Skip to content

feat(electron): inspect packaged Electron fuse state without execution - #2399

Merged
N0zoM1z0 merged 23 commits into
morluto:mainfrom
mvanhorn:fix/electron-fuse-inspection
Oct 14, 2026
Merged

N0zoM1z0 merged 23 commits into
morluto:mainfrom
mvanhorn:fix/electron-fuse-inspection

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Agents can now check whether a packaged Electron app will honor --inspect, ELECTRON_RUN_AS_NODE, embedded ASAR integrity, and app-only loading before trying a runtime lane. inspect_electron_fuses / inspect-electron-fuses reads the fuse wire stored in the Electron binary. It does not launch the app, write to it, or use the network.

No issue is linked. This is a new static, read-only primitive within the existing format-inspection scope, proposed here with the implementation.

Demo

Electron fuse inspection demo

Full-quality MP4

Simulated demo rendered from real output. Every value on screen is copied from rea inspect-electron-fuses on this branch, run against Obsidian.app and Granola.app installed on my machine.

Problem and expected behavior

observe_javascript_runtime with electron-main needs the app started with Inspector enabled. When the app's EnableNodeCliInspectArguments fuse is off, Electron ignores --inspect, and the agent only finds out after a launch and a target listing that has no main-process target. On my machine that fuse is off in all three Electron apps I checked.

The same fuse wire also says whether Electron validates embedded ASAR integrity and whether it loads app code only from app.asar. That decides whether the app.asar that analyze_javascript_application reads is the only code Electron will run, and whether an integrity contradiction reported by inspect_artifact is one Electron itself would enforce. REA had no way to read any of this.

With this change, one call on a .app bundle, the Electron Framework binary, or a Windows/Linux Electron executable returns, per slice: the sentinel offset, wire version, declared length, and every fuse as {index, name, state, raw_byte}. It also returns four labeled derivations (runtime_implications): inspector arguments honored or not, ELECTRON_RUN_AS_NODE honored or not, embedded ASAR integrity enforced or not, and app code restricted to app.asar or not.

Change and scope

The reader streams the selected file once in 256 KiB windows, carrying a sentinel-sized overlap between windows. It records every sentinel per slice (up to 32) without choosing between them. Universal Mach-O files reuse readMachoImage for slice ranges, so offsets are file-absolute and each slice reports its own wire. Fuse bytes 0, 1 and r map to disabled, enabled and removed. Any other byte is unknown with the raw byte kept. Indices past the version 1 name table keep name: null, and a different wire version keeps every byte but names nothing.

A missing sentinel is reported as unknown with a limitation, never as "all fuses disabled". A truncated wire is marked complete: false. Electron compiles embedded ASAR integrity validation only for macOS and Windows, so on an ELF executable that fuse byte is kept but its derivation is unknown.

Bundle selection resolves Contents/Frameworks/Electron Framework.framework and follows Versions/Current only inside the framework directory. A file selected inside the framework (for example .../Versions/Current/Electron Framework) is re-walked from the framework root, so the same links are rejected whichever way the binary is selected, and resolved_path names the real file. Contents, Frameworks and the framework directory itself must be real directories; a symlinked one is rejected rather than followed out of the bundle.

