Skip to content

feat(native): inspect recorded crashes through pwntools and pwndbg - #1054

Merged
N0zoM1z0 merged 6 commits into
mainfrom
feat/recorded-crash
Oct 8, 2026
Merged

N0zoM1z0 merged 6 commits into
mainfrom
feat/recorded-crash

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refs #969. Add a general recorded-crash capability: inspect an explicit Linux core independently of an active disassembler or live process. This is useful for application crash investigation and binary analysis; CTF is only one possible application.

Problem and expected behavior

REA's offline ELF tool deliberately excludes cores. Agents need every recorded thread/register, original note bytes and source locations, with optional debugger mapping context. Historical PIDs must remain recorded metadata and must never select a live process.

Change and scope

  • Reuse unchanged pwntools/pyelftools structures and Linux amd64 ctypes. Extract the existing snapshot/process/reply boundary into a shared typed decoder; keep ELF-specific semantics and core semantics in separate adapters.
  • Add a portable report, application port/shared Evidence workflow and named CLI/MCP adapters. Source-bound uint64 registers remain lossless; each supported raw note requires exactly one interpretation and each recorded thread requires all27 supported register identities bound to their ABI slots. Note owners/descriptors and unfamiliar kinds are preserved.
  • Optional unchanged BYO pwndbg/GDB enrichment queries mapping candidates from the same snapshot, in an owned core-only session with no executable pairing. Preserve exact observed versions, diagnostics and unknown current file identities. Zero flags leave permissions unknown.
  • Own both stage lifetimes; preserve diagnostics across invalid output, cancellation and cleanup failure. Retain tighter inherited soft/hard limits. Keep resource-branch markers distinct from unverified launcher exits.
  • Retain upstream MIT license/provenance; add modular source-owned real verification and a conditional installed-package CI lane using the exact upstream commit/frozen lockfile.

Contract and boundary impact

  • Semantic owner and earliest changed stage: pure domain/native/recordedCrash; source parsing and ABI interpretation stay in provider bridges.
  • CLI and MCP/tool-catalog contract: inspect-recorded-crash / inspect_recorded_crash, explicit path and optional mapping-context facet; catalog139/skill33. No approval boolean. Coverage-bearing ELF/note headers, canonical kind labels and owner displays are independently bound to the selected snapshot; exact physical note/padding coverage prevents hidden or duplicated observations.
  • Provider/format/platform: Linux x64, ELF64 amd64 little-endian ET_CORE; pwntools4.15.0/pyelftools0.33/Unicorn2.1.2, optional pwndbg2026.09.15. Incompatible ELF class/endian/machine/type, declared OSABI or ABI version return target-specific failures before Linux note interpretation. System V/unspecified ABI alone does not prove OS origin. Shared ELF target rejections now use the existing unsupported_target category rather than provider absence.
  • Evidence/provenance: full raw/normalized report inline, SHA-256/size, original source coordinates, all recorded thread registers, signed signals, unknown note completeness and signal-thread association. Mapping candidates and an envelope containing them are explicitly derived; basic recorded evidence remains observed. PID/current-signal and meaningful SIGINFO scalars are independently bound to original descriptor bytes alongside registers.
  • Process/authority/cleanup: basic owned Python; optional owned GDB, core-only connection verified before map queries, no paired executable or caller GDB command language. Input is never launched by inspection. BYO engine code is trusted and process limits are not a sandbox.
  • Package/generated metadata: original pwndbg license and fixed bridges included; generated catalog/skill/package metadata regenerated. No installer or host-default configuration changes.

Evidence and regression coverage

  • Added domain/service/provider/SDK/schema tests, including source bytes, uint64 values, invalid context, requested unavailable context, cancellation and two-stage cleanup diagnostics.
  • Executed source-owned two-thread core fixture: high RDI/R12, signed signal code, fault-address meaning, raw/opaque/missing/malformed notes, negative/historical PIDs, missing/wrong reported plugin profile and unsupported ET_EXEC carrier.
  • A live owned sentinel collides with the recorded PID. CLI/MCP inspection traces preserve attempted executions and reject ptrace/process-memory access, provider lookups of that PID's /proc files, and attempted Internet sockets. Exact ownership ps enumeration and observed upstream iconv -l/selected Git version lookup are separately accounted for. Sentinel survives; no descendants remain after cleanup. Fixture generation explicitly executes its own test program.
  • User-visible invocation:
rea inspect-recorded-crash /artifacts/crash.core --debugger-context --json
{"name":"inspect_recorded_crash","arguments":{"path":"/artifacts/crash.core","include_debugger_context":true}}

