From: Remi Gacogne Date: Tue, 9 May 2017 15:21:21 +0000 (+0200) Subject: rec: Add a `nsec3-max-iterations` setting, default to 2500 X-Git-Tag: rec-4.1.0-alpha1~50^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d377bb54f4099b61d38ec36a2b9f99166d0a7364;p=pdns rec: Add a `nsec3-max-iterations` setting, default to 2500 --- diff --git a/docs/markdown/recursor/settings.md b/docs/markdown/recursor/settings.md index 3c9b8771d..49bd3bbb8 100644 --- a/docs/markdown/recursor/settings.md +++ b/docs/markdown/recursor/settings.md @@ -721,6 +721,14 @@ to continue serving your customers. Can be set at runtime using Number of milliseconds to wait for a remote authoritative server to respond. +## `nsec3-max-iterations` +* Integer +* Default: 2500 +* Available since: 4.1 + +Maximum number of iterations allowed for an NSEC3 record. If an answer containing an NSEC3 record +with more iterations is received, its DNSSEC validation status is treated as Insecure. + ## `packetcache-ttl` * Integer * Default: 3600 diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 880358103..2220f192c 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2732,6 +2732,7 @@ static int serviceMain(int argc, char*argv[]) } g_dnssecLogBogus = ::arg().mustDo("dnssec-log-bogus"); + g_maxNSEC3Iterations = ::arg().asNum("nsec3-max-iterations"); try { loadRecursorLuaConfig(::arg()["lua-config-file"], ::arg().mustDo("daemon")); @@ -3223,6 +3224,7 @@ int main(int argc, char **argv) ::arg().set("snmp-master-socket", "If set and snmp-agent is set, the socket to use to register to the SNMP master")=""; ::arg().set("tcp-fast-open", "Enable TCP Fast Open support on the listening sockets, using the supplied numerical value as the queue size")="0"; + ::arg().set("nsec3-max-iterations", "Maximum number of iterations allowed for an NSEC3 record")="2500"; ::arg().setCmd("help","Provide a helpful message"); ::arg().setCmd("version","Print version string"); diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 60b4f4998..2ec5dd0bf 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -1696,6 +1696,10 @@ void SyncRes::getDenialValidationState(NegCache::NegCacheEntry& ne, vState& stat updateValidationState(state, Insecure); return; } + else if (res == INSECURE) { + LOG("Insecure denial found for "<d_iterations > g_maxNSEC3Iterations) { + return INSECURE; + } + string h = hashQNameWithSalt(nsec3->d_salt, nsec3->d_iterations, qname); // cerr<<"Salt length: "<d_salt.length()<<", iterations: "<d_iterations<<", hashed: "<d_iterations > g_maxNSEC3Iterations) { + return INSECURE; + } + string h = hashQNameWithSalt(nsec3->d_salt, nsec3->d_iterations, sname); string beginHash=fromBase32Hex(v.first.first.getRawLabels()[0]); @@ -167,6 +176,9 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 auto nsec3 = std::dynamic_pointer_cast(r); if(!nsec3) continue; + if (g_maxNSEC3Iterations && nsec3->d_iterations > g_maxNSEC3Iterations) { + return INSECURE; + } string h = hashQNameWithSalt(nsec3->d_salt, nsec3->d_iterations, nextCloser); string beginHash=fromBase32Hex(v.first.first.getRawLabels()[0]); diff --git a/pdns/validate.hh b/pdns/validate.hh index 540569786..5713de9c7 100644 --- a/pdns/validate.hh +++ b/pdns/validate.hh @@ -28,6 +28,7 @@ #include "dnsrecords.hh" extern bool g_dnssecLOG; +extern uint16_t g_maxNSEC3Iterations; // 4033 5 enum vState { Indeterminate, Bogus, Insecure, Secure, NTA, TA };