Out of scope: changing fuse state (this tool never writes), an inspect_artifact next-probe hint (possible follow-up), and inferring Inspector access granted from inside app code (for example app.commandLine switches). That last case is called out as a limitation in every result.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/electron/ElectronFuseReader.ts (wire parsing), src/electron/ElectronFusePath.ts (selection), domain schema and derivations in src/domain/electron/electronFuses.ts, service src/application/electron/ElectronFuseService.ts.
  • Contribution scope fit and linked maintainer decision: static format inspection of caller-selected files; no execution, injection, mutation or protection recovery, so not applicable.
  • CLI and MCP/tool-catalog contract: new inspect_electron_fuses / inspect-electron-fuses with one path input; registered next to the other Electron tools, effects entry evidence (read-only), catalog builders and capability inventory updated.
  • Provider, bridge, target-format, or platform compatibility: Mach-O (thin and universal), PE, ELF. No external tool.
  • Evidence, artifact, provenance, or reconstruction contract: Evidence records selected and resolved paths, SHA-256, size and container format; derivations are labeled relationship: "derivation" and cite the fuse index and sentinel offset they came from.
  • Target selection, authority, upstream behavior, and cleanup details: reads one admitted regular file; file identity is rechecked after the scan.
  • Generated metadata, package, or installation impact: authored skill text in .agents/skills/reverse-engineer-anything/ (SKILL.md and references/runtime-observation.md); build outputs not committed.

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/domain/electron/electronFuses.test.ts (state decoding, unknown bytes, version mismatch, missing and truncated wires, multiple sentinels, ELF ASAR applicability); src/electron/ElectronFuseProvider.test.ts (thin, universal, PE and ELF fixtures, sentinel split across read windows, framework symlink containment for bundle, framework, and direct Versions/Current/Electron Framework selection, and a symlinked framework directory); tests/acceptance/electronFusesCli.test.ts; tests/boundary/mcp/electronFusesMcp.test.ts; fixtures in tests/fixtures/electron/fuseImage.ts.
  • Base reproduction or other evidence: executed. Before this change there is no operation that reads the fuse wire.
  • User-visible CLI/MCP output: on three installed apps, the output matches an independent byte read of the same files exactly (same sentinel offsets and bytes):
App Container Wire Fuse bytes (index 0..n) Inspector args
Obsidian universal, 2 slices v1, 8 fuses 01000001 on both slices not honored
Discord universal, 2 slices v1, 9 fuses 001000011 on both slices not honored
Granola universal, 2 slices v1, 9 fuses 001011011 on both slices not honored

A full Obsidian result is 1,105 tokens (--token-count).

  • Remaining proof gaps: no real Windows or Linux Electron binary was checked; PE and ELF are covered by fixtures only.

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

All on macOS 27 with Node 26 and the pinned npm 11.16.0, on this branch rebased on 8fc2043:

npm run test:focused -- tests/acceptance/electronFusesCli.test.ts tests/boundary/mcp/electronFusesMcp.test.ts \
  tests/boundary/cli/cliToolCoverage.test.ts tests/boundary/filesystem/productCatalog.test.ts \
  src/domain/electron/electronFuses.test.ts src/electron/ElectronFuseProvider.test.ts src/contracts/toolEffects.test.ts   # pass: 7 files, 40 tests
npm run check:fast             # pass
npm run docs:check             # pass
npm run verify:test-discovery  # pass, 999 files
rea inspect-electron-fuses /Applications/{Obsidian,Discord,Granola}.app   # table above

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Additive tool.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only for real binaries.
  • Package or release metadata impact: skill text and docs only.
  • Security, privacy, process, or containment review: reads one caller-selected file; symlinks are followed only inside the Electron framework directory; no process launch, writes or network.

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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@matbrgz

matbrgz commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Review & Verification Summary

Verdict: LGTM (Approved) 🚀

1. Architecture & Security Invariants

  • Read-Only Inspection Without Execution: Accurately extracts the Electron fuse wire from Mach-O, PE, and ELF binaries via a streaming 256 KiB sliding window without launching the executable or executing scripts.
  • Fail-Closed Symlink & Path Hardening: ElectronFusePath.ts enforces that bundle traversals (Contents/Frameworks/Electron Framework.framework) never follow symlinks outside the enclosing bundle, strictly rejecting path traversal tricks.
  • Platform-Specific Epistemics:
    • Accurately differentiates macOS/Windows vs Linux ELF regarding ASAR integrity enforcement (marks derivation as unknown on ELF where integrity checks are not compiled in).
    • Keeps missing sentinels or truncated wires marked with explicit limitations rather than inferring disabled states.

