Skip to content

fix(electron): reject non-executable paths and contain launch rejections - #2705

Merged
morluto merged 21 commits into
morluto:mainfrom
CassieFox23:fix/electron-launch-rejections
Oct 13, 2026
Merged

morluto merged 21 commits into
morluto:mainfrom
CassieFox23:fix/electron-launch-rejections

Conversation

@CassieFox23

@CassieFox23 CassieFox23 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: A bad executable_path could kill the whole REA process. Now a file you can't run is refused up front. A launch that fails gets a normal error, and the server keeps running. I tested this on Linux only.

Summary

Refs #2269. I tested on Linux only, so this does not close the issue.

capture_electron_scenario could end the whole process. In MCP the server exited and the client saw Connection closed. All retained Evidence went with it. In the CLI there was a Node stack trace and no JSON.

This PR does two things. It refuses an executable_path that is not an executable file, before any launch. It also turns a failed launch into a typed execution_failure instead of a crash.

Problem and expected behavior

Playwright starts four promises in electron.launch(). Each waits for output. It awaits only one. When the child exits or the launch times out, all four reject. Nobody awaits the other three. They become unhandled rejections, and Node ends the process.

I checked this with a short script that calls _electron.launch directly. For an executable that exits at once, three unhandledRejection events fired about 2 ms before the catch ran. A launch that timed out showed the same shape, with Playwright's own TimeoutError.

On Linux, the smallest trigger is a file with the execute bit that never prints Debugger listening on. Three such files crashed the process:

  • a script that runs exit 0
  • a script that sleeps (the timeout case, 60 s)
  • a plain text file with mode 755

A text file without the execute bit did not crash on Linux. The spawn fails with EACCES, and Playwright rejects cleanly. That case already returned execution_failure. On Windows the launch goes through a shell, so any file can reach the crash path. I could not test Windows.

Expected: a typed error, a live server, and Evidence that survives.

Change and scope

Two small changes, one at each boundary.

  • src/application/javascript/ElectronActiveObservationService.ts checks the resolved executable_path while paths are canonicalized. It must be a regular file. On non-Windows hosts it must also pass access(X_OK). A failure is an invalid_request with issues[0].path = ["executable_path"]. It is the same shape as the unresolved-path issues, and it joins the same list.
  • src/browser/PlaywrightElectronActiveProvider.ts wraps only the launch call in containLaunchRejections. While the call runs, it listens for unhandledRejection. A rejection that does not come from Playwright is re-thrown at once. A Playwright rejection is held until the call settles. If the launch failed, a held rejection is dropped only when its message is part of the launch's own error. Every other held rejection is raised again, so the process still fails. If the launch worked, all held rejections are raised again. The listener is removed on every path. The real error still reaches the existing catch and becomes the usual typed failure.

Not included:

  • No check that the file is an Electron binary. A wrapper script is a valid launcher, so a magic-byte check would be wrong.
  • No Windows executable check. A .cmd shim can launch there, and I cannot test PE rules.
  • No dependency bump, and no child process for launches.

Closed PR #2501 checked a Windows PE header inside canonicalPaths. That function is gone from main. It did not touch the Playwright rejection. The commit that closed #2272 says this crash is separate.

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 final review checklist
unchecked. Maintainers can help resolve open questions.

This is a fix inside existing limits. It adds no new capability. A scope decision is not applicable. See the contribution scope.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the application service owns path checks, and they run first. The provider owns the launch and its rejections.
  • Contribution scope fit and linked maintainer decision: a bug fix within existing limits. No maintainer decision is needed.
  • CLI and MCP/tool-catalog contract: no schema or catalog change. A non-executable file now gives invalid_request instead of execution_failure. Both codes already exist.
  • Provider, bridge, target-format, or platform compatibility: tested on Linux. Windows and macOS were not run. The X_OK check is skipped on Windows.
  • Evidence, artifact, provenance, or reconstruction contract: no change. Earlier Evidence stays retained after a failed launch. I checked this over MCP.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the launch is unchanged. Cleanup still runs through the existing path. No stray child was left after my failed launches.
  • 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): none.

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.

The only new file calls are stat and access on the path the caller chose.

Evidence and regression coverage

