-
Notifications
You must be signed in to change notification settings - Fork 73
Fix possible buffer overrun issues #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…g RSA keys where the wolfCrypt max key size doesn't match what TPM supports. ZD 20237.
…M2_GetWolfRng` to ensure NULL is set on RNG init error.
There was a problem hiding this 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.
…KEY_BYTES` uses (times 2). Fix LABEL_MAX_BUFFER. Add better defaults for SLB9672/SLB9673.
… 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.
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_GetWolfRngto ensure NULL is set on RNG init error.Fix some of the configurable limit defaults.
Implement an address sanitizer test.