Skip to content

Commit

Permalink
validator: limit the amount of work on SHA1 in NSEC3 proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
vcunat committed Feb 12, 2024
1 parent b5051ac commit 24699e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/dnssec/nsec3.c
Expand Up @@ -146,6 +146,18 @@ static int closest_encloser_match(int *flags, const knot_rrset_t *nsec3,
const knot_dname_t *encloser = knot_wire_next_label(name, NULL);
*skipped = 1;

/* Avoid doing too much work on SHA1, mitigating:
* CVE-2023-50868: NSEC3 closest encloser proof can exhaust CPU
* We log nothing here; it wouldn't be easy from this place
* and huge SNAME should be suspicious on its own.
*/
const int max_labels = knot_dname_labels(nsec3->owner, NULL) - 1
+ kr_nsec3_max_depth(&params);
for (int l = knot_dname_labels(encloser, NULL); l > max_labels; --l) {
encloser = knot_wire_next_label(encloser, NULL);
++(*skipped);
}

while(encloser) {
ret = hash_name(&name_hash, &params, encloser);
if (ret != 0)
Expand Down

0 comments on commit 24699e9

Please sign in to comment.