The evidence is executed on Linux. It is not source-derived.

  • Tests added or updated: two tests in tests/acceptance/applications/electronInvalidPaths.test.ts, and eleven in the new tests/boundary/process/electronLaunchRejections.test.ts. The first two are unchanged. One covers a mode 644 file through CLI and MCP. The other covers an executable that exits at once, through CLI and MCP. It checks that the server survives. It checks that binary_session works. It checks that get_evidence_bundle returns the same Evidence id. The new file runs the built provider in a child process. It checks that an unrelated rejection still ends the process. It checks that the listener is gone after a launch fails or works. More cases test two launches at once.
  • Base reproduction or other evidence: on main, the exit 0 script ended the MCP server. The client saw Connection closed. The server printed Error: Process failed to launch! from electron.js:247. The sleeping script ended the CLI after about 61 s with TimeoutError from progress.js:86. The new tests fail on main under Node 22, 24 and 26.
  • User-visible CLI/MCP output (if applicable): see below.
  • Remaining proof gaps: no Windows run, no macOS run, no real Electron launch. The new tests run in a child process, because the Vitest worker registers its own unhandledRejection listener. Most use a fake launch. Two use a real Playwright launch of a script that exits at once. The overlapping cases use fake launches only.

Output after the fix, for the mode 644 text file:

{"error":"Electron analysis failed","code":"invalid_request","details":{"operation":"capture_electron_scenario","issues":[{"path":["executable_path"],"reason":"invalid_value","message":"executable_path <file> is not an executable file: EACCES: permission denied, access '<file>'"}]}}

For the script that exits at once, the exit code is 1 and the code is execution_failure. The diagnostics say Process failed to launch!. The MCP server stays up.

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 test:focused -- tests/acceptance/applications/electronInvalidPaths.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts tests/acceptance/applications/electronBlankPathCli.test.ts tests/boundary/mcp/electronMcp.test.ts tests/boundary/process/electronLaunchRejections.test.ts on Node 22.23.1, 24.18.0 and 26.11.1: 5 files and 25 tests passed on each.
  • The same command on unfixed main, on all three Node versions: 2 of the 3 tests in the new file failed.
  • I broke the fix four ways and ran the new file against each. Skipping the one-turn wait failed 1 test. Never removing the listener failed 9. Skipping the shared record of absorbed errors failed 2. Dropping every held rejection, which is the old behavior, failed 3.
  • npm run test:focused on the 22 test files with "electron" in the name, on Node 24: 342 tests passed.
  • npm run check:fast on Node 24: passed.
  • npm run verify:test-discovery: all 1039 test files found once.
  • oxfmt --check on the four changed files: passed.
  • Manual CLI and MCP runs on the built tree, before and after, with five files. They were a .har, a .txt, a script that exits, a mode 755 text file and a script that sleeps. After the fix, none ended the process. After the revision I reran three of them through the CLI. They were the script that exits at once, the mode 644 file, and a script that sleeps 300 s. The last one hits the real 60 s timeout. None ended the process. I did not rerun the MCP checks on the revised code.

Not run: the full suite, npm run check:pr, npm run docs:check, npm run verify:package, Windows, macOS, and a real Electron launch.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. On Linux, a non-executable file used to give execution_failure. It now gives invalid_request.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: a failed launch no longer ends the process. Playwright leaves extra errors behind, and the launch now drops them. Every other rejection still does. That includes an unrelated Playwright one. The match needs a Playwright path in the stack, and the launch error must contain the orphan's message. If Playwright changes either, the old crash comes back. It does not hide new bugs. Two captures at once share one record of absorbed errors, so neither raises the other's. One gap remains. Say an unrelated Playwright error has the same message as the launch failure. If it lands in the same window, it is dropped too.

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.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

