mirror of
https://github.com/obgm/libcoap.git
synced 2026-10-27 21:22:33 +03:00
coap_oscore_decrypt_pdu() only checked encrypt_len == 0 before computing encrypt_len - tag_len (size_t), so a protected payload shorter than the tag underflowed to a huge value used for plain_pdu->used_size and the AEAD output buffer size. This is reached before the payload is authenticated. Reject a payload that cannot hold the tag plus the inner Code byte up front and handle it like any other decryption failure: a request is answered with 4.00 "Decryption failed" and the replay state is rolled back, so an unauthenticated short request cannot advance the replay window. Also guard the subtraction in cose_encrypt0_decrypt(). Add a regression test for every payload length from one byte through the tag length.