Skip to content

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

Merged
dgarske merged 1 commit into
wolfSSL:masterfrom
tmael:fix-rsa-unpad-oob-515
Jun 3, 2026
Merged

Fix heap out-of-bounds read in TPM2_ASN_RsaUnpadPkcsv15#516
dgarske merged 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.
@dgarske dgarske merged commit 4f9d85c into wolfSSL:master Jun 3, 2026
141 checks passed
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

2 participants