Bound fwTPM child blob sizes before copying from the response - #595
Merged
dgarske merged 1 commit intoSep 10, 2026
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new bounds checks still don’t assert that the response buffer (rspSize) actually contains the claimed blob lengths before reading/copying, which can cause reads past the valid response payload.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens fwTPM unit test parsing of TPM Create responses by adding upper-bound assertions before copying child key blobs, aiming to prevent oversized blob lengths from overflowing the caller-provided buffers.
Changes:
- Added a new
AssertIntLE()helper macro for “less-than-or-equal” integer assertions. - Added bounds checks to ensure
outPrivate.sizeandoutPublic(size-prefix + data) fit into the caller buffers beforememcpy()inCreateChildBlobs().
File summaries
| File | Description |
|---|---|
| tests/fwtpm_unit_tests.c | Adds assertions to bound parsed child blob sizes before copying them out of the TPM response in fwTPM unit tests. |
Review details
Suppressed comments (1)
tests/fwtpm_unit_tests.c:10548
- CreateChildBlobs() reads/copies outPublic using *pubSz from the response, but does not assert the response length (rspSize) covers the size field and the subsequent 2+pubSz bytes. This can read beyond the valid response and copy uninitialized/stale bytes from gRsp into pub.
*pubSz = GetU16BE(gRsp + pos);
AssertIntGT(*pubSz, 0);
AssertIntLE(2 + *pubSz, sizeof(TPM2B_PUBLIC)); /* fits caller's buffer */
memcpy(pub, gRsp + pos, 2 + *pubSz); /* keep the size prefix */
- Files reviewed: 1/1 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.
aidangarske
force-pushed
the
coverity-913517-tainted-child-blobs
branch
from
September 9, 2026 16:30
9e005c9 to
bc33d44
Compare
dgarske
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CID 913517