Skip to content

Commit e8233bc

Browse files
committed
resolved: refuse validating wildcard RRs for SOA, NSEC3, DNAME
1 parent 7160eb1 commit e8233bc

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/resolve/dns-type.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ bool dns_type_may_redirect(uint16_t type) {
120120
DNS_TYPE_KEY);
121121
}
122122

123+
bool dns_type_may_wildcard(uint16_t type) {
124+
125+
/* The following records may not be expanded from wildcard RRsets */
126+
127+
if (dns_type_is_pseudo(type))
128+
return false;
129+
130+
return !IN_SET(type,
131+
DNS_TYPE_NSEC3,
132+
DNS_TYPE_SOA,
133+
134+
/* Prohibited by https://tools.ietf.org/html/rfc4592#section-4.4 */
135+
DNS_TYPE_DNAME);
136+
}
137+
123138
bool dns_type_is_dnssec(uint16_t type) {
124139
return IN_SET(type,
125140
DNS_TYPE_DS,

src/resolve/dns-type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ bool dns_type_is_valid_rr(uint16_t type);
131131
bool dns_type_may_redirect(uint16_t type);
132132
bool dns_type_is_dnssec(uint16_t type);
133133
bool dns_type_is_obsolete(uint16_t type);
134+
bool dns_type_may_wildcard(uint16_t type);
134135

135136
bool dns_class_is_pseudo(uint16_t class);
136137
bool dns_class_is_valid_rr(uint16_t class);

src/resolve/resolved-dns-dnssec.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ int dnssec_verify_rrset(
548548
r = dns_name_suffix(DNS_RESOURCE_KEY_NAME(key), rrsig->rrsig.labels, &source);
549549
if (r < 0)
550550
return r;
551+
if (r > 0 && !dns_type_may_wildcard(rrsig->rrsig.type_covered)) {
552+
/* We refuse to validate NSEC3 or SOA RRs that are synthesized from wildcards */
553+
*result = DNSSEC_INVALID;
554+
return 0;
555+
}
551556
if (r == 1) {
552557
/* If we stripped a single label, then let's see if that maybe was "*". If so, we are not really
553558
* synthesized from a wildcard, we are the wildcard itself. Treat that like a normal name. */

0 commit comments

Comments
 (0)