Skip to content

fix(elf): reject reserved direct section counts - #10149

Closed
wunianze666-netizen wants to merge 2 commits into
morluto:mainfrom
wunianze666-netizen:codex/elf-reserved-direct-section-count
Closed

wunianze666-netizen wants to merge 2 commits into
morluto:mainfrom
wunianze666-netizen:codex/elf-reserved-direct-section-count

Conversation

@wunianze666-netizen

@wunianze666-netizen wunianze666-netizen commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reject reserved direct ELF section counts before reading section headers.

Problem and expected behavior

An ELF64 object declared 0xff00 directly in e_shnum, backed the declared table with bytes, and produced complete inspect-elf-notes and inspect_elf_notes Evidence. The ELF header contract uses zero in e_shnum and places the actual count in section zero when the count reaches 0xff00. This case came from inspecting the shared declaration reader. ELF gABI header fields

Change and scope

Validate the raw direct count in the shared section table admission used by native directory and note readers. The guard runs before either reader interprets table rows. Legal direct counts and the existing extended-numbering outcomes are covered by the controls. Related table bounds repair

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

  • Semantic owner and earliest changed stage: shared ELF section table field admission checks the raw e_shnum value.
  • Contribution scope fit and linked maintainer decision: ordinary offline format correction within existing inspection.
  • CLI and MCP/tool-catalog contract: malformed direct counts use the existing input-format refusal.
  • Provider, bridge, target-format, or platform compatibility: synthetic ELF64 on Windows Node 24.22.1.
  • Evidence, artifact, provenance, or reconstruction contract: the refusal retains the snapshot hash, path, and byte length. The maximum legal direct count produces the same complete report on both revisions.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the caller-selected ELF object uses the existing passive file workflow.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): existing error schemas and tool metadata.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: the note parser and native section directory reject the reserved count in an otherwise backed table. The existing file admission controls still admit legal extended numbering.
  • Base reproduction or other evidence: clean 047d75a4 accepted the 4,178,432-byte reserved-count fixture on both compiled surfaces. The candidate refused the same path and digest. The highest legal direct count and valid extended-encoding controls matched their baseline outcomes.
  • User-visible CLI/MCP output (if applicable): the malformed fixture now exits 1 with invalid_request and category invalid_input. The named SDK call returns the same typed refusal with snapshot evidence.
  • Remaining proof gaps: passive synthetic ELF inputs on Windows. Live targets and external engines are separate workflows.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • Two new reader cases failed on clean accepted main and passed on the candidate. The other 69 cases were excluded by name in those selected runs.
  • Focused ELF note, native directory, file admission, and MCP suites reported 107 passed | 1 skipped (108).
  • Three compiled CLI and three same-connection named SDK cases per revision. The tool definition, JSON Schema 2020-12 meta-schemas, actual payload validation, snapshot hashes, and client cleanup were checked.
  • CI-fast static checks, architecture guards, and diff checks passed.

CI fixture follow-up

The Source job found one initializer test fixture with 65,535 sections encoded directly in e_shnum. The fixture now uses the ELF extended encoding, with zero in e_shnum and the count in section zero's sh_size. Its table size, full initializer slot budget, time assertion, and result assertions are retained. Original Source job

On Windows Node 24.22.1, the selected case reproduced the CI failure and passed after the fixture correction. The full initializer parser file passed all 107 tests. This revision changes the initializer test fixture.

Compatibility, safety, and release

  • Breaking changes or migration steps: a reserved direct count is refused as malformed input.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows Node 24.22.1 and passive synthetic ELF.
  • Package or release metadata impact: existing ELF reader behavior and guide.
  • Security, privacy, process, or containment review: existing bounded file reads and admission.

Author readiness

Human owner: @wunianze666-netizen

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T01:41:06.413294Z cdf0bc9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto

morluto commented Nov 19, 2026

Copy link
Copy Markdown
Owner

The current-base replacement is #12193. It rejects reserved direct ELF section counts at the shared declaration boundary and includes the Dart, Deno, and Node SEA follow-up from #12196. The combined head is validated and queued for squash merge. Thanks for the original report and controls.

@morluto morluto closed this Nov 19, 2026
morluto added a commit that referenced this pull request Nov 19, 2026
* fix(elf): reject invalid section table and zlib declarations

Refs #10149, #10148, #9330.

Co-authored-by: Nianze Wu <[email protected]>

* fix(elf): share section count admission with carrier readers (#12196)

fix(elf): admit section tables before carrier recognition

---------

Co-authored-by: Nianze Wu <[email protected]>
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants