Fix GetObjectId bounds in PKCS12 ContentInfo parsing#10233
Open
TristanInSec wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix GetObjectId bounds in PKCS12 ContentInfo parsing#10233TristanInSec wants to merge 1 commit intowolfSSL:masterfrom
TristanInSec 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? |
Contributor
|
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. |
Member
|
@dgarske , have a look at ZD 21641 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)