mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #263] Questionable implementation of DNSClass -> u16 conversion #423
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#423
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @briansmith on GitHub (Oct 25, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/263
DNSClass::OPTs are constructed using code like this, that reads the value from the wire:Thus, the value within a
DNSClass::OPTcan be any value in [0, 65535], and the peer chooses that value, so it is attacker-controlled.Now consider the implementation of
DNSClasss-> u16 conversion:This has a collision for values {1, 3, 4, 254, 255} of version.
Now consider the
Ordimplementation forDNSClass:This is using the colliding
DNSClass->u16conversion.In turn, the
Ordimplementation is used for the purposes of determining the canonical order of records in a record set. DNSSEC requires us to sort records in the canonical order. However, there's no way that we're guaranteeing that things are in the canonical order here, because of the collision. Because of #200, this broken sorting logic is used not just for signing, but also for verifying DNSSEC-signed record sets.I don't see any attack that can make use of this + #200, but this is definitely buggy.
The solution is probably to rewrite the
Ordimplementation ofDNSClassto not use the buggyDNSClass->u16conversion. Probably we should also remove the buggy conversion function itself.@briansmith commented on GitHub (Oct 25, 2017):
Note that test
test_order()doesn't considerORD. If it did, we would probably have discovered this bug at the time that test was written.@bluejekyll commented on GitHub (Oct 25, 2017):
This is a great catch!
@bluejekyll commented on GitHub (Nov 21, 2017):
Ok, I reviewed the code, and usage.
This field is annoying, it's overloaded to mean the max payload length from the rfc: https://tools.ietf.org/html/rfc6891#section-6.1.2
Basically,
OPTis only used in the EDNS context. Given that context, it represents the maximum length which is supported by the server. Most set this to 4,096. TRust-DNS actually defaults (it should be configurable) to 1500, which is generally a good network packet size. Though, this should really be 28 less for IPv4 or 48 less for IPv6.@bluejekyll commented on GitHub (Nov 26, 2017):
Reopening... The Opt max_data_length should never be less than 512 (i.e. original DNS max packet length). This will actually fix the concern of this issue.