Skip to content

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Jul 17, 2025

Fix possible buffer overrun issues. Specifically issues with exporting RSA keys where the wolfCrypt max key size doesn't match what TPM supports in wolfTPM2_RsaKey_TpmToWolf. ZD 20237.

Fix checks around TPM2_GetHashDigestSize.
Fix for HASH_COUNT (make sure its at least 2 by default).
Fix for TPM2_GetWolfRng to ensure NULL is set on RNG init error.
Fix some of the configurable limit defaults.

Implement an address sanitizer test.

…g RSA keys where the wolfCrypt max key size doesn't match what TPM supports. ZD 20237.
@dgarske dgarske self-assigned this Jul 17, 2025
@dgarske dgarske requested a review from embhorn July 17, 2025 14:25
@dgarske dgarske assigned wolfSSL-Bot and embhorn and unassigned dgarske Jul 17, 2025
@dgarske dgarske requested a review from Copilot July 18, 2025 14:59
Copy link

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

This PR addresses buffer overrun vulnerabilities in the wolfTPM library by adding comprehensive bounds checking and buffer size validation throughout the codebase. The changes focus on preventing buffer overruns in RSA key operations, hash digest size validation, and various authentication and data copying functions.

Key changes include:

  • Added bounds checking for all buffer copy operations with truncation where appropriate
  • Fixed hash digest size validation to ensure positive values and proper buffer bounds
  • Enhanced RSA and ECC key conversion functions to validate buffer sizes before copying
  • Implemented address sanitizer testing in CI to catch memory safety issues

Reviewed Changes

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

Show a summary per file
File Description
wolftpm/tpm2_types.h Updated configurable limits, added XMEMMOVE macro, and enhanced HASH_COUNT validation
tests/unit_tests.c Replaced XMEMCPY with XMEMMOVE for overlapping memory operations
src/tpm2_wrap.c Added comprehensive buffer bounds checking across authentication, key operations, and data copying functions
src/tpm2.c Fixed NULL pointer assignment on RNG initialization failure
.github/workflows/make-test-swtpm.yml Added address sanitizer testing configuration

…exceed 80). Fix for missing brace with `WOLFTPM_USE_SYMMETRIC` and added test for it.
@dgarske dgarske requested a review from embhorn July 18, 2025 16:04
…KEY_BYTES` uses (times 2). Fix LABEL_MAX_BUFFER. Add better defaults for SLB9672/SLB9673.
@embhorn embhorn merged commit 2ce5bbc into wolfSSL:master Jul 18, 2025
4 checks passed
dgarske added a commit to dgarske/wolfTPM that referenced this pull request Dec 1, 2025
… 2 chars. Added test to catch this and made sure there are no others. Bug introduced in PR wolfSSL#427 and release v3.9.2.
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