]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
More strict validation of the relation between qname, rname and authname for NS records 16340/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 22 Sep 2025 09:44:12 +0000 (11:44 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 24 Sep 2025 09:36:18 +0000 (11:36 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/syncres.cc

index 987a6aa5a1ab35fb3ac0a2492a66b86d3792f4dd..d57276fe690a732bf972a137024da1eebbe5af12 100644 (file)
@@ -4379,9 +4379,9 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN
         ++skipCount;
         continue;
       }
-      if (rec->d_type == QType::NS && !d_updatingRootNS && rec->d_name == g_rootdnsname) {
+      if (rec->d_type == QType::NS && (!rec->d_name.isPartOf(auth) || (rec->d_name == auth && !d_updatingRootNS) || !qname.isPartOf(rec->d_name))) {
         /*
-         * We don't want to pick up root NS records in AUTHORITY and their associated ADDITIONAL sections of random queries.
+         * We don't want to pick up irrelevant NS records in AUTHORITY and their associated ADDITIONAL sections.
          * So remove them and don't add them to allowedAdditionals.
          */
         LOG(prefix << qname << ": Removing NS record '" << rec->toString() << "' in the AUTHORITY section of a response received from " << auth << endl);