Skip to content

Coverity fixes Harden TPM bounds and configuration paths - #591

Open
aidangarske wants to merge 1 commit into
wolfSSL:masterfrom
aidangarske:coverity-outstanding-issues-6
Open

Coverity fixes Harden TPM bounds and configuration paths#591
aidangarske wants to merge 1 commit into
wolfSSL:masterfrom
aidangarske:coverity-outstanding-issues-6

Conversation

@aidangarske

Copy link
Copy Markdown
Member
  • 911493
  • 912593
  • 913183
  • 913184
  • 913340
  • 913341

@aidangarske
aidangarske requested a review from dgarske September 7, 2026 18:00
Copilot AI lite review requested due to automatic review settings September 7, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

wolfTPM2_ST33_GetFwUpgradeCommands now dereferences caps unconditionally and forces haveFwVer=1, violating its documented/covered caps == NULL contract and risking a NULL-pointer crash.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR appears to address multiple Coverity findings by tightening bounds checks in TPM wrapper code paths, hardening packet/response boundary handling, and adjusting configuration/locking behavior in the core TPM2 context cleanup.

Changes:

  • Add/strengthen bounds validation to prevent out-of-range writes and inconsistent session mutation (e.g., wolfTPM2_SetAuthHandle, wolfTPM2_PolicyPCRMake) and add unit tests for these edge cases.
  • Refine cleanup-time locking behavior in TPM2_Cleanup to avoid acquiring/releasing an uninitialized mutex depending on build configuration.
  • Adjust firmware TPM crypto/curve selection logic to reject unsupported ECC curves at compile-time thresholds.
File summaries
File Description
tests/unit_tests.c Adds coverage for wolfTPM2_SetAuthHandle policy-auth offset bounds and non-mutation on failure.
tests/fwtpm_unit_tests.c Tightens PCR properties capability parsing boundary checks in test code.
src/tpm2.c Introduces TPM2_DYNAMIC_HW_LOCK path to conditionally acquire/release the global HW lock during cleanup.
src/tpm2_wrap.c Hardens bounds checks in wolfTPM2_SetAuthHandle and wolfTPM2_PolicyPCRMake; modifies ST33 FW upgrade command selection path.
src/fwtpm/fwtpm_crypto.c Updates ECC curve mapping to reject curves below ECC_MIN_KEY_SZ using preprocessor checks.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/tpm2_wrap.c
@aidangarske
aidangarske marked this pull request as ready for review September 7, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants