Hickory DNS Recursor Cache Poisoning via Sibling Zone Delegation
The experimental `hickory-recursor` crate in Hickory DNS is vulnerable to cross-zone cache poisoning due to storing DNS records keyed by record name/type instead of query, enabling an attacker to redirect queries for a victim zone to an attacker-controlled nameserver.
The Hickory DNS project’s experimental hickory-recursor crate, now integrated into hickory-resolver under the recursor feature, contains a vulnerability in its DNS record cache (DnsLru). The cache stores records based on the record’s name and type, rather than the originating query. This design flaw allows for cross-zone cache poisoning because the cache_response() function chains ANSWER, AUTHORITY, and ADDITIONAL sections into a single record iterator during insertion. The bailiwick filter uses the zone context of the NS pool that serviced the lookup, leading to improper validation of records from sibling zones. This issue affects all published versions of the experimental hickory-recursor crate prior to its integration into hickory-resolver 0.26.0. Users of the hickory-dns binary configured with the recursor feature are affected.
Attack Chain
- Attacker registers the domain
attacker.poc.and sets up a malicious nameserver. - Hickory DNS server queries the nameserver for
attacker.poc.to build its NS pool. - The attacker’s nameserver responds with an
AUTHORITYsection that includes a malicious record delegating a sibling zone, such asvictim.poc., tons.evil.poc.. - The Hickory DNS server’s bailiwick check incorrectly validates the malicious
victim.poc. NS ns.evil.poc.record becausevictim.poc.is a subdomain of the parent zonepoc.. - The malicious NS record for
victim.poc.is stored in the cache, keyed by(victim.poc., NS). - A client queries the Hickory DNS server for a name within the
victim.poc.zone. - Hickory DNS server builds its NS pool for
victim.poc.using the poisoned cache entry, directing queries tons.evil.poc.. - The attacker’s nameserver now receives queries intended for the legitimate
victim.poc.nameserver, allowing the attacker to intercept and manipulate DNS resolution.
Impact
Successful exploitation of this vulnerability allows an attacker to redirect DNS queries for a target domain to an attacker-controlled nameserver. This can lead to various malicious activities, including phishing attacks, man-in-the-middle attacks, and the distribution of malware. The vulnerability affects any system using Hickory DNS with the recursor feature enabled, potentially impacting a wide range of users relying on the resolver for DNS resolution. If the targeted domain is critical for service delivery (e.g., email, web), the impact could be significant.
Recommendation
- Upgrade to
hickory-resolverversion 0.26.0 or later with therecursorfeature enabled to address the vulnerability as described in the advisory (https://github.com/advisories/GHSA-83hf-93m4-rgwq). - If upgrading is not immediately feasible, disable the
recursorfeature inhickory-dnsto prevent exploitation. - Implement monitoring for unexpected NS record changes, focusing on
AUTHORITYsections of DNS responses, using a custom rule based on your environment and typical DNS configurations.
Detection coverage 2
Detect NS Record Modification in DNS Responses
mediumDetects modifications to NS records within DNS responses, which could indicate a cache poisoning attempt.
Hickory DNS Recursion Enabled
infoDetects when Hickory DNS is configured to act as a recursive resolver. This is an informational rule to identify systems at risk.
Detection queries are kept inside the platform. Get full rules →