|
| 1 | +From cc92db37659144dccc482cb88533a741929712a7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Matthijs Mekking <matthijs@isc.org> |
| 3 | +Date: Tue, 3 Mar 2026 10:40:36 +0100 |
| 4 | +Subject: [PATCH 1/3] Check iterations in isdelegation() |
| 5 | + |
| 6 | +When looking up an NSEC3 as part of an insecurity proof, check the |
| 7 | +number of iterations. If this is too high, treat the answer as insecure |
| 8 | +by marking the answer with trust level "answer", indicating that they |
| 9 | +did not validate, but could be cached as insecure. |
| 10 | + |
| 11 | +(cherry picked from commit 988040a5e02f86f4a8cdb0704e8d501f9082a89c) |
| 12 | +--- |
| 13 | + lib/dns/validator.c | 65 ++++++++++++++++++++++++++++++++++----------- |
| 14 | + 1 file changed, 49 insertions(+), 16 deletions(-) |
| 15 | + |
| 16 | +diff --git a/lib/dns/validator.c b/lib/dns/validator.c |
| 17 | +index 4e856e5..082db33 100644 |
| 18 | +--- a/lib/dns/validator.c |
| 19 | ++++ b/lib/dns/validator.c |
| 20 | +@@ -251,12 +251,25 @@ exit_check(dns_validator_t *val) { |
| 21 | + } |
| 22 | + |
| 23 | + /*% |
| 24 | +- * Look in the NSEC record returned from a DS query to see if there is |
| 25 | +- * a NS RRset at this name. If it is found we are at a delegation point. |
| 26 | ++ * The isdelegation() function is called as part of seeking the DS record. |
| 27 | ++ * Look in the NSEC or NSEC3 record returned from a DS query to see if the |
| 28 | ++ * record has the NS bitmap set. If so, we are at a delegation point. |
| 29 | ++ * |
| 30 | ++ * If the response contains NSEC3 records with too high iterations, we cannot |
| 31 | ++ * (or rather we are not going to) validate the insecurity proof. Instead we |
| 32 | ++ * are going to treat the message as insecure and just assume the DS was at |
| 33 | ++ * the delegation. |
| 34 | ++ * |
| 35 | ++ * Returns: |
| 36 | ++ *\li #ISC_R_SUCCESS the NS bitmap was set in the NSEC or NSEC3 record, or |
| 37 | ++ * the NSEC3 covers the name (in case of opt-out), or |
| 38 | ++ * we cannot validate the insecurity proof and are going |
| 39 | ++ * to treat the message as isnecure. |
| 40 | ++ *\li #ISC_R_NOTFOUND the NS bitmap was not set, |
| 41 | + */ |
| 42 | +-static bool |
| 43 | +-isdelegation(dns_name_t *name, dns_rdataset_t *rdataset, |
| 44 | +- isc_result_t dbresult) { |
| 45 | ++static isc_result_t |
| 46 | ++isdelegation(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset, |
| 47 | ++ isc_result_t dbresult, const char *caller) { |
| 48 | + dns_fixedname_t fixed; |
| 49 | + dns_label_t hashlabel; |
| 50 | + dns_name_t nsec3name; |
| 51 | +@@ -284,7 +297,7 @@ isdelegation(dns_name_t *name, dns_rdataset_t *rdataset, |
| 52 | + goto trynsec3; |
| 53 | + } |
| 54 | + if (result != ISC_R_SUCCESS) { |
| 55 | +- return (false); |
| 56 | ++ return (ISC_R_NOTFOUND); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | +@@ -298,7 +311,7 @@ isdelegation(dns_name_t *name, dns_rdataset_t *rdataset, |
| 61 | + dns_rdata_reset(&rdata); |
| 62 | + } |
| 63 | + dns_rdataset_disassociate(&set); |
| 64 | +- return (found); |
| 65 | ++ return (found ? ISC_R_SUCCESS : ISC_R_NOTFOUND); |
| 66 | + |
| 67 | + trynsec3: |
| 68 | + /* |
| 69 | +@@ -334,6 +347,18 @@ trynsec3: |
| 70 | + if (nsec3.hash != 1) { |
| 71 | + continue; |
| 72 | + } |
| 73 | ++ /* |
| 74 | ++ * If there are too many iterations assume bad things |
| 75 | ++ * are happening and bail out early. Treat as if the |
| 76 | ++ * DS was at the delegation. |
| 77 | ++ */ |
| 78 | ++ if (nsec3.iterations > DNS_NSEC3_MAXITERATIONS) { |
| 79 | ++ validator_log(val, ISC_LOG_DEBUG(3), |
| 80 | ++ "%s: too many iterations", |
| 81 | ++ caller); |
| 82 | ++ dns_rdataset_disassociate(&set); |
| 83 | ++ return (ISC_R_SUCCESS); |
| 84 | ++ } |
| 85 | + length = isc_iterated_hash( |
| 86 | + hash, nsec3.hash, nsec3.iterations, nsec3.salt, |
| 87 | + nsec3.salt_length, name->ndata, name->length); |
| 88 | +@@ -345,7 +370,7 @@ trynsec3: |
| 89 | + found = dns_nsec3_typepresent(&rdata, |
| 90 | + dns_rdatatype_ns); |
| 91 | + dns_rdataset_disassociate(&set); |
| 92 | +- return (found); |
| 93 | ++ return (found ? ISC_R_SUCCESS : ISC_R_NOTFOUND); |
| 94 | + } |
| 95 | + if ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) == 0) { |
| 96 | + continue; |
| 97 | +@@ -361,12 +386,12 @@ trynsec3: |
| 98 | + memcmp(hash, nsec3.next, length) < 0))) |
| 99 | + { |
| 100 | + dns_rdataset_disassociate(&set); |
| 101 | +- return (true); |
| 102 | ++ return (ISC_R_SUCCESS); |
| 103 | + } |
| 104 | + } |
| 105 | + dns_rdataset_disassociate(&set); |
| 106 | + } |
| 107 | +- return (found); |
| 108 | ++ return (found ? ISC_R_SUCCESS : ISC_R_NOTFOUND); |
| 109 | + } |
| 110 | + |
| 111 | + /*% |
| 112 | +@@ -582,8 +607,10 @@ fetch_callback_ds(isc_task_t *task, isc_event_t *event) { |
| 113 | + } else if (eresult == DNS_R_SERVFAIL) { |
| 114 | + goto unexpected; |
| 115 | + } else if (eresult != DNS_R_CNAME && |
| 116 | +- isdelegation(dns_fixedname_name(&devent->foundname), |
| 117 | +- &val->frdataset, eresult)) |
| 118 | ++ isdelegation(val, |
| 119 | ++ dns_fixedname_name(&devent->foundname), |
| 120 | ++ &val->frdataset, eresult, |
| 121 | ++ "fetch_callback_ds") == ISC_R_SUCCESS) |
| 122 | + { |
| 123 | + /* |
| 124 | + * Failed to find a DS while trying to prove |
| 125 | +@@ -743,10 +770,13 @@ validator_callback_ds(isc_task_t *task, isc_event_t *event) { |
| 126 | + dns_trust_totext(val->frdataset.trust)); |
| 127 | + have_dsset = (val->frdataset.type == dns_rdatatype_ds); |
| 128 | + name = dns_fixedname_name(&val->fname); |
| 129 | ++ |
| 130 | + if ((val->attributes & VALATTR_INSECURITY) != 0 && |
| 131 | + val->frdataset.covers == dns_rdatatype_ds && |
| 132 | + NEGATIVE(&val->frdataset) && |
| 133 | +- isdelegation(name, &val->frdataset, DNS_R_NCACHENXRRSET)) |
| 134 | ++ isdelegation(val, name, &val->frdataset, |
| 135 | ++ DNS_R_NCACHENXRRSET, |
| 136 | ++ "validator_callback_ds") == ISC_R_SUCCESS) |
| 137 | + { |
| 138 | + result = markanswer(val, "validator_callback_ds", |
| 139 | + "no DS and this is a delegation"); |
| 140 | +@@ -2565,7 +2595,8 @@ validate_nx(dns_validator_t *val, bool resume) { |
| 141 | + result = findnsec3proofs(val); |
| 142 | + if (result == DNS_R_NSEC3ITERRANGE) { |
| 143 | + validator_log(val, ISC_LOG_DEBUG(3), |
| 144 | +- "too many iterations"); |
| 145 | ++ "%s: too many iterations", |
| 146 | ++ __func__); |
| 147 | + markanswer(val, "validate_nx (3)", NULL); |
| 148 | + return (ISC_R_SUCCESS); |
| 149 | + } |
| 150 | +@@ -2601,7 +2632,7 @@ validate_nx(dns_validator_t *val, bool resume) { |
| 151 | + result = findnsec3proofs(val); |
| 152 | + if (result == DNS_R_NSEC3ITERRANGE) { |
| 153 | + validator_log(val, ISC_LOG_DEBUG(3), |
| 154 | +- "too many iterations"); |
| 155 | ++ "%s: too many iterations", __func__); |
| 156 | + markanswer(val, "validate_nx (4)", NULL); |
| 157 | + return (ISC_R_SUCCESS); |
| 158 | + } |
| 159 | +@@ -2818,7 +2849,9 @@ seek_ds(dns_validator_t *val, isc_result_t *resp) { |
| 160 | + return (ISC_R_COMPLETE); |
| 161 | + } |
| 162 | + |
| 163 | +- if (isdelegation(tname, &val->frdataset, result)) { |
| 164 | ++ result = isdelegation(val, tname, &val->frdataset, result, |
| 165 | ++ "seek_ds"); |
| 166 | ++ if (result == ISC_R_SUCCESS) { |
| 167 | + *resp = markanswer(val, "proveunsecure (4)", |
| 168 | + "this is a delegation"); |
| 169 | + return (ISC_R_COMPLETE); |
| 170 | +-- |
| 171 | +2.45.4 |
| 172 | + |
| 173 | + |
| 174 | +From 76a45317d9806512c7f1365e6893267ce681df00 Mon Sep 17 00:00:00 2001 |
| 175 | +From: Matthijs Mekking <matthijs@isc.org> |
| 176 | +Date: Tue, 3 Mar 2026 11:17:25 +0100 |
| 177 | +Subject: [PATCH 2/3] Don't verify already trusted rdatasets |
| 178 | + |
| 179 | +If we already marked an rdataset as secure (or it has even stronger |
| 180 | +trust), there is no need to cryptographically verify it again. |
| 181 | + |
| 182 | +(cherry picked from commit 0ec08c212022d08c9717f2bc6bd3e8ebd6f034ce) |
| 183 | +--- |
| 184 | + lib/dns/include/dns/types.h | 1 + |
| 185 | + lib/dns/validator.c | 7 +++++++ |
| 186 | + 2 files changed, 8 insertions(+) |
| 187 | + |
| 188 | +diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h |
| 189 | +index 641d81f..6f40629 100644 |
| 190 | +--- a/lib/dns/include/dns/types.h |
| 191 | ++++ b/lib/dns/include/dns/types.h |
| 192 | +@@ -356,6 +356,7 @@ enum { |
| 193 | + ((x) == dns_trust_additional || (x) == dns_trust_pending_additional) |
| 194 | + #define DNS_TRUST_GLUE(x) ((x) == dns_trust_glue) |
| 195 | + #define DNS_TRUST_ANSWER(x) ((x) == dns_trust_answer) |
| 196 | ++#define DNS_TRUST_SECURE(x) ((x) >= dns_trust_secure) |
| 197 | + |
| 198 | + /*% |
| 199 | + * Name checking severities. |
| 200 | +diff --git a/lib/dns/validator.c b/lib/dns/validator.c |
| 201 | +index 082db33..29585aa 100644 |
| 202 | +--- a/lib/dns/validator.c |
| 203 | ++++ b/lib/dns/validator.c |
| 204 | +@@ -1508,6 +1508,13 @@ verify(dns_validator_t *val, dst_key_t *key, dns_rdata_t *rdata, |
| 205 | + bool ignore = false; |
| 206 | + dns_name_t *wild; |
| 207 | + |
| 208 | ++ if (DNS_TRUST_SECURE(val->event->rdataset->trust)) { |
| 209 | ++ /* |
| 210 | ++ * This RRset was already verified before. |
| 211 | ++ */ |
| 212 | ++ return ISC_R_SUCCESS; |
| 213 | ++ } |
| 214 | ++ |
| 215 | + val->attributes |= VALATTR_TRIEDVERIFY; |
| 216 | + wild = dns_fixedname_initname(&fixed); |
| 217 | + again: |
| 218 | +-- |
| 219 | +2.45.4 |
| 220 | + |
| 221 | + |
| 222 | +From 447417e1964cfe78e6889b314a1507643c7fc326 Mon Sep 17 00:00:00 2001 |
| 223 | +From: Matthijs Mekking <matthijs@isc.org> |
| 224 | +Date: Tue, 3 Mar 2026 11:43:23 +0100 |
| 225 | +Subject: [PATCH 3/3] Check RRset trust in validate_neg_rrset() |
| 226 | + |
| 227 | +In many places we only create a validator if the RRset has too low |
| 228 | +trust (the RRset is pending validation, or could not be validated |
| 229 | +before). This check was missing prior to validating negative response |
| 230 | +data. |
| 231 | + |
| 232 | +(cherry picked from commit 6ca67f65cd685cf8699540a852c1e3775bd48d64) |
| 233 | +Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> |
| 234 | +Upstream-reference: https://raw.githubusercontent.com/Kanishk-Bansal/CVE-Patches/refs/heads/main/CVE-2026-1519.patch |
| 235 | +--- |
| 236 | + lib/dns/validator.c | 17 +++++++++++++---- |
| 237 | + 1 file changed, 13 insertions(+), 4 deletions(-) |
| 238 | + |
| 239 | +diff --git a/lib/dns/validator.c b/lib/dns/validator.c |
| 240 | +index 29585aa..c758384 100644 |
| 241 | +--- a/lib/dns/validator.c |
| 242 | ++++ b/lib/dns/validator.c |
| 243 | +@@ -2439,6 +2439,17 @@ validate_neg_rrset(dns_validator_t *val, dns_name_t *name, |
| 244 | + } |
| 245 | + } |
| 246 | + |
| 247 | ++ if (rdataset->type != dns_rdatatype_nsec && |
| 248 | ++ DNS_TRUST_SECURE(rdataset->trust)) |
| 249 | ++ { |
| 250 | ++ /* |
| 251 | ++ * The negative response data is already verified. |
| 252 | ++ * We skip NSEC records, because they require special |
| 253 | ++ * processing in validator_callback_nsec(). |
| 254 | ++ */ |
| 255 | ++ return DNS_R_CONTINUE; |
| 256 | ++ } |
| 257 | ++ |
| 258 | + val->currentset = rdataset; |
| 259 | + result = create_validator(val, name, rdataset->type, rdataset, |
| 260 | + sigrdataset, validator_callback_nsec, |
| 261 | +@@ -2549,11 +2560,9 @@ validate_ncache(dns_validator_t *val, bool resume) { |
| 262 | + } |
| 263 | + |
| 264 | + result = validate_neg_rrset(val, name, rdataset, sigrdataset); |
| 265 | +- if (result == DNS_R_CONTINUE) { |
| 266 | +- continue; |
| 267 | ++ if (result != DNS_R_CONTINUE) { |
| 268 | ++ return (result); |
| 269 | + } |
| 270 | +- |
| 271 | +- return (result); |
| 272 | + } |
| 273 | + if (result == ISC_R_NOMORE) { |
| 274 | + result = ISC_R_SUCCESS; |
| 275 | +-- |
| 276 | +2.45.4 |
| 277 | + |
0 commit comments