Fix GetObjectId bounds in PKCS12 ContentInfo parsing#10233
Fix GetObjectId bounds in PKCS12 ContentInfo parsing#10233TristanInSec wants to merge 1 commit intowolfSSL:masterfrom
Conversation
Bound GetObjectId() by the ContentInfo SEQUENCE end (curIdx + curSz) instead of the full buffer size. This prevents the OID TLV from being parsed past the SEQUENCE boundary in the first place, complementing the post-check added in PR wolfSSL#10018. Previously, GetObjectId received (word32)size as maxIdx, allowing it to read OID data beyond the ContentInfo SEQUENCE. The post-check then caught this after the fact. With this change, GetObjectId itself rejects an OID that would exceed the SEQUENCE, so the over-read never occurs.
|
Can one of the admins verify this patch? |
|
Hi @TristanInSec , I don’t see you setup as a contributor. Can you tell us more about yourself and your project? If you’d like to start the process for getting on file with a signed contributor agreement please email support at wolfssl dot com. |
|
@dgarske , have a look at ZD 21641 . |
|
Hi @dgarske, I'm an independent security researcher. I identified this bounds issue while reviewing PKCS12 parsing code and wanted to contribute the fix. I'd be happy to sign the contributor agreement. Could you share the process or a link to get started? |
|
Closing in favor of #10378 |
Summary
GetObjectId()by the ContentInfo SEQUENCE end (curIdx + curSz) instead of the full buffer size ((word32)size)Context
PR #10018 added a post-check that catches when
GetObjectId()advanceslocalIdxpast the ContentInfo SEQUENCE boundary. However,GetObjectId()itself still receives the full buffer size asmaxIdx, so it parses the OID TLV beyond the SEQUENCE boundary before the post-check rejects it.This change bounds
GetObjectId()at the source, so it rejects an oversized OID immediately during parsing rather than after the fact. The post-check from #10018 remains as defense-in-depth.Test plan
test_wc_d2i_PKCS12_oid_underflowtest (added in Fix GetSafeContent to check length #10018) covers this pathASN_PARSE_E(now byGetObjectIddirectly, rather than the post-check)