Conversation
Implements RFC 6764 Section 8 security requirement to validate that discovered service endpoints remain within the same domain as the queried domain. This prevents DNS hijacking attacks where malicious DNS records redirect clients to attacker-controlled servers. Security Issue: Without domain validation, if DNS is hijacked, an attacker can redirect example.com to evil.hackers.are.us. Even with TLS and valid certificates for evil.hackers.are.us, credentials would be leaked to the attacker. RFC 6764 Section 8 states: "In the absence of a secure DNS option, clients SHOULD check that the target FQDN returned in the SRV record matches the original service domain that was queried. If the target FQDN is not in the queried domain, clients SHOULD verify with the user that the SRV target FQDN is suitable for use before executing any connections to the host." Implementation: 1. Added _is_subdomain_or_same() function to validate discovered domains - Allows same domain (example.com -> example.com) - Allows subdomains (example.com -> calendar.example.com) - Rejects different domains (example.com -> evil.com) 2. Applied validation to SRV record discovery - Checks hostname from SRV records - Logs warning and rejects if domain mismatch - Falls back to next discovery method 3. Applied validation to well-known URI redirects - Checks redirect Location header - Rejects redirects to different domains - Returns None to try alternative discovery 4. Updated security documentation - Removed TODO comment (now implemented) - Added RFC 6764 Section 8 reference - Documented domain validation mitigation Testing: - Doctests verify _is_subdomain_or_same() logic - Handles edge cases: subdomains, case sensitivity, trailing dots This provides defense-in-depth alongside TLS certificate verification. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
tobixen
added a commit
that referenced
this pull request
Dec 1, 2025
Resolves #574 - DNS service discovery should not cause redirections to other domains. That is a security risk unless using DNSSEC. --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solves #574
🤖 Generated with Claude Code