mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-26 03:35:52 +03:00
[GH-ISSUE #1203] MessageResponseBuilder::error_msg does not support all RCODEs #627
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#627
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 @jonasbb on GitHub (Sep 15, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1203
Describe the bug
MessageResponseBuilder::error_msgallows to construct a response message with a given response code. The implementation fails to set the EDNS options if the response code requires EDNS.To Reproduce
Steps to reproduce the behavior:
A minimal implementation of
RequestHandlerfor theservercrate:This code should produce a DNS response with the status code
BADVERSbut it does not create a EDNS record, thus it will end up asNOERROR. The lower 4 bit ofBADVERSare all 0 which maps to theNOERRORvalue.Expected behavior
Silently changing the response code is very bad. I can see two possible solutions here:
This would be the most developer friendly solution. If a EDNS record already exists it simply sets the high bits. This could lead to a situation where the server response with a EDNS record even if the client didn't specify EDNS support. But these "extended" response codes only make sense in the presence of EDNS.
Result<_, _>.One problem with both solutions is that
MessageResponse::set_ednsallows to overwrite the EDNS record of the response after setting the correct response code bits. This again could silently alter the intended response code.Version:
Crate: server
Version: 0.20.0-alpha.1 and main
Additional context
The same problem is also present in
trust_dns_server::authority::Catalog(0.20.0-alpha.1 and main).github.com/bluejekyll/trust-dns@48f625ad0d/crates/server/src/authority/catalog.rs (L94-L124)Here the problem is not related to the use of
error_msg, but the code implements the behavior manually and forgets to set the high response code in the EDNS record.The documentation for
Header::set_response_codehints that it does not support all response codes. The documentation could be improved with a link toEDNSand a small example how to properly set any response code.@bluejekyll commented on GitHub (Sep 15, 2020):
This can definitely be improved. It looks like you've identified some ways that you want to improve the situation. Would you be interested in submitting a PR for this?
@jonasbb commented on GitHub (Sep 16, 2020):
Yes, I will take a look at that. The solution should presumably also be applied to
Messageinproto, since that has an almost identicalerror_msgfunction.@bluejekyll commented on GitHub (Sep 16, 2020):
Oh, it's too bad those are duplicating the logic. Would be nice, if it's not difficult, to combine them.