Skip to content

feat(artifacts): inventory and extract Node.js single executable application blobs - #7000

Merged
morluto merged 3 commits into
morluto:mainfrom
mvanhorn:fix/node-sea-blob
Oct 24, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
mvanhorn:fix/node-sea-blob

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A Node.js single executable application (SEA) is the node binary with a NODE_SEA_BLOB injected: the main script, an optional snapshot or code cache, and named assets. Before this change inspect-artifact saw such a file only as a plain Mach-O, ELF or PE executable, and extract-artifact had nothing to extract. This adds a node-sea artifact reader so the blob is inventoried and its stored members can be extracted; the executable itself is never started. No related issue; this is a new static format in the existing artifact graph.

Problem and expected behavior

An analyst who wants the shipped JavaScript of a SEA today has to find the blob and decode Node's layout by hand. Expected: inspect-artifact reports root format node-sea with flags, code path and fuse observations, and lists the main script, snapshot or code cache, and each asset by name; extract-artifact writes their stored bytes through the existing safe output tree.

Change and scope

src/artifacts/nodeSea/NodeSeaLocation.ts locates the blob in Mach-O __NODE_SEA_BLOB sections, ELF notes owned by NODE_SEA_BLOB, and PE RCDATA resources named NODE_SEA_BLOB. NodeSeaBlob.ts decodes the Node v24 layout. NodeSeaArtifactReader builds members.

For ELF, PT_NOTE segments are authoritative, as at runtime; SHT_NOTE sections are read only when no program-header table is readable. The real postject-injected aarch64 binary below carries stale section entries that start mid-note. For PE, a bounded name probe runs before the shared resource parser, so a malformed resource tree in an ordinary PE stays a native-classification concern.

Truncation, unknown flags, invalid UTF-8, duplicate asset names and conflicting blobs fail closed. Limits are in docs/node-sea.md. Asset count and name-byte admission bound retained metadata independently of body sizes; decoding and inventory construction yield for cancellation, and member construction no longer retains a second full array. Not included: decoding V8 snapshots or code caches, or any execution. No new tool; the existing artifact contracts carry the new format. AI was used for assistance.

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: artifact inventory classification (src/artifacts/inventory/classify.ts) and the artifact reader registry.
  • Contribution scope fit and linked maintainer decision: static format inspection and extraction of a local file within existing artifact authority; separate scope decision not applicable.
  • CLI and MCP/tool-catalog contract: no new tool or flag. inspect_artifact / extract_artifact accept the new node-sea root format; the artifact format enum gains node-sea and node-sea-entry.
  • Provider, bridge, target-format, or platform compatibility: portable TypeScript, no provider. Mach-O (including universal), ELF and PE carriers.
  • Evidence, artifact, provenance, or reconstruction contract: new format_metadata kinds for the root and entries; raw flags, code path, blob location and fuse observations are retained.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; extraction uses the existing safe output tree and never overwrites.
  • 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): adds a verify:node-sea package script. No committed build outputs.

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: src/artifacts/nodeSea/NodeSeaBlob.test.ts and src/artifacts/NodeSeaArtifactReader.test.ts (Mach-O, universal, ELF and PE carriers; flags and fuses; a stale SHT_NOTE entry beside a valid PT_NOTE; a non-SEA PE with a cyclic resource tree; the large-PE admission limit; truncated, unknown and conflicting blobs), tests/acceptance/nodeSeaCli.test.ts, tests/boundary/mcp/nodeSeaMcp.test.ts. Fixtures are synthetic; no binaries are committed.
  • Base reproduction or other evidence: with the released CLI, inspect-artifact on a SEA reports a plain native executable and extract-artifact has nothing to extract. Executed against a real Node 24.22.1 linux-arm64 SEA (not committed), built with node --experimental-sea-config and postject with useCodeCache: true and two assets. Before the PT_NOTE change this binary failed with Node SEA ELF note table is truncated.
  • User-visible CLI/MCP output (if applicable): see below.
  • Remaining proof gaps: no real Mach-O or PE SEA was exercised (synthetic coverage only). Older blob layouts without the exec-argument byte are not supported.
$ rea inspect-artifact hello-sea --json | jq ...
root: node-sea
  main-script  app.js
  code-cache   __node_sea__/code-cache
  asset        config.json
  asset        greeting.txt

$ rea extract-artifact hello-sea --json   # output root contains:
app.js  config.json  greeting.txt  __node_sea__/code-cache

The extracted app.js and greeting.txt are byte-identical to the build inputs (cmp).

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

Review follow-up b5a7256b7; macOS arm64, pinned Node 24.22.1 and npm 11.16.0:

  • npm run test:focused -- src/artifacts/nodeSea/NodeSeaBlob.test.ts src/artifacts/NodeSeaArtifactReader.test.ts tests/acceptance/nodeSeaCli.test.ts tests/boundary/mcp/nodeSeaMcp.test.ts - 56 tests passed. Covers parser limits, in-flight cancellation, close during inventory construction, compiled CLI inventory/extraction, and both MCP schema profiles, including refusal of an empty-body table above the record bound.
  • npm run check - passed (typecheck, lint, module boundaries, architecture guards).
  • npm run docs:check - passed, including 9 README consistency tests.

The author's earlier real Linux arm64 SEA inventory/extraction evidence above was not rerun for this cancellation follow-up. Real Mach-O and PE producer coverage remains unverified. No resource benchmarks were run.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Files that previously classified as plain native executables now classify as node-sea only when a valid blob is found.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with a Linux arm64 carrier; no provider involved.
  • Package or release metadata impact: one new package script (verify:node-sea).
  • Security, privacy, process, or containment review: the input is never executed; parsing is bounded and extraction goes through the existing safe output tree.

Author readiness

Human owner: @mvanhorn

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

Demo

demo

…ication blobs

Adds a node-sea artifact reader that locates the NODE_SEA_BLOB payload in
Mach-O sections, ELF notes and PE RCDATA resources, decodes the blob
header, main script, optional snapshot and code cache, and named assets,
and extracts their stored bytes through the existing safe output tree.
The executable is never run. Resource-tree errors in a PE without a
NODE_SEA_BLOB name stay with native classification; truncated, unknown
or over-limit SEA declarations fail closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge based on the reviewed changes.

Summary

Adds static inventory and extraction of Node.js SEA blobs in Mach-O, ELF, and PE files.

  • REA inventories Node.js SEA programs inside native executables.
  • REA extracts stored scripts and assets from Node.js SEA files.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Native executable] --> B[Locate SEA blob]
  B --> C[Decode bounded blob]
  C --> D[Build and check members]
  D --> E[Artifact inventory]
  E --> F[Extract through safe output tree]
Loading

Reviews (3) · Last reviewed commit: "fix(artifacts): make SEA metadata constr..." · Reviewed by Greptile

Comment thread src/artifacts/nodeSea/NodeSeaBlob.ts Resolved
Comment thread src/domain/artifactInspection.ts Resolved
mvanhorn and others added 2 commits October 24, 2026 06:20
Move the bounded NODE_SEA_BLOB name probe into the shared PE resource
layout module so SEA admission uses the same header and section mapping
as the full parser; the layout reader now accepts a header prefix with
the file size. Bound SEA asset count and decoded name bytes before
records are created and report resource bounds as limit failures. Offer
the JavaScript next probe only for main scripts with a source suffix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
@morluto
morluto merged commit ed79bf9 into morluto:main Oct 24, 2026
36 of 44 checks passed
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants