Repository navigation
fix(elf): reject tables inside the declared ELF header - #10133
Merged
morluto merged 1 commit intoNov 11, 2026
Merged
Conversation
Admission compared table offsets with the class minimum, so a larger e_ehsize still parsed those header bytes as program or section entries. Co-authored-by: Cursor <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
12 of 22 tasks
3 tasks done
5 tasks
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
ELF admission treated only the class minimum (52 or 64 bytes) as the header. A larger
e_ehsizestill let the program or section table start inside that declared header, so those header bytes were parsed as table entries. Notes already rejected the same overlap. No open issue matches this.Problem and expected behavior
Smallest trigger: ELF64 with
e_ehsize80 ande_phoff64 (or ELF32 withe_ehsize64 ande_phoff52), and a nonzero table count. gABI sayse_ehsizeis the header's size in bytes ande_phoff/e_shoffare the tables' file offsets, so a table must not start beforee_ehsize.Previously
parseBinaryTargetadmitted that file. It now returnsfile_format_rejectedwithELF program header table overlaps the fixed headeror the section equivalent. A declared header that ends at or before the table offset is still admitted. Tables with a zero count are unchanged.Change and scope
tableFailurecompares the table offset with the admittedheader.headerSize(e_ehsize) instead of the class minimum.readElfFixedHeaderalready requires that size to be at least the class minimum and no larger than the file. The same check already exists for note tables inElfNoteParser.Not included: note-owner byte matching, compressed section-name alignment, and any change to PE or Mach-O.
Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
validateElfDeclaredRanges/readElfTableDeclarationsinsrc/domain/elfDeclaredRanges.ts. Native section, hardening, export, initializer, and kernel-module readers consume this admission. Note parsing already usedheader.headerSize. No path was removed.file_format_rejectedreason string is reused. No tool schema change.e_ehsizeis unchanged. Images whose tables start inside a larger declared header are now rejected.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
tests/boundary/filesystem/elfDeclaredRanges.test.tscovers ELF32/ELF64 and both endiannesses. A program table insidee_ehsize, a section table insidee_ehsize(program count 0), and an extended header whose section table starts aftere_ehsizeare all asserted.0909d89c966c30955fd0906b622ff25f3700789f. Withsrc/domain/elfDeclaredRanges.tsstashed, the new cases received{ ok: true }instead of the overlap rejection (4 failed, 15 existing tests passed). With the fix restored, the same file passed 19/19.parseBinaryTarget, which is what the regression calls. The reason text is the existing overlap sentence.e_ehsizelarger than the class minimum was available.npm run test:focuseddoes not reach Vitest on this machine (see validation).Format-assumption boundary regression: the malformed overlap is paired with an extended header whose table starts after
e_ehsize, and existing truncation cases in the same file still pass. Lifecycle regressions: not applicable; no process, file ownership, or cleanup change.For evidence-bearing changes:
Validation performed
git stash push -- src/domain/elfDeclaredRanges.tsthennode scripts/run-exact-tests.mjs run tests/boundary/filesystem/elfDeclaredRanges.test.ts— exit 1. 4 failed, 15 passed. Each new case failed withexpected { ok: false, ... overlaps the fixed header } received { ok: true }.git stash popthen the same Vitest command — exit 0. 19 passed.npm run test:focused -- tests/boundary/filesystem/elfDeclaredRanges.test.ts— exit 1 before Vitest.metadata:checkthrowsThe property 'options.mode' must be one of: 'strip'. Received 'transform'under Node.js v26.12.1. This happened with the production change stashed and does not depend on the diff. The command above is the Vitest step that focused mode runs after that prerequisite.npx oxfmt src/domain/elfDeclaredRanges.ts tests/boundary/filesystem/elfDeclaredRanges.test.ts— exit 0. No further diff.npm run check:fast— exit 0. typecheck and lint, 2 successful. About 2m17s.gh search prs --repo morluto/rea "e_ehsize OR ehsize OR \"overlaps the fixed header\" OR \"declared ELF header\""— no matches. Dedup TSVs had no matching open PR, open issue, or recent merge.Compatibility, safety, and release
e_ehsizewas previously admitted and is nowfile_format_rejected. That file was already rejected by ELF note admission.Author readiness
Human owner: @rudycelekli
Before merge
type(scope): outcome.Prepared with AI assistance. Human ownership declarations remain pending.