Reject zero-length Airoha TLV to avoid extraction hang - #1601
Open
bunlongheng wants to merge 1 commit into
Open
Conversation
qkaiser
reviewed
Aug 10, 2026
Comment on lines
+77
to
+78
| if file.tell() >= file.size(): | ||
| raise InvalidInputFormat("Airoha MOVER_INFO TLV not found") |
Contributor
There was a problem hiding this comment.
dissect.cstruct parsing after this line will raise EOFError when the file is fully consumed. Your conditional on tlv_length is sufficient, you can remove this one.
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.
While reading the Airoha handler I noticed _read_sections can spin forever. It walks the TLV list looking for MOVER_INFO, and each iteration does file.seek(tlv.tlv_length, SEEK_CUR) before parsing the next TLV. If a crafted image has a TLV whose length is 0 and it isn't MOVER_INFO, the seek advances nothing, the same 4 bytes get parsed again, and the loop never terminates, so unblob just hangs on that input with no timeout.
I added a guard that bails out with InvalidInputFormat when a TLV reports zero length, plus a stop once the walk runs off the end of the file before finding MOVER_INFO. Valid images are unaffected since their TLVs advance normally.