mbedtls/ChangeLog.d/ssl-cookie-write-bounds.txt
Naveed 258bbbbdb0 Fix out-of-bounds write in mbedtls_ssl_cookie_write
mbedtls_ssl_cookie_write() only reserves COOKIE_HMAC_LEN bytes for the
MAC after the timestamp, but passed COOKIE_MD_OUTLEN as the output size
to psa_mac_sign_finish(). PSA fills the unused part of the declared
output buffer, so up to 4 bytes (20 with SHA-384) past the end of the
caller's buffer were overwritten when it had less than that to spare.

Pass the size that was actually reserved and add a regression test.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-16 19:28:28 +05:30

7 lines
335 B
Plaintext

Bugfix
* Fix mbedtls_ssl_cookie_write() writing up to 20 bytes past the end of
the output buffer when less than 36 bytes (or 52 bytes when the cookie
uses SHA-384) were available. The library's own callers always leave
enough room, so only applications that call it directly with a smaller
buffer were affected.