Skip to content

Fix pkcs12 parse issue#10172

Open
embhorn wants to merge 5 commits intowolfSSL:masterfrom
embhorn:zd21568
Open

Fix pkcs12 parse issue#10172
embhorn wants to merge 5 commits intowolfSSL:masterfrom
embhorn:zd21568

Conversation

@embhorn
Copy link
Copy Markdown
Member

@embhorn embhorn commented Apr 8, 2026

Description

When an ENCRYPTED_DATA ContentInfo is decrypted, the code allocates a heap buffer, calls DecryptContent() to decrypt in-place, then reassigns the data pointer to the decrypted buffer. However, all subsequent ASN.1 parsing operations continue using ci->dataSz (the original, larger ContentInfo size) as the bounds parameter, instead of the actual decrypted content size returned by DecryptContent().

Fixes zd21568

Testing

Added test_wc_PKCS12_encrypted_content_bounds

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@embhorn embhorn self-assigned this Apr 8, 2026
Copilot AI review requested due to automatic review settings April 8, 2026 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes an out-of-bounds read risk in PKCS#12 parsing when processing ENCRYPTED_DATA by ensuring subsequent ASN.1 parsing uses the decrypted payload size (not the original ContentInfo size), and adds a regression test case.

Changes:

  • Track decrypted content bounds via a new contentSz value and use it for subsequent ASN.1 parsing operations.
  • Preserve existing behavior for the DATA ContentInfo branch by continuing to use ci->dataSz.
  • Add a new API test covering the encrypted-content parsing path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
wolfcrypt/src/pkcs12.c Introduces contentSz and switches ASN.1 parsing bounds to ensure decrypted content is parsed within correct limits.
tests/api/test_pkcs12.h Registers the new PKCS#12 encrypted-content bounds test in the API test list.
tests/api/test_pkcs12.c Adds a new test that creates, serializes, re-parses, and parses a PKCS#12 with encrypted content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings April 9, 2026 15:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@embhorn
Copy link
Copy Markdown
Member Author

embhorn commented Apr 10, 2026

Jenkins retest this please

@embhorn embhorn assigned wolfSSL-Bot and unassigned embhorn Apr 10, 2026
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.

3 participants