2. Local Verification

  • npm run test:local -- src/domain/electron/electronFuses.test.ts passed (6/6 tests).
  • npm run test:local -- src/electron/ElectronFuseProvider.test.ts passed (12/12 tests).
  • npm run check:fast (Turbo typecheck + lint) passed cleanly across all workspaces.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was established.

Summary

Adds read-only Electron fuse inspection through inspect_electron_fuses and inspect-electron-fuses.

  • Electron fuse inspection shows what a packaged app will honor.

The previous-review ancestry check passed, but the merge bases differed. The full PR diff was therefore used throughout. All supplied previous threads were unnumbered, so none receive numbered ledger entries.

Source checks confirmed the reported fixes for the prior containment, active-version selection, report checks, resource tests, and repeated-search cases. Tests were not run during this review. Supersession could not be checked because GitHub access required authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI or MCP path] --> B[ElectronFuseService]
  B --> C[Admit selected file]
  C --> D[Check container and slice ranges]
  D --> E[Hash file and find fuse wires]
  E --> F[Decode bytes and derive meanings]
  F --> G[Check report and return Evidence]
Loading

Reviews (14) · Last reviewed commit: "chore: resynchronize Electron fuse inspe..." · Reviewed by Greptile

Comment thread src/electron/ElectronFusePath.ts Resolved
Comment thread src/domain/electron/electronFuses.ts Resolved
Comment thread src/electron/ElectronFuseProvider.ts Resolved
Comment thread src/electron/ElectronFusePath.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The path resolver discarded the identity facts established by containment checks, allowing the reader to admit a replacement path. Resolution now returns the selected file identity and every checked directory/link identity as owner facts. The reader checks those facts before and after open/read and compares bigint file metadata against the originally selected file. The provider consumes that selection directly. A regression swaps Versions/A to an outside link between selection and opening and expects refusal.

Validation: source inspection, touched-file formatting, and git diff --check. Tests, builds, lint, and real-provider verification were not run, as explicitly requested by the maintainer.

  1. thread 1

Candidate ordering selected a retained Versions/A before the framework's active link. Selection now follows the top-level Electron Framework binary first, then Versions/Current, and uses A only when those candidates are absent. An invalid active candidate fails closed. Added a retained-A/Current-to-B regression proving app/framework selection reads B.

Validation: source inspection, touched-file formatting, and git diff --check. Tests, builds, lint, and real-provider verification were not run, as explicitly requested by the maintainer.

@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation area: cli CLI adapter and one-shot commands area: server Server layer and tool wiring P2: medium Medium priority issue labels Oct 13, 2026
Comment thread src/electron/ElectronFusePath.ts Resolved
Comment thread src/domain/electron/electronFuses.ts Resolved
Comment thread src/electron/ElectronFuseReader.ts Resolved
Comment thread docs/electron-fuses.md Resolved
Resolve current-main integration, reject overlapping Mach-O slices before repeated scanning, validate scan windows, preserve changed-path semantics, and align the guide with active framework selection.

Co-authored-by: Kaoru0822 <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Maintainer follow-up and real-artifact verification are complete on 6631d5929.

What changed in the follow-up:

  • merged current main and resolved the Rust/Electron catalog, capability, server, test-project, and Hopper baseline conflicts;
  • rejected overlapping universal Mach-O slice ranges before sentinel scanning, preventing repeated FAT declarations from multiplying search work;
  • bounded injectable scan windows to 1–256 KiB, so zero cannot stall the scanner and oversized test configuration cannot allocate an unbounded buffer;
  • preserved artifact_changed semantics when a previously checked framework path disappears during admission;
  • corrected the guide's active framework selection order and updated its measured output size.

Real producer verification used Electron's official v44.7.1 release archives after checking all three archives against the release SHASUMS256.txt:

  • Linux x64 ELF, 228,506,952 bytes;
  • Windows x64 PE, 245,487,104 bytes;
  • macOS arm64 app/framework, 202,912,368 bytes.

