]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
limit the number of NSEC3 iterations RFC5155 10.3
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 20 Jul 2014 11:15:53 +0000 (13:15 +0200)
committermind04 <mind04@monshouwer.org>
Thu, 30 Apr 2015 23:13:39 +0000 (01:13 +0200)
pdns/common_startup.cc
pdns/dbdnsseckeeper.cc
pdns/pdns.conf-dist
pdns/pdnssec.cc

index dc1f5f3d71d0e08d9a88b955e3f4a1c0815b45c6..c7067524983ed204c634eb54671466be4096b96f 100644 (file)
@@ -144,6 +144,7 @@ void declareArguments()
   ::arg().set("default-ksk-size","Default KSK size (0 means default)")="0";
   ::arg().set("default-zsk-algorithms","Default ZSK algorithms")="rsasha256";
   ::arg().set("default-zsk-size","Default KSK size (0 means default)")="0";
+  ::arg().set("max-nsec3-iterations","Limit the number of NSEC3 hash iterations")="500"; // RFC5155 10.3
 
   ::arg().set("include-dir","Include *.conf files from this directory");
 }
index 4020925c448a4ead832406b29f75d41e3cd6ab81..59f668a544d0ca204a8e8392fcf9a43b89d6766d 100644 (file)
@@ -231,11 +231,16 @@ bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordConte
   if(value.empty()) { // "no NSEC3"
     return false;
   }
-     
+
+  static int maxNSEC3Iterations=::arg().asNum("max-nsec3-iterations");
   if(ns3p) {
     NSEC3PARAMRecordContent* tmp=dynamic_cast<NSEC3PARAMRecordContent*>(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value));
     *ns3p = *tmp;
     delete tmp;
+    if (ns3p->d_iterations > maxNSEC3Iterations) {
+      ns3p->d_iterations = maxNSEC3Iterations;
+      L<<Logger::Error<<"Number of NSEC3 iterations for zone '"<<zname<<"' is above 'max-nsec3-iterations'. Value adjusted to: "<<maxNSEC3Iterations<<endl;
+    }
   }
   if(narrow) {
     getFromMeta(zname, "NSEC3NARROW", value);
@@ -246,6 +251,10 @@ bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordConte
 
 bool DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow)
 {
+  static int maxNSEC3Iterations=::arg().asNum("max-nsec3-iterations");
+  if (ns3p.d_iterations > maxNSEC3Iterations)
+    throw runtime_error("Can't set NSEC3PARAM for zone '"+zname+"': number of NSEC3 iterations is above 'max-nsec3-iterations'");
+
   clearCaches(zname);
   string descr = ns3p.getZoneRepresentation();
   vector<string> meta;
index 97e6c82ed1e332a9baeac403e7cfb3a15d45d8be..06b2fff27d79163371001359c0517cbd501c9a3a 100644 (file)
 #
 # max-ent-entries=100000
 
+#################################
+# max-nsec3-iterations Limit the number of NSEC3 hash iterations
+#
+# max-nsec3-iterations=500
+
 #################################
 # max-queue-length     Maximum queuelength before considering situation lost
 #
index 8bda743303c2a4cf13820e3d83fd1fb4e5d0fec8..352e9a054a4568940ff14bd55e3be10d12105c6d 100644 (file)
@@ -132,6 +132,7 @@ void loadMainConfig(const std::string& configdir)
   ::arg().set("max-ent-entries", "Maximum number of empty non-terminals in a zone")="100000";
   ::arg().set("module-dir","Default directory for modules")=LIBDIR;
   ::arg().setSwitch("direct-dnskey","Fetch DNSKEY RRs from backend during DNSKEY synthesis")="no";
+  ::arg().set("max-nsec3-iterations","Limit the number of NSEC3 hash iterations")="500"; // RFC5155 10.3
   ::arg().laxFile(configname.c_str());
 
   BackendMakers().launch(::arg()["launch"]); // vrooooom!