mirror of
https://github.com/openssl/openssl.git
synced 2026-10-28 16:36:02 +08:00
tls_construct_ctos_psk() reserved the resumption binder with WPACKET_sub_allocate_bytes_u8() and kept the returned pointer. Reserving the external PSK binder afterwards can grow the packet and relocate its backing buffer, leaving the resumption binder pointer dangling. tls_psk_do_binder() then wrote the binder into freed memory. Record the binder end offsets instead and convert them to pointers only after both binders and their enclosing lengths have been allocated. Add test_psk_binder_growth to sslapitest for SHA-256 and SHA-384. It offers both a resumption ticket and an external PSK, sizes the packet so the first binder ends exactly at the buffer end, and uses a secure BUF_MEM so growth always relocates. Both binders are then verified. Without the fix, ASan reports a heap-use-after-free. Fixes:9368f86526"Add TLSv1.3 client side external PSK support" Assisted-by: pi:GLM-5.3-Flash-EXL3 Assisted-by: OpenAI:gpt-6.1-sol Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.foundation> Reviewed-by: Bob Beck <beck@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> Merge-date: Tue Oct 27 17:55:26 2026 Merged-from: https://github.com/openssl/openssl/pull/33293 (cherry picked from commit88db43c5a9)