For every artifact, REA found exactly one V1 sentinel and the same nine-byte wire, 101100011. SHA-256, absolute sentinel offset, version, length, and raw states matched an independent mmap scan. @electron/[email protected] read independently reported the same nine named states on all three platforms. The Windows result was also called through the public MCP server and exactly matched the CLI normalized result and subject.

Under a 2-CPU / 8 GiB process-family guard, complete CLI scans took 2.26–2.54 s each with about 440 MiB peak RSS including startup. The real Linux result was 1,157 CLI tokens. A 512 MiB sparse FAT file with 128 declarations of the same slice failed closed before scanning in 1.51 s at about 304 MiB peak RSS.

Validation:

  • 30 Electron fuse domain/adapter tests passed;
  • 5 public CLI/MCP fuse tests passed;
  • 24 capability inventory tests passed;
  • 11 product catalog tests passed;
  • 6 server identity tests passed in their stable run; cold 2-CPU runs exposed an existing fixed 10 s timeout sensitivity, while current main passed the same baseline and the PR's measured tests settled to 7.3/6.8 s;
  • npm run check:fast, npm run docs:check, and npm run check:ci passed;
  • no binary, generated build output, or downloaded artifact is committed.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Final CI classification for head e716beb20 / tested merge ref 3e9df1f5e:

  • 36 checks passed, including Build, Docs, Static checks, Greptile, all Electron fuse domain/provider tests (30/30 inside the full source lane), all real browser/Apple/package lanes, Windows capability/package, and reverse-tools coverage plus both Stryker mutation runs.
  • Source tests failed only in the base's newly added src/ghidra/GhidraPowerPcProfile.test.ts (3 cases); the Electron tests passed in the same job and this PR changes no Ghidra files.
  • Test shard (3/5) failed only in the base CI self-test tests/boundary/filesystem/ciTestReports.test.ts. Portable tests reproduced those same four base failures while more than 6,000 other tests passed. The later main commit 22552525d addresses the CI-report failure; it is outside this PR's Electron diff.
  • CI required only aggregated test, test-shard, and test-source as failed; it reported no additional product failure.

Local verification after the latest conflict resolution also passed the Electron tests (30/30), the fixed Rizin/cache-policy/CI-report/native-type-binding focused set (36 passed, 1 skipped), and npm run check:fast under the 2-CPU / 8 GiB guard. There are no unresolved review threads and no Electron-related CI failure remaining.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

The collaborator merge attempt is blocked only by branch protection on the two base-test failures documented above; repository auto-merge is disabled. The PR is mergeable, Greptile is green, every Electron check passed, and there are no unresolved threads.

A maintainer with bypass authority can squash-merge this head. Please retain these truthful trailers in the squash commit so the original and follow-up contributors remain credited:

Co-authored-by: Matt Van Horn <[email protected]>
Co-authored-by: morluto <[email protected]>
Co-authored-by: N0zoM1z0 <[email protected]>
Co-authored-by: Kaoru0822 <[email protected]>

N0zoM1z0 and others added 3 commits October 14, 2026 00:15
Co-authored-by: Kaoru0822 <[email protected]>

# Conflicts:
#	.agents/skills/reverse-engineer-anything/references/runtime-observation.md
@N0zoM1z0
N0zoM1z0 merged commit bcc1415 into morluto:main Oct 14, 2026
40 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Many thanks @N0zoM1z0 for merging the Electron fuse inspector. Reading the fuse wire statically should save agents a lot of wasted runtime attempts.

@morluto morluto mentioned this pull request Oct 14, 2026
3 tasks done
@morluto morluto added area: build Build, CI, packaging, and publishing provider: electron Analysis provider / engine: electron labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing area: cli CLI adapter and one-shot commands area: runtime Process capture and runtime observation area: server Server layer and tool wiring enhancement New feature or request P2: medium Medium priority issue provider: electron Analysis provider / engine: electron

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants