Skip to content

fix(electron): reject active scenario capture when inspect fuse is disabled (#3453) - #3605

Merged
baron merged 5 commits into
morluto:mainfrom
HarsH-1877:fix/electron-inspect-arguments-fuse-3453
Oct 15, 2026
Merged

baron merged 5 commits into
morluto:mainfrom
HarsH-1877:fix/electron-inspect-arguments-fuse-3453

Conversation

@HarsH-1877

Copy link
Copy Markdown
Contributor

Summary

Fixes #3453. In active Electron scenario capture (capture_electron_scenario), Playwright attaches to the target Electron main process using Node CLI inspect arguments (--inspect=0 or --remote-debugging-port=0). When an Electron executable has the EnableNodeCliInspectArguments fuse explicitly disabled or removed, the runtime silently ignores inspection flags, causing Playwright to hang for the full 60-second startup deadline before timing out.

This PR adds a pre-flight fuse inspection before process launch. If the executable explicitly disables or removes EnableNodeCliInspectArguments, capture() immediately fails fast with a typed AnalysisUnsupportedTargetError ("unsupported_target") without spawning processes or waiting for the startup deadline.

Problem and expected behavior

  • Trigger: Calling capture_electron_scenario on an Electron target binary where the EnableNodeCliInspectArguments fuse is disabled (e.g. Obsidian or production Electron distributions).
  • Previous behavior: PlaywrightElectronActiveProvider attempts to launch the binary with inspect flags. Playwright hangs for 60 seconds awaiting the DevTools connection, ultimately throwing a generic startup timeout error.
  • Expected behavior: PlaywrightElectronActiveProvider reads the binary's fuses prior to launch and returns an immediate AnalysisUnsupportedTargetError advising the caller to use passive CDP inspection (inspect_electron_page) or run against an unrestricted development binary. If the fuse state is unknown, missing, or unparseable, launch proceeds normally.

Change and scope

  • Added assertNodeCliInspectArgumentsSupported helper in src/browser/PlaywrightElectronActiveFuses.ts utilizing existing readElectronFuseImage.
  • Integrated pre-flight check into PlaywrightElectronActiveProvider.capture() before process baseline capture and launch.
  • Injected optional readFuseImage into PlaywrightElectronActiveProvider for isolated unit testing.
  • Documented target fuse prerequisites in docs/electron-observation.md.

Contribution scope: Not applicable (ordinary fix within existing provider boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/browser/PlaywrightElectronActiveProvider.ts (provider pre-launch stage).
  • Contribution scope fit and linked maintainer decision: Not applicable.
  • CLI and MCP/tool-catalog contract: Unchanged schema; failure returns tagged AnalysisUnsupportedTargetError.
  • Provider, bridge, target-format, or platform compatibility: Cross-platform Electron (Mach-O, PE, ELF).
  • Evidence, artifact, provenance, or reconstruction contract: Refusal returns structured error without corrupting partial evidence.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Fast-fail before launch prevents orphan processes and avoids unnecessary process supervisor tracking.
  • Generated metadata (docs/public/product-catalog.json), package, or installation 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:
    • Unit tests in src/browser/PlaywrightElectronActiveFuses.test.ts (8 tests covering disabled, enabled, unknown/missing wire, unparseable, Mach-O universal, Windows PE, Linux ELF, and AbortSignal cancellation).
    • Integration test in src/browser/PlaywrightElectronActiveProvider.test.ts (rejects active capture before launch when EnableNodeCliInspectArguments fuse is disabled).
  • Base reproduction or other evidence: On base eab789aed, calling capture on a fuse-disabled binary invoked launch() and timed out after 60s. With this change, launch() is never called and AnalysisUnsupportedTargetError is returned immediately.
  • User-visible CLI/MCP output (if applicable):
    AnalysisUnsupportedTargetError: Target binary disables the EnableNodeCliInspectArguments fuse; Node CLI inspector arguments are ignored and active scenario capture cannot attach.
  • Remaining proof gaps: None.

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 — 2/2 tasks passed (typecheck & lint clean).
  • npm run verify:module-boundaries — 1887 files checked, 0 violations.
  • npm run test:focused -- src/browser/PlaywrightElectronActiveFuses.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts — 15/15 tests passed.
  • npm run verify:test-discovery — 1280 files discovered exactly once.
  • npm run docs:check — 6/6 tasks passed (docs & catalogs consistent).
  • npm run build:cached — 3/3 tasks passed (runtime bundle compiled cleanly).

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Node v22.20.0 / Windows 11 host.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Refusing execution when inspector arguments are disabled honors the target's explicit containment settings and prevents hanging background processes.

Author readiness

Human owner: @HarsH-1877

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

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

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; all previous findings are addressed and no new blocking issue was found.

Summary

Adds a fuse check before active Electron capture launches the target.

  • Active Electron capture checks the inspector fuse before launch.

All three previous findings are addressed. No new actionable issue or security concern was established. Available local history showed no superseding change.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Capture request] --> B[Find executable or macOS framework]
  B --> C[Read fuses within startup deadline]
  C --> D{Inspect fuse state}
  D -->|Disabled or removed| E[Return unsupported target]
  D -->|Enabled or unknown| F[Capture process baseline]
  F --> G[Launch original executable]
  C -->|Deadline reached| H[Return timeout without launch]
Loading

Reviews (2) · Last reviewed commit: "fix(electron): resolve macOS framework b..." · Reviewed by Greptile

@rahul05ranjan rahul05ranjan 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.

Verified the preflight is at the right layer: PlaywrightElectronActiveProvider is the only implementation of the ElectronActiveObservationPort (wired once in src/composition/electronScenario.ts), and the check runs before both captureBaseline and launch(), so no active-capture entry point skips it. The passive CDP path (inspect_electron_page) is correctly untouched.

Ran src/browser/PlaywrightElectronActiveFuses.test.ts on arm64 Linux: 9/9 pass, including the ELF/PE rejection cases, the no-sentinel fail-open, and the universal-binary slice selection (arm64 slice enabled resolves on an arm64 host). The provider integration test also asserts launchSpy is never invoked on a fuse-disabled binary, so the fast-fail happens before any process spawn — no orphan process or supervisor tracking.

Two things I'd think about:

  1. The .app fallback in appBundleDirectoryOf: when resolveElectronFuseTarget throws (e.g. the app ships a renamed framework instead of Electron Framework.framework), the catch silently falls back to reading the launcher binary, which typically has no sentinel — the preflight passes and the user is back to the original 60-second hang. Missing/unknown fuse state failing open is fine and documented, but a resolver failure is a different failure mode: the fuse wire likely exists and we just couldn't reach it. Should a resolver failure on a confirmed bundle at least be distinguishable from a genuinely unknown state?

  2. The deadline wrapping: runWithExecutionLimits races the preflight against startupDeadline but doesn't cancel the underlying read, so on timeout the fuse scan (which also computes a full sha256 of a possibly ~1 GiB file per the reader's admission bounds) keeps running in the background after capture has already failed, and the shared deadline shortens the effective launch timeout for slow reads. Not a blocker — but the new tests cover the rejection and fail-open paths well, and there's nothing covering the deadline-expiry path.

