Skip to content

feat(elf): decode Linux core dump process and memory mapping notes - #8830

Merged
morluto merged 5 commits into
morluto:mainfrom
rishikeshgowdakk:feat/elf-core-notes
Nov 4, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
rishikeshgowdakk:feat/elf-core-notes

Conversation

@rishikeshgowdakk

@rishikeshgowdakk rishikeshgowdakk commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expands inspect_elf_notes / rea inspect-elf-notes to decode Linux CORE dump note tables without executing the target or requiring external debuggers (GDB/LLDB). Parses process metadata (NT_PRPSINFO), memory-mapped file regions (NT_FILE), fault signals (NT_SIGINFO), and auxiliary vectors (NT_AUXV) across 32-bit and 64-bit, little-endian and big-endian targets within strict memory and text budgets.

Problem and expected behavior

Upstream recently expanded inspect_elf_notes to handle big-endian ABI tags (#8803) and validate non-allocated note boundaries. While inspect-elf-notes already accepted ET_CORE object types (e_type === 4), all Linux CORE notes were previously reported as type_name: "unknown" with gnu: null and raw descriptor hashes.

For reverse engineers and agents analyzing crash artifacts, core dumps are among the most valuable native files. Extracting faulting signal codes, mapped libraries/binaries (NT_FILE), process arguments (NT_PRPSINFO), and system capabilities (NT_AUXV) is essential to contextualize crashes before deep disassembly.

With this change:

  • NT_PRPSINFO (type 3): Decodes PID, PPID, PGRP, SID, UID, GID, state, filename, and command line arguments bounded by TextBudget.
  • NT_FILE (type 0x46494c45): Decodes memory mapping table (start_address, end_address, file_offset_pages, path) and page size.
  • NT_SIGINFO (type 0x53494749): Decodes signal number, errno, and fault code.
  • NT_AUXV (type 6): Decodes auxiliary vectors with well-known AT_* symbolic names (AT_PAGESZ, AT_PHDR, AT_ENTRY, etc.).
  • Both 32-bit and 64-bit, little-endian and big-endian targets are supported natively.
  • Non-decoded core notes (such as thread register sets NT_PRSTATUS) and malformed descriptors remain safely unparsed (core: null) without partial success errors or uncaught exceptions.

Change and scope

  • Pure TypeScript binary decoder implemented in ElfNoteParser.ts with zero new external runtime dependencies.
  • Added domain schema definitions in src/domain/native/elfNotes.ts using Zod strict schemas with exact hexadecimal formatting.
  • Integrated TextBudget.chargeText to bound decoded string paths and arguments within existing memory limits.
  • Added comprehensive unit tests and fixtures in src/native/elf/ElfNoteParser.test.ts and src/native/elf/ElfNotes.fixture.ts.
  • Added end-to-end acceptance tests in tests/acceptance/elfNotesCore.test.ts covering both the CLI (rea inspect-elf-notes --json) and the MCP server (inspect_elf_notes).
  • Updated docs/elf-notes.md and tool contracts to document Linux core note observations.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Native ELF parser (ElfNoteParser.ts) producing ElfNotes domain evidence consumed by CLI and MCP handlers.
  • Contribution scope fit and linked maintainer decision: Follows existing inspect_elf_notes static analysis capability without process execution or debugger invocation.
  • CLI and MCP/tool-catalog contract: Output schema for inspect_elf_notes updated with backward-compatible nullable core note field.
  • Provider, bridge, target-format, or platform compatibility: Standard Linux ELF core dump format (sys/procfs.h, linux/elfcore.h). Portable across all supported Node.js host environments.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves artifact path, hash, byte length, and raw descriptor previews.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable (purely static file inspection).
  • Generated metadata impact: none.

Expected effects:

  • 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:
    • src/native/elf/ElfNoteParser.test.ts: Added unit tests for 64-bit LE, 32-bit BE, and malformed core notes.
    • tests/acceptance/elfNotesCore.test.ts: Added CLI and MCP acceptance test for core dump note decoding.
    • src/native/elf/ElfNotes.fixture.ts: Added core note generation fixtures.
  • Base reproduction or other evidence: Core notes previously resulted in type_name: "unknown", gnu: null.
  • User-visible CLI/MCP output:
{
  "owner": "CORE",
  "type": 1179208773,
  "type_name": "core_file",
  "gnu": null,
  "core": {
    "file": {
      "count": 2,
      "page_size": 4096,
      "mappings": [
        {
          "start_address": "0x555555554000",
          "end_address": "0x555555558000",
          "file_offset_pages": "0x0",
          "path": "/opt/target-service"
        }
      ]
    }
  }
}

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

  • npm run check:fast — passed (0 errors, turbo typecheck & oxlint)
  • npm run docs:check — passed (package, skill, product catalog, completion ledger, and readme consistency tests passed)
  • npx vitest run src/native/elf/ElfNoteParser.test.ts src/native/elf/ElfNotesProvider.test.ts src/domain/native/elfNotes.test.ts tests/acceptance/elfNotesCore.test.ts tests/acceptance/elfNotesAbiEndian.test.ts tests/acceptance/elfNotesCli.test.ts tests/boundary/mcp/elfNotesMcp.test.ts tests/boundary/filesystem/elfNotes.test.ts — passed (8 test files, 84 tests passed)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Existing consumer fields and contracts remain intact.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: Purely passive binary parser respecting strict TextBudget bounds.

Author readiness

Human owner: @rishikeshgowdakk

  • 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.

Inspect Linux core dump note tables and decode structured metadata without
requiring external tools or debuggers:
- NT_PRPSINFO (type 3): decode process ID, parent ID, process group,
  session, UID, GID, execution state, filename, and command line arguments
  bounded by the text budget.
- NT_FILE (type 0x46494c45): decode mapped memory ranges (start_address,
  end_address, file_offset_pages) and mapped file paths with page size.
- NT_SIGINFO (type 0x53494749): decode faulting signal number, errno, and code.
- NT_AUXV (type 6): decode auxiliary vector pairs with known AT_* tag names.
- Support both 32-bit and 64-bit, little-endian and big-endian targets.
- Retain unknown core note types gracefully without partial success errors.
- Add comprehensive unit tests, fixtures, acceptance tests, and documentation.
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T20:45:41.832024Z 5aa3bd2 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a792c5019c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/elf/ElfNoteParser.ts Outdated
const nullIdx = descriptor.indexOf(0, strPos);
if (nullIdx < 0) return null;
const pathBuf = descriptor.subarray(strPos, nullIdx);
const path = pathBuf.toString("utf8");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve non-UTF-8 mapping path bytes

For a Linux core whose NT_FILE filename contains bytes that are not valid UTF-8, which Linux pathnames may contain, this conversion replaces them with U+FFFD, so the emitted mapping path no longer identifies the original file and distinct byte paths can collapse. Preserve the path bytes losslessly or include their raw encoding alongside the display string.

AGENTS.md reference: AGENTS.md:L37-L37

Useful? React with 👍 / 👎.

prpsinfo: null,
file: null,
siginfo: null,
auxv,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unterminated or truncated AUXV vectors

When an NT_AUXV descriptor lacks an AT_NULL entry, ends in a partial pair, or has more than 128 non-null pairs, this loop stops at the available or capped prefix and still returns it as core.auxv. The caller receives no truncation or invalid marker, so a malformed or capped vector is presented as complete process state; verify the terminator and entry boundaries, or report the cap, before returning it.

AGENTS.md reference: AGENTS.md:L37-L37

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96ef6f6b31

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/elf/ElfNoteParser.ts Outdated
const pathBuf = descriptor.subarray(strPos, nullIdx);
const path = pathBuf.toString("latin1");
const path_hex = pathBuf.toString("hex");
chargeText(text, pathBuf.length);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Budget NT_FILE path hex expansion

For an accepted large NT_FILE descriptor with long paths, this charges only the path length even though the mapping also allocates and emits path_hex at twice that length. The returned mapping strings can therefore reach roughly three times the source path bytes while the shared text budget accounts for only one, allowing a file within max_file_bytes to produce much larger output and risk memory exhaustion during CLI/MCP serialization. Charge the hex expansion before constructing it or bound the raw field.

AGENTS.md reference: AGENTS.md:L91-L91

Useful? React with 👍 / 👎.

@rishikeshgowdakk

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b03ac1116

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/elf/ElfNoteParser.ts Outdated
Comment on lines +472 to +473
const errno = i32(4);
const code = i32(8);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Decode SIGINFO with the target ELF ABI

On Linux MIPS cores, siginfo_t stores the prefix as signo, code, errno, but these reads interpret the latter fields as errno then code. A SIGSEGV/SEGV_MAPERR can therefore be reported as errno 1 and code 0; select the order from the ELF machine/ABI or leave it unknown when unsupported.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

Comment thread src/native/elf/ElfNoteParser.ts Outdated
Comment on lines +444 to +446
start_address: hexWord(raw.start),
end_address: hexWord(raw.end),
file_offset_pages: hexWord(raw.offsetPages),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Budget NT_FILE address string expansion

With max_entries set to its allowed 256, an ELF can contain 256 NT_FILE notes with 4096 mappings each, within the parser's limits. These conversions create three up-to-18-character strings per mapping without charging them to TextBudget; roughly 25 MiB of short-path descriptors can therefore produce over a million retained mapping objects and a much larger inline CLI/MCP result. Charge this expansion or cap total mappings before building the arrays.

AGENTS.md reference: AGENTS.md:L91-L91

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed updates fix all three numbered findings and add no separate blocking finding.

Summary

Adds Linux CORE note decoding to inspect_elf_notes and inspect-elf-notes.

  • ELF note reports now decode Linux core process and crash details.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Selected ELF file"] --> B["Read declared note tables"]
  B --> C["Keep source ranges and descriptor hashes"]
  C --> D["Decode GNU and Linux CORE notes"]
  D --> E["Apply shared text and scan allowances"]
  E --> F["ElfNotes output contract"]
  F --> G["CLI JSON"]
  F --> H["MCP response"]
Loading

Reviews (3) · Last reviewed commit: "fix(elf): cache auxv padding scans, pre-..." · Reviewed by Greptile

Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.ts Resolved
@rishikeshgowdakk

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 359ecd49de

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/elf/ElfNoteParser.ts Outdated
break;
}
const aVal = readWord(off + wordSize);
rawPairs.push({ aType, aVal });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Charge AUXV entries before retaining them

With max_file_bytes raised to the allowed 512 MiB, a single NT_AUXV can contain tens of millions of non-null pairs; the max_entries cap counts notes, not pairs. This line retains every pair before the post-loop chargeText runs, so an over-budget vector can exhaust the CLI/MCP process instead of returning a bounded limit failure. Charge or cap the vector before retaining it.

AGENTS.md reference: AGENTS.md:L57-L58

Useful? React with 👍 / 👎.

Comment thread src/native/elf/ElfNoteParser.ts Resolved
Comment thread src/native/elf/ElfNoteParser.test.ts Resolved
@rishikeshgowdakk

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 5aa3bd2303

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto
morluto merged commit e75d1c7 into morluto:main Nov 4, 2026
6 checks passed
@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks for adding Linux core-dump note decoding, @rishikeshgowdakk, and welcome to REA! The retained PRPSINFO, FILE, SIGINFO, and AUXV facts add process, mapping, signal, and auxiliary-vector context without launching a debugger; bounded strings and unparsed unsupported notes keep the limits visible.

@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants