The vulnerability is a result of improper input validation and a lack of output encoding when processing DNS records of the types LOC, RP, SSHFP, and TLSA. An authenticated user with DNS management permissions can exploit this to inject arbitrary records into the bind9 zone file, potentially leading to domain hijacking or DNS amplification attacks.
The vulnerability exists in a multi-step process that would be visible in a runtime profile:
- The
DomainZones::add function is the primary entry point that receives the malicious user input. Before the patch, it performed no validation at all for the affected record types.
- The patch introduced new validation functions in the
Validate class. However, these functions are flawed. Validate::validateDnsLoc uses a regex with \s+ that allows newlines, enabling an attacker to inject additional DNS records. Validate::validateDnsTlsa fails to enforce a maximum length for certain records, allowing for oversized payloads.
- A fundamental flaw is that all the new validation functions (
validateDnsLoc, validateDnsTlsa, validateDnsRp, validateDnsSshfp) return the original, unescaped input. The DomainZones::add function then uses this raw data, which is subsequently concatenated directly into the DNS zone file, causing the injection (CWE-74).
During an exploit, a profiler would show a call to DomainZones::add, which in turn calls one of the flawed Validate methods before the malicious data is processed and written to the zone file.