The normalized report includes target_execution: "not-performed", live_process_identity: "unknown", source-bound threads[].registers[], raw notes[], and debugger with core connection, no executable, derived maps and unknown current file identities. This describes inspection, separately from fixture generation.

Remaining coverage: full unwinding, executable/library matching, live debugging, other architectures/core formats and other hosts are outside this increment. Shared decoder resource markers, late cancellation and cleanup have deterministic boundary regressions; real GDB memory/CPU exhaustion is not claimed.

  • 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

  • Focused domain/service/provider/SDK/schema/catalog tests: 93 passed, one host skip across10 files; after fixture refactoring, latest20 provider/service tests passed. Raw-owner follow-up:31 domain/service/provider checks passed; both thread/signal display-label counterexamples reproduced against the previous installed validator. ABI/scalar/confidence review follow-up:39 domain/service/provider/SDK checks passed; six scalar mismatches and the mixed-confidence envelope first reproduced as7 failing regressions, then passed after correction. Interpretation completeness follow-up:51 domain/service/provider/SDK checks passed;12 missing/duplicate-row, incomplete/unknown-register and wrong-register-slot counterexamples failed before the fix and passed after it. Final physical-source follow-up:64 focused checks passed;11 physical-identity/coverage/header counterexamples plus an unknown-owner display forgery were reproduced before correction. Exact physical coverage and independent source-header/enum/count binding close those paths.
  • npm run check:fast, npm run format:check, npm run docs:check — passed.
  • npm run verify:test-discovery — all576 test files exactly once.
  • Fresh npm pack --ignore-scripts / isolated installation — required bridges/runtime/original licenses included; private plans, reference clones, game data and binary fixtures excluded. Original upstream checkout remains unmodified.
  • Installed node scripts/verify-recorded-crash.mjs <installed>/scripts/rea.mjs — 42 actual CLI/MCP/trace cases passed on the latest9ba594c0 installed package (including GNU/Linux, Solaris, FreeBSD, unsupported ABI-version, extended program counts, zero/nonzero note tails and envelope confidence checks), complete139-tool schema/inventory/session parity; original inputs unchanged, sentinel alive and verifier descendants empty.
  • Local real debugger: GDB13.1 with unchanged pwndbg2026.09.15 build55596aa; The hosted installed-package workflow passed28 cases on818d70ef after provisioning GDB on the disposable runner, with no VPS changes. The previous9147e89b hosted36-case proof and its local6-case owner smoke also passed. Synced current main b9fb438 (shared Evidence and CLI JSON changes) without conflicts, producing be6c54e. All102 relevant core/Evidence/CLI JSON checks and a freshly installed6-case CLI/MCP smoke passed with139 schemas. Latest-head hosted42-case verification and all remaining CI must pass before merge.

Compatibility, safety, and release

  • Breaking changes/migration: none; additive target-free capability and optional evidence facet. Existing ELF workflow retains its behavior apart from the intentional target-error classification correction.
  • Real Hopper/Ghidra/browser: not run; independent capability. Linux actual GDB/pwndbg verification performed as above; no other OS claim.
  • Package/release: new bridges and original license, generated catalog/skill updated. No release requested or triggered.
  • Local-only evidence, supplied paths and diagnostics are retained. No ambient environment persistence, live PID authority, implicit host-file pairing or host-default changes.

Review checklist

  • One focused outcome; Conventional Commit title.
  • Related issue linked.
  • Changed behavior and meaningful failure paths tested.
  • Owning docs/contracts/generated metadata updated.
  • Representative CLI/MCP invocation and result semantics included.
  • Final diff checked for private data, unrelated changes and unsupported claims.

@N0zoM1z0 N0zoM1z0 added enhancement New feature or request area: bridge Hopper bridge (Python) related changes area: mcp MCP server, transport, and tool registration area: tests Test suite and verification labels Oct 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 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-10-08T08:46:43.260168Z be6c54e 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.

@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: cfd3627b52

ℹ️ 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 bridge/pwntools/recorded_crash_impl.py Resolved
@N0zoM1z0

N0zoM1z0 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review the latest 818d70e follow-up as well as the core-only ownership and evidence boundaries. Final self-review reproduced a portable validator gap: an EVIL NUL-terminated raw owner could be accepted if its display label said CORE (both thread and signal variants). The validator now requires exact raw CORE bytes, matching the existing unchanged decoder behavior;31 focused checks pass. The first real CI stopped at missing GDB on the disposable runner, before provider execution; the workflow now provisions that CI prerequisite. VPS defaults are unchanged. The earlier installed28-case proof passed, and a current-package owner-boundary smoke is running.

