Repository navigation
Conversation
…r-controlled ELF header fields and overflows the stack Signed-off-by: zhang hongyuan <100520587+Metastarx@users.noreply.github.com>
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.
Summary
Running a bundle executes the packaged uab-header, which parses the ELF trailer of the running file itself, so every field of that ELF header is controlled by whoever produced the bundle. getSectionHeader() trusted e_shentsize and sh_name directly: it read e_shentsize bytes into a fixed SectionHeader on the stack, so a value larger than the struct overflowed it, and it built a string_view from an unchecked sh_name, so an offset outside the section-name string table scanned memory past the buffer. The section header table bounds were not validated either. The fix requires e_shentsize to match sizeof(SectionHeader), checks that e_shoff plus e_shnum entries lie inside the file, always reads exactly one SectionHeader, and resolves sh_name through a lookup that validates the offset and requires a NUL terminator, skipping malformed entries instead of dereferencing them.
Verification
ctest --test-dir build-release --output-on-failure- passed (100% tests passed, 0 tests failed out of 751)Checklist