An executable_path that runs but never prints the inspector line made
Playwright's electron.launch() leave three waits unawaited. They rejected
unhandled and Node ended the CLI or the MCP server (morluto#2269).

Check the resolved executable_path is a regular file, and on non-Windows
hosts that it passes X_OK, before any launch. Wrap only the launch call
in a scoped unhandledRejection listener that absorbs rejections whose
stack is in playwright-core/lib and re-throws anything else.

Tested on Linux with Node 22.23.1, 24.18.0 and 26.11.1.

Refs morluto#2269

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
@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 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

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

Summary

The PR checks executable_path before launching Electron and contains Playwright’s extra launch rejections so failed captures can return typed errors.

  • Electron requests reject paths that cannot be launched.
  • Failed Electron launches return typed errors without stopping the server.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Capture request] --> B[Resolve paths]
  B --> C{Regular executable file?}
  C -->|No| D[Return invalid_request]
  C -->|Yes| E[Launch Electron with shared rejection listener]
  E --> F{Launch settles}
  F -->|Failure| G[Absorb held errors matching launch failure]
  F -->|Success| H[Do not absorb held errors]
  G --> I[Remove completed launch scope]
  H --> I
  I --> J[Remove listener after last launch]
  J --> K[Preserve unrelated error reporting]
  G --> L[Return execution_failure]
Loading

Reviews (12) · Last reviewed commit: "chore: resolve main conflicts with share..." · Reviewed by Greptile

The listener around the launch dropped every rejection with a
playwright-core stack, so an unrelated Playwright failure during the
launch window would vanish. Hold those rejections instead. When the
launch settles, drop only the ones whose message is part of the launch's
own error (the orphans of a failed launch). Raise every other one again
through the unhandledRejection path, so the process still fails. A launch
that succeeds raises all of them. Rejections without a Playwright stack
still fail at once.

One setImmediate turn before the decision lets rejections queued by the
settling tick arrive first. It is a single turn, not a timer. A shared
set of absorbed errors stops overlapping launches from raising each
other's orphans. The listener is removed on every path.

Add child-process tests that drive the built provider through its launch
seam, since Vitest's worker has its own unhandledRejection listener.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
@CassieFox23

Copy link
Copy Markdown
Contributor Author

Thanks, Greptile. Both points were right.

  1. The listener now holds each stray Playwright error. When the launch ends, it drops only the ones that repeat the launch's own error. It raises the rest again, so the process still fails. Other rejections still fail at once.

  2. New child-process tests are in tests/boundary/process/electronLaunchRejections.test.ts. An unrelated rejection still ends the process. The listener count returns to its start after success and failure. Four deliberate breaks each fail a test.

I can't fix it at the source. The code that makes them is not ours.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@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 earlier implementation suppressed errors by Playwright stack text alone. The current path absorbs a rejection only when its message repeats a captured launch failure; unrelated errors are forwarded. The shared listener records each rejected promise with the launch scopes that were active when it arrived, and forwards through external listeners without entering its own holding map again. Existing process-boundary regressions retain unrelated-error and real failing-launch cases.

Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection.

  1. thread 1

Per-launch listeners replayed the same rejected promises into one another, multiplying retained errors. There is now one listener and one promise-indexed holding map. Each event snapshots its candidate launch owners; a settling scope consumes its own failures or releases its candidacy, and an unmatched rejection is forwarded once after its candidates settle. The regression source checks one listener and exactly three original orphan events across a failure overlapping four successful launches.

Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection.

  1. thread 1

The fake application proves launch settlement but deliberately has no owned process PID, so capture success was the wrong assertion. The regression now expects capture refusal for those four successful launches and specifically checks process_ownership_unavailable; the failing launch retains its alpha failure cause. The one-listener and exactly-three-original-orphan assertions remain, so rejection ownership coverage is preserved rather than weakened.

Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection.

@morluto morluto added bug Something isn't working security Target-execution safety, isolation, authority, and contamination handling area: runtime Process capture and runtime observation area: domain Domain logic, errors, and pure functions area: providers Provider and capability discovery, including provider proposal triage P1: high High priority issue for current or next iteration labels Oct 13, 2026
dakjdakd and others added 5 commits October 14, 2026 01:18
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@CassieFox23

Copy link
Copy Markdown
Contributor Author

TL;DR: morluto's fixes work. On Linux, the five test files pass on Node 22, 24 and 26, a bad executable_path still gives a typed error, and the MCP server stays up. Greptile's macOS timeout note was right, and e1579ec already fixes it.

Results (Linux, head 3ca7237)

The head moved from 2b8b0f1 to 3ca7237 while I tested. No PR file changed. Every check gave the same result on both.

