Skip to content

Fix pkcs12 parse issue#10172

Merged
SparkiDev merged 2 commits intowolfSSL:masterfrom
embhorn:zd21568
Apr 14, 2026
Merged

Fix pkcs12 parse issue#10172
SparkiDev merged 2 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
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10172

Scan targets checked: wolfcrypt-api_misuse, wolfcrypt-bugs, wolfcrypt-compliance, wolfcrypt-concurrency, wolfcrypt-consttime, wolfcrypt-defaults, wolfcrypt-mutation, wolfcrypt-portability, wolfcrypt-proptest, wolfcrypt-src, wolfcrypt-zeroize

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

@SparkiDev SparkiDev assigned embhorn and unassigned wolfSSL-Bot Apr 12, 2026
Copilot AI review requested due to automatic review settings April 13, 2026 20:14
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 3 comments.


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

Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10172

Scan targets checked: wolfcrypt-api_misuse, wolfcrypt-bugs, wolfcrypt-compliance, wolfcrypt-concurrency, wolfcrypt-consttime, wolfcrypt-defaults, wolfcrypt-mutation, wolfcrypt-portability, wolfcrypt-proptest, wolfcrypt-src, wolfcrypt-zeroize

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10172

Scan targets checked: wolfcrypt-api_misuse, wolfcrypt-bugs, wolfcrypt-compliance, wolfcrypt-concurrency, wolfcrypt-consttime, wolfcrypt-defaults, wolfcrypt-mutation, wolfcrypt-portability, wolfcrypt-proptest, wolfcrypt-src, wolfcrypt-zeroize

No new issues found in the changed files. ✅

@SparkiDev SparkiDev merged commit 409b5fc into wolfSSL:master Apr 14, 2026
409 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.

5 participants