@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: 818d70efac

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

@N0zoM1z0

N0zoM1z0 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review the latest b2cd148. All three findings are fixed and backed by failing-before/passing-after regressions: compatible OSABI/version checks before Linux note interpretation, independent snapshot binding of PID/signal scalars, and derived confidence for mixed debugger-map Evidence. Latest39 focused tests and static/build/docs/format checks passed; the freshly installed package passed36 real CLI/MCP/core-only trace cases, complete139-tool schemas and cleanup with no descendants. Earlier818d70ef hosted core and ELF real-tool lanes passed. Waiting for all latest-head CI before merge.

@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: b2cd148bb3

ℹ️ 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/domain/native/recordedCrash.ts Resolved
@N0zoM1z0

N0zoM1z0 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review latest9147e89b, addressing the remaining completeness finding. Each supported raw note must have exactly one interpretation and each thread every supported register exactly once, with register names independently bound to ABI slots.12 regressions failed before the fix;51 targeted checks and latest installed6-case CLI/MCP smoke with139-tool schema/inventory parity now pass. Full36-case installed verification passed locally and in hosted CI on b2cd148; latest-head CI is running. No additional feature scope.

@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: 9147e89b90

ℹ️ 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/domain/native/recordedCrash.ts Resolved
@N0zoM1z0

N0zoM1z0 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review the latest 9ba594c, addressing the physical note identity finding. Pure aligned/physical coverage checks and independent snapshot header/count/kind bindings prevent duplicate or hidden notes/segments; owner displays are checked against raw bytes as well. Latest 64 targeted tests and freshly installed 42-case CLI/MCP/core-only trace verification passed, including extended program counts and zero/nonzero note tails, all 139 schemas and empty descendants. The unchanged upstream parser remains in use. Waiting for latest-head CI before merge; no new feature scope.

@N0zoM1z0 N0zoM1z0 self-assigned this Oct 8, 2026

@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: be6c54e3ad

ℹ️ 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 on lines +42 to +45
if content[4:6] != b"\x02\x01":
raise CoreFailure("unsupported-target", "Initial recorded-core profile requires ELF64 little-endian.")
if len(content) < 64:
raise CoreFailure("format", "Selected ELF64 core header is truncated.")

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 invalid ELF versions before decoding core notes

When an otherwise valid-looking core sets either EI_VERSION (byte 6) or the ELF header's e_version field to a value other than EV_CURRENT, these checks still proceed because they validate only class, endianness, OSABI, type, and machine; the independent snapshot binding omits both version fields as well. Such a malformed carrier can therefore have its Linux note payload interpreted and returned as observed crash evidence instead of producing an invalid-format failure, so validate both version fields before constructing ELFFile and bind them again at the consumer boundary.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

Comment on lines +68 to +72
for (const [key, path, kind] of [
["REA_PWNDBG_GDB", gdb, "file"],
["REA_PWNDBG_GDBINIT", entry, "file"],
["REA_PWNDBG_VENV_PATH", venv, "directory"],
] as const) {

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 Check cancellation before debugger configuration probes

When include_debugger_context is requested and cancellation arrives after the basic decoder completes but before or during this preflight, an invalid or missing GDB/pwndbg path is caught and converted to AnalysisCapabilityUnavailableError because the first abort check occurs only after all three probes and the staging writes. The caller can therefore receive a provider-configuration failure instead of cancellation; check the signal before these probes and preserve cancellation if it fires while they run.

AGENTS.md reference: AGENTS.md:L59-L59

Useful? React with 👍 / 👎.

@N0zoM1z0
N0zoM1z0 merged commit 163ee09 into main Oct 8, 2026
32 of 33 checks passed
@N0zoM1z0
N0zoM1z0 deleted the feat/recorded-crash branch October 8, 2026 08:50
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…orluto#1054)

* feat(native): inspect recorded crashes through pwntools and pwndbg

* fix(native): bind core note semantics to raw owner bytes

* fix(native): validate recorded core ABI and evidence scalars

* fix(native): require complete recorded note interpretations

* fix(native): bind physical core notes to original headers
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 23, 2026
@morluto morluto added the provider: pwntools Analysis provider / engine: pwntools label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: bridge Hopper bridge (Python) related changes area: mcp MCP server, transport, and tool registration area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: tests Test suite and verification enhancement New feature or request provider: pwntools Analysis provider / engine: pwntools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants