[Git][NTPsec/ntpsec][master] ntpd/nts_cookie.c: reject cookies shorter than AD_LENGTH
Matt Selsky (@selsky)
gitlab at mg.gitlab.com
Tue Oct 6 01:41:07 UTC 2026
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
873fbdd9 by Matt Selsky at 2026-10-06T01:32:46+00:00
ntpd/nts_cookie.c: reject cookies shorter than AD_LENGTH
cookielen comes from the wire (the NTS_Cookie extension length) and was only
checked against NTS_MAX_COOKIELEN. A cookie shorter than AD_LENGTH (20: key ID
+ nonce) reaches:
- memcmp(finger, &key->I, sizeof(key->I)), which reads past the declared cookie
length.
- cipherlength = cookielen - AD_LENGTH, which goes negative and is passed to
AES_SIV_Decrypt() as a size_t.
AES_SIV_Decrypt() rejects the wrapped length before dereferencing anything, so
this is not exploitable, but we want the check if/when we remove libaes_siv.
- - - - -
1 changed file:
- ntpd/nts_cookie.c
Changes:
=====================================
ntpd/nts_cookie.c
=====================================
@@ -381,6 +381,8 @@ bool nts_unpack_cookie(uint8_t *cookie, int cookielen,
// We may get garbage from the net
if (cookielen > NTS_MAX_COOKIELEN)
return false;
+ if (cookielen < AD_LENGTH)
+ return false;
finger = cookie;
key = NULL; // squash uninitialized warning
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/873fbdd9f84c03088f2c25b256fc9c5ab8ab9d55
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/873fbdd9f84c03088f2c25b256fc9c5ab8ab9d55
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20261006/0bfa6bf0/attachment-0001.htm>
More information about the vc
mailing list