Fix bugs in libhoth_extract_ot_bundle#209
Open
sandumjacob wants to merge 1 commit intogoogle:mainfrom
Open
Conversation
Contributor
sandumjacob
commented
Feb 13, 2026
- Fix integer overflow, buffer overread in libhoth_extract_ot_bundle
- Add regression tests.
259b59d to
cf295be
Compare
cf295be to
cc50b3c
Compare
xorptr
approved these changes
Feb 24, 2026
|
|
||
| // Checks that the image offset doesn't cause | ||
| // the offset calculations to read beyond the image buffer. | ||
| if ((offset + OPENTITAN_OFFSET_APP_FW + OPENTITAN_OFFSET_VERSION_MINOR + 4) > |
Collaborator
There was a problem hiding this comment.
My understanding is that this check relies on 2 implicit conditions for correctness (which hold true currently):
(OPENTITAN_OFFSET_HEADER_DATA + 4) <= image_size, so thatoffsetcan be read properly. This is currently true sinceOPENTITAN_OFFSET_HEADER_DATA < OPENTITAN_OFFSET_APP_FWandimage_size >= smallest_fwOPENTITAN_OFFSET_VERSION_MINOR>OPENTITAN_OFFSET_VERSION_MAJORso that ROM_EXT and APP version can be read properly.
Would it be a good idea to check these conditions explicitly (using static_assert or in some other manner)?
| // the offset calculations to read beyond the image buffer. | ||
| if ((offset + OPENTITAN_OFFSET_APP_FW + OPENTITAN_OFFSET_VERSION_MINOR + 4) > | ||
| image_size) { | ||
| fprintf(stderr, "Image offset is invalid"); |
Collaborator
There was a problem hiding this comment.
nit: Would it be a good idea to print offset in the error messages?
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.