LOG(prefix << qname << ": Cannot use " << name << '/' << qtype << " records from cache: Bogus" << endl);
return false;
}
- // We could validate Indeterminete authoritative records here.
+ // We could validate Indeterminate authoritative records here.
return true;
}
*flawedNSSet = false;
vState state{vState::Indeterminate};
- if (bool isAuth = false; g_recCache->get(d_now.tv_sec, subdomain, QType::NS, flags, &nsVector, d_cacheRemote, d_routingTag, nullptr, nullptr, nullptr, nullptr, &isAuth) > 0 &&
- canUseRecords(prefix, qname, subdomain, QType::NS, state)) {
+ if (bool isAuth = false; g_recCache->get(d_now.tv_sec, subdomain, QType::NS, flags, &nsVector, d_cacheRemote, d_routingTag, nullptr, nullptr, nullptr, &state, &isAuth) > 0 && canUseRecords(prefix, qname, subdomain, QType::NS, state)) {
if (s_maxnsperresolve > 0 && nsVector.size() > s_maxnsperresolve) {
vector<DNSRecord> selected;
selected.reserve(s_maxnsperresolve);
}
soaInAuth = true;
}
- if (!haveAnswers && lwr.d_rcode == RCode::NoError) {
- acceptDelegation = true;
- }
}
/* dealing with records in additional */
else if (rec->d_place == DNSResourceRecord::ADDITIONAL) {
}
} // end of first loop, handled answer and most of authority section
+ if (!haveAnswers && lwr.d_rcode == RCode::NoError) {
+ acceptDelegation = true;
+ }
+
sanitizeRecordsPass2(prefix, lwr, qname, qtype, auth, allowedAnswerNames, allowedAdditionals, cnameSeen, acceptDelegation && !soaInAuth, skipvec, skipCount);
}
}
}
+ bool seenBogusRRSet = false;
for (auto tCacheEntry = tcache.begin(); tCacheEntry != tcache.end(); ++tCacheEntry) {
if (tCacheEntry->second.records.empty()) { // this happens when we did store signatures, but passed on the records themselves
}
if (vStateIsBogus(recordState)) {
+ seenBogusRRSet = true;
/* this is a TTD by now, be careful */
for (auto& record : tCacheEntry->second.records) {
auto newval = std::min(record.d_ttl, static_cast<uint32_t>(s_maxbogusttl + d_now.tv_sec));
if (tCacheEntry->first.type != QType::NSEC3 && (tCacheEntry->first.type == QType::DS || tCacheEntry->first.type == QType::NS || tCacheEntry->first.type == QType::A || tCacheEntry->first.type == QType::AAAA || isAA || wasForwardRecurse)) {
bool doCache = true;
- if (tCacheEntry->first.place == DNSResourceRecord::ANSWER && ednsmask) {
+ if (!isAA && seenBogusRRSet) {
+ LOG(prefix << qname << ": Not caching non-authoritative rrsets received with Bogus answer" << endl);
+ doCache = false;
+ }
+ if (doCache && tCacheEntry->first.place == DNSResourceRecord::ANSWER && ednsmask) {
const bool isv4 = ednsmask->isIPv4();
if ((isv4 && s_ecsipv4nevercache) || (!isv4 && s_ecsipv6nevercache)) {
doCache = false;
BOOST_AUTO_TEST_CASE(test_dnssec_bogus_unsigned_ds)
{
std::unique_ptr<SyncRes> sr;
- initSR(sr, true);
+ initSR(sr, true, false);
setDNSSECValidation(sr, DNSSECMode::ValidateAll);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::BogusNoRRSIG);
BOOST_REQUIRE_EQUAL(ret.size(), 2U);
- BOOST_CHECK_EQUAL(queriesCount, 3U);
+ BOOST_CHECK_EQUAL(queriesCount, 4U);
/* again, to test the cache */
ret.clear();
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::BogusNoRRSIG);
BOOST_REQUIRE_EQUAL(ret.size(), 2U);
- BOOST_CHECK_EQUAL(queriesCount, 3U);
+ BOOST_CHECK_EQUAL(queriesCount, 4U);
/* now we ask directly for the DS */
ret.clear();
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::BogusNoRRSIG);
BOOST_REQUIRE_EQUAL(ret.size(), 1U);
- BOOST_CHECK_EQUAL(queriesCount, 3U);
+ BOOST_CHECK_EQUAL(queriesCount, 4U);
}
BOOST_AUTO_TEST_CASE(test_dnssec_bogus_unsigned_ds_direct)
0 b.www.1.ghost.example.net. 3600 IN A 192.0.2.7
Rcode: 0 (No Error), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
Reply to question for qname='b.www.1.ghost.example.net.', qtype=A
-0 c.www.1.ghost.example.net. 3600 IN A 192.0.2.7
-Rcode: 0 (No Error), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+1 ghost.example.net. 3600 IN SOA ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
+Rcode: 3 (Non-Existent domain), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
Reply to question for qname='c.www.1.ghost.example.net.', qtype=A
1 ghost.example.net. 3600 IN SOA ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
Rcode: 3 (Non-Existent domain), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
0 b.www.2.ghost.example.net. 3600 IN A 192.0.2.8
Rcode: 0 (No Error), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
Reply to question for qname='b.www.2.ghost.example.net.', qtype=A
-0 c.www.2.ghost.example.net. 3600 IN A 192.0.2.8
-Rcode: 0 (No Error), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+1 ghost.example.net. 3600 IN SOA ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
+Rcode: 3 (Non-Existent domain), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
Reply to question for qname='c.www.2.ghost.example.net.', qtype=A
1 ghost.example.net. 3600 IN SOA ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
Rcode: 3 (Non-Existent domain), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0