Check Node 22 Node 24 Node 26
Five PR test files (29 tests) pass pass pass
CLI: .har and .txt file without the exec bit gives invalid_request pass pass pass
CLI: script that exits at once gives execution_failure pass pass pass
MCP over stdio: both cases, server alive, Evidence kept pass pass pass
60 second timeout script, CLI and MCP not run pass not run

Greptile: "macOS checks time out"

It was valid. At a69f3ca the test child had 60 seconds and Vitest had 30. A cold Swift build can take 88 seconds. Commit e1579ec raised them to 150 and 180 seconds.

I faked a 35 second setup step on Linux. The old file failed at 30 seconds. The current file passed. So I add no change. Each of the 13 tests takes under 0.7 seconds on Linux.

Not run

  • macOS and Windows. I have no Mac, so only the fake delay checks the fix.
  • A real Electron launch.
  • CI for 3ca7237 was still queued. On 2b8b0f1, Static checks and Build package passed before the next push cancelled the run.

Thanks, morluto, for these fixes

  • 31f2761: all launches share one listener. Each stray error is held once.
  • 44b5ac5: other listeners get a stray error once, not twice.
  • ab090f3 and c296182: the new test now expects what its fake app can do.
  • e1579ec: longer deadlines for a cold macOS build.
Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- \
  tests/acceptance/applications/electronInvalidPaths.test.ts \
  src/browser/PlaywrightElectronActiveProvider.test.ts \
  tests/acceptance/applications/electronBlankPathCli.test.ts \
  tests/boundary/mcp/electronMcp.test.ts \
  tests/boundary/process/electronLaunchRejections.test.ts
node scripts/rea.mjs capture-electron-scenario input.json --format json

The input file holds executable_path, application_path and actions: []. The four executable_path files were capture.har and not-an-executable.txt (mode 644), exit0.sh (mode 755, exit 0) and sleep300.sh (mode 755, sleep 300).

For the MCP check, a stdio client called binary_session, analyze_javascript_application and get_evidence_bundle. Then it called capture_electron_scenario, checked that the server process was alive, and called the first and third tools again.

For the slow setup, I ran the test file with systemProcessOwnershipHost.prepare made to wait 35 seconds, and picked one test with -t.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 3ca7237
  • First head tested: 2b8b0f1
  • Base: a9195c3
  • The box was shared with other test runs.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

The test that runs an executable which exits at once builds the Swift
ownership helper twice on macOS: in the CLI process, and again in the
MCP server process on its first tool call that prepares. A cold Swift
cache can spend up to 120 seconds on a build. The test had only the
30 second default.

Give the test 180 seconds, as e1579ec did for
electronLaunchRejections.test.ts and 65a809a did for
webSourceLocationCli.test.ts. cli.run has no deadline of its own, so
it needs no timeoutMs.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
@CassieFox23

Copy link
Copy Markdown
Contributor Author

Follow-up on the macOS timeout note. The early-exit test in electronInvalidPaths.test.ts also builds the Swift ownership helper on macOS. It builds it twice: in the CLI process, then in the MCP server process. The test had the 30 second default. The patch gives it 180 seconds, as e1579ec did for the launch test.

Checked on Linux only. The file passes on Node 22, 24 and 26. A fake 35 second setup step fails the old test and passes the new one. The MCP client still limits each call to 60 seconds. This file cannot change that.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

CI follow-up pushed in 6ab231c. The failed source tests used a PowerPC installation fixture without the required application.java.min; the failed shard inherited GITHUB_STEP_SUMMARY, diverting fixture report output from stdout. The fixes declare the Java bounds and isolate fixture publication/group-classification environment. All 18 affected tests pass locally with CI-like environment variables set; check:fast passes. Current-head hosted CI is still being monitored; no checks or assertions were disabled.

@morluto
morluto merged commit 97aff28 into morluto:main Oct 13, 2026
30 checks passed
@morluto morluto added the provider: electron Analysis provider / engine: electron label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: providers Provider and capability discovery, including provider proposal triage area: runtime Process capture and runtime observation bug Something isn't working P1: high High priority issue for current or next iteration provider: electron Analysis provider / engine: electron security Target-execution safety, isolation, authority, and contamination handling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] capture_electron_scenario reports every unresolvable path as application_path/invalid_format and drops the cause

3 participants