@HarsH-1877

Copy link
Copy Markdown
Contributor Author

@rahul05ranjan Appreciate you running the test suite on arm64 Linux and verifying the layer boundaries!

Regarding the two points:

  1. Resolver failure on .app bundles: Failing open when resolveElectronFuseTarget fails is intentional per REA's contract on unknowns (AGENTS.md and docs/electron-observation.md). If a non-standard or customized Electron bundle ships with a renamed framework or unusual directory layout, we cannot definitively observe fuse wire state. Failing closed would risk false-positive rejections for custom builds that might actually permit CLI inspection, so we preserve the unknown state and let Playwright attempt launch.

  2. Deadline wrapping & read cancellation: runWithExecutionLimits follows the existing pattern used across PlaywrightElectronActiveActions. Caller cancellation via options.signal is forwarded directly to readFuseImage. Coupling internal deadline timeouts to an AbortController to cancel underlying async tasks would be a worthwhile enhancement to runWithExecutionLimits across the browser module in follow-up work.

@baron baron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed exact head 1369fcdf1ce8551893c6c0f451d0214f551affec against fresh origin/main, the fuse reader/path producer, active provider consumer, tests, documentation and existing review threads.

This is a routine refusal fix within existing capture authority, not a new execution/injection capability requiring a separate advance scope decision. The owner’s three readiness declarations are complete. The preflight consumes parsed fuse facts, resolves the normal macOS framework layout while leaving Playwright’s executable selection unchanged, and rejects before baseline capture/launch. Missing/unparseable fuse state remains unknown rather than being misrepresented as enabled. Passive inspection is unchanged.

The previous macOS-path, startup-deadline and cancellation-test findings have concrete fixes. I also accounted for the still-discussed limitations rather than treating them as solved: resolver failure intentionally falls back to unknown/normal launch, and the execution-limit race does not cancel its bounded underlying file scan on timeout. I agree these are nonblocking here: unknown is not a refusal claim, and deadline expiry prevents target launch; the latter resource/cancellation improvement belongs at the shared execution-limit owner rather than as a duplicate downstream timeout mechanism. No new blocking source/design issue was established.

Local verification on macOS arm64 with Node 24.19.0 (repository pins 24.18.0): all 9 fuse tests and the new provider no-launch regression passed. The combined focused run was 13 passed / 3 failed: three pre-existing provider launch/partial-capture cases failed before reaching their expected mocked path. I reran the provider file at the PR merge-base and observed the same three failures (3 passed / 3 failed); this environment does not independently establish those provider paths, and I do not claim a fully passing local suite or real Electron reproduction. Dependencies were independently installed in an isolated temporary checkout because its lock digest differs from the allowed shared-dependency digest.

Immediately before submission, the head remained unchanged and MERGEABLE. All 34 repository check/status contexts are successful or intentionally skipped, with no pending/failing context, including all five shards, browser, portable aggregation, CI required and PR readiness. Approval is based on the source/design review and that current-head CI, with the local limitations above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working provider: electron Analysis provider / engine: electron

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] capture_electron_scenario waits for the full 60 s startup deadline when the target's EnableNodeCliInspectArguments fuse is disabled

4 participants