]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: refuse validating wildcard RRs for SOA, NSEC3, DNAME
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Jan 2016 01:29:31 +0000 (02:29 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Jan 2016 19:21:57 +0000 (20:21 +0100)
src/resolve/dns-type.c
src/resolve/dns-type.h
src/resolve/resolved-dns-dnssec.c

index fb8228048dab1d1d8b01dc4dbf4cab42c35ea424..47a37fa0a7577fa76f2a49e9a3e088942f25a065 100644 (file)
@@ -120,6 +120,21 @@ bool dns_type_may_redirect(uint16_t type) {
                        DNS_TYPE_KEY);
 }
 
+bool dns_type_may_wildcard(uint16_t type) {
+
+        /* The following records may not be expanded from wildcard RRsets */
+
+        if (dns_type_is_pseudo(type))
+                return false;
+
+        return !IN_SET(type,
+                       DNS_TYPE_NSEC3,
+                       DNS_TYPE_SOA,
+
+                       /* Prohibited by https://tools.ietf.org/html/rfc4592#section-4.4 */
+                       DNS_TYPE_DNAME);
+}
+
 bool dns_type_is_dnssec(uint16_t type) {
         return IN_SET(type,
                       DNS_TYPE_DS,
index 45080fd243a3c6f7390562497b53194b244250e2..747bc854e1a16046f163cc56a1a26cfba6043665 100644 (file)
@@ -131,6 +131,7 @@ bool dns_type_is_valid_rr(uint16_t type);
 bool dns_type_may_redirect(uint16_t type);
 bool dns_type_is_dnssec(uint16_t type);
 bool dns_type_is_obsolete(uint16_t type);
+bool dns_type_may_wildcard(uint16_t type);
 
 bool dns_class_is_pseudo(uint16_t class);
 bool dns_class_is_valid_rr(uint16_t class);
index a18ae56b9ea360196bd5ec7a9ea9212a7b875583..6f0f8f837e702dc2a02f58373980010013e47088 100644 (file)
@@ -548,6 +548,11 @@ int dnssec_verify_rrset(
         r = dns_name_suffix(DNS_RESOURCE_KEY_NAME(key), rrsig->rrsig.labels, &source);
         if (r < 0)
                 return r;
+        if (r > 0 && !dns_type_may_wildcard(rrsig->rrsig.type_covered)) {
+                /* We refuse to validate NSEC3 or SOA RRs that are synthesized from wildcards */
+                *result = DNSSEC_INVALID;
+                return 0;
+        }
         if (r == 1) {
                 /* If we stripped a single label, then let's see if that maybe was "*". If so, we are not really
                  * synthesized from a wildcard, we are the wildcard itself. Treat that like a normal name. */