Skip to content

fix(elf): reject unmatched NT_FILE pathnames - #10138

Merged
morluto merged 5 commits into
morluto:mainfrom
wunianze666-netizen:codex/elf-nt-file-path-coverage
Nov 11, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
wunianze666-netizen:codex/elf-nt-file-path-coverage

Conversation

@wunianze666-netizen

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

Copy link
Copy Markdown
Contributor

Summary

Leave NT_FILE mappings unknown when the descriptor contains unmatched pathname bytes. Retain the raw note identity, location, and hash.

Problem and expected behavior

A synthetic ELF core note declares one mapping but appends a second pathname after the one it names. Both inspect-elf-notes and inspect_elf_notes reported the first row as decoded and ignored the unmatched bytes. The Linux writer emits one filename per mapping and sizes the descriptor to those filenames. This case came from direct inspection of the passive decoder. Linux NT_FILE producer

Change and scope

Check the suffix after the declared filenames during the existing descriptor scan. Nonzero bytes leave core null. The scan result is reused when program and section tables reference the same descriptor. A zero-filled suffix remains accepted for compatibility, consistent with the existing core mapping authority check.

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: the passive ELF note parser validates the full pathname area before projecting core.file.
  • Contribution scope fit and linked maintainer decision: ordinary correction in existing read-only decoding.
  • CLI and MCP/tool-catalog contract: inspect-elf-notes and inspect_elf_notes use the existing nullable core field.
  • Provider, bridge, target-format, or platform compatibility: ELF32 and ELF64 note fixtures cover big- and little-endian inputs.
  • Evidence, artifact, provenance, or reconstruction contract: the raw descriptor range and hash, note identity, and table-examination coverage are retained. An incomplete semantic decode leaves core null.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): a selected ELF file is read through the existing passive tool path.
  • 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): the decoder uses the existing schema and 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: ELF32 big-endian and ELF64 little-endian regressions cover the exact pathname list, zero suffix, and surplus pathname. A shared descriptor in PT_NOTE and SHT_NOTE retains both entries with the same hash and coverage.
  • Base reproduction or other evidence: on clean 0909d89c, both new parser cases failed because the surplus pathname produced a decoded mapping. The same 208-byte synthetic file through the compiled CLI and MCP returned one row. With the fix, both return core: null for that file and retain its descriptor. The exact, zero-suffix, and unterminated controls produced equal normalized reports across revisions.
  • User-visible CLI/MCP output (if applicable): type_name: "core_file", core: null and a 68-byte descriptor whose SHA-256 is f89ae466300c0f8f3c2f0d4e361538e90c24b2c56dcc7aeef0a01ef05f0f1a2d.
  • Remaining proof gaps: Windows Node 24.22.1 and synthetic passive ELF inputs. The Windows host refused the filesystem test's symlink setup with EPERM before the test called REA. Live Linux core and debugger validation remain separate.

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

Current head 8bc15fe4d237bc5e113d5a51c957d1797b61ab52 merges accepted main with a normal merge commit. The diff against that base retains this PR's 3-file patch.

  • Local focused run: 75 passed | 1 skipped (76). Build: 3 successful, 3 total, 1 cached, 3 total. Four actual CLI and four same-connection named SDK cases passed, including the surplus-path descriptor and three byte-identical controls. The earlier Windows symlink fixture reached EPERM before calling REA. The current focused run selected the parser and MCP suites.
  • CI-fast typecheck, lint and format, architecture guards, and diff checks passed. Normal fork push and upstream head readback passed.
  • Accepted main repaired earlier Source and package-verifier failures. Its Linux x64 package job passed. The accepted main run still reports separate Process CLI cleanup assertions and Electron/Kuna deadlines. Accepted main CI
Previous revision and validation evidence
  • Frozen base parser run with the new regressions reported 2 failures, 66 passes, and 1 existing host-ELF skip. The candidate parser and MCP suites passed 76 tests with that same skip. The third suite stopped at its Windows symlink fixture setup, for a total of 1 failure, 76 passes and 1 skip.
  • Actual compiled CLI and same-connection MCP SDK ran four cases per revision. The named tool definition, JSON Schema 2020-12 meta-schemas, actual input and output, typed Evidence, descriptor digest, and SDK cleanup checks passed.
  • npm run check:ci:fast:tasks, architecture guards, npm run docs:check, and git diff --check passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: callers already handle nullable core on undecoded notes.
  • Real Hopper/Ghidra, browser, or OS coverage: local Windows Node 24.22.1, offline ELF note reads.
  • Package or release metadata impact: a parser behavior fix and documentation update.
  • Security, privacy, process, or containment review: the fixture paths are evidence strings in a passive file read.

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.

Maintainer integration validation

Integrated main 6b2f9918088c02ea00efc417051362f260d1cee2, including the CI lifecycle repair. Feature diff unchanged; current head e54b65f3a646f46e69e95f98b1f2b653a0950722. Combined validation of #10138, #10085 and #10044 on this main: 222 passed, 1 host-ELF skip across 15 parser/service/filesystem/CLI/MCP suites; typecheck and lint passed. The CI repair separately passed 373 tests with 3 host-specific skips. Local macOS Node 24.22.1; fresh hosted CI pending. No Windows loader verification is claimed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T23:45:04.982043Z e54b65f New commits
ℹ️ 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 merged commit fadfdf1 into morluto:main Nov 11, 2026
4 of 7 checks passed
@morluto morluto mentioned this pull request Nov 12, 2026
3 tasks done
@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