Skip to content

Fix heap out-of-bounds read in TPM2_ASN_RsaUnpadPkcsv15#516

Open
tmael wants to merge 1 commit into
wolfSSL:masterfrom
tmael:fix-rsa-unpad-oob-515
Open

Fix heap out-of-bounds read in TPM2_ASN_RsaUnpadPkcsv15#516
tmael wants to merge 1 commit into
wolfSSL:masterfrom
tmael:fix-rsa-unpad-oob-515

Conversation

@tmael
Copy link
Copy Markdown
Contributor

@tmael tmael commented Jun 1, 2026

Add a bounds check (idx < *sigSz) before dereferencing the separator byte. Fixes #515.

When a PKCS#1 v1.5 padded buffer consists entirely of 0xFF padding
bytes after the 0x00 0x01 header, with no 0x00 separator, the padding
scan loop exits with idx == *sigSz. The subsequent separator check then
dereferenced sig[*sigSz], reading one byte past the end of the buffer.
A 3-byte input of 00 01 FF triggers the over-read.

Add a bounds check (idx < *sigSz) before dereferencing the separator
byte. Fixes wolfSSL#515.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Heap OOB read in TPM2_ASN_RsaUnpadPkcsv15

1 participant