Repository navigation
fix(frida): reject an unreadable script file before starting a session - #2211
Conversation
The shared instrument_with_frida workflow started the Frida session, which attaches or spawns the target, before the provider read a file script source. A missing script file then failed loadScript with a bare invalid_request, and session cleanup resumed the paused spawn, so the target ran without instrumentation. Check that the selected file is a readable regular file first and report the path, or access_denied for EACCES/EPERM, before any device effect. Fixes #2209 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0ed313d40
ℹ️ 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".
| > | ||
| > { | ||
| // Reject an unreadable script file before any attach or spawn effect. | ||
| const unreadable = await unreadableScriptFile(input.source); |
There was a problem hiding this comment.
Check cancellation before validating the script file
When instrument receives an already-aborted CLI/MCP signal together with a missing, unreadable, or non-regular file source, this preflight runs before #startSession's cancellation guard and returns an input/access-denied error rather than AnalysisCancelledError. It also makes cancellation wait for filesystem I/O. Check the signal before this preflight (and let cancellation win if it arrives during it) so file sources retain the existing cancellation semantics.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4046536 (with a small extraction in 6116a9d). instrument now checks the signal before the script-file preflight and again after it, so an already-aborted request returns AnalysisCancelledError without touching the filesystem, and an abort that arrives during the check also wins over the input/access-denied error. New test reports cancellation before checking a file script source uses an aborted signal with a missing file and fails without the change.
An already-aborted request with an unreadable file source returned the input or access-denied error instead of AnalysisCancelledError. Check the signal before the script file preflight and again after it, so file sources keep the existing cancellation semantics. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
FridaInstrumentationService.instrument, the shared CLI (instrument-with-frida) and MCP (instrument_with_frida) one-shot workflow, starts the Frida session before the provider reads afilescript source. If the file is missing:loadScriptfails;So the target program ran without instrumentation, and the caller got a bare
invalid_requestwith no issue.The workflow now checks that a
filesource is a readable regular file before#startSession:invalid_requestwith aninvalid_valueissue at["path"](Cannot read Frida script file <path>: no file exists there./it is not a regular file.);access_denied.Inline sources are unchanged. The provider still reads the file when loading, so a file that changes between the check and the load is handled as before.
Fixes #2209
Before / after (macOS, Frida via rea-agents;
targetis a compiled program that appends to a marker file when it runs)Validation
src/application/frida/FridaInstrumentationService.test.ts) cover a missing file and a directory. They assert the issue and that the provider'sstartSessionis never called. They fail on main and pass with this change; all Frida tests pass (64 across the CLI, MCP, manager, service and contract suites).npm run lintpasses.npm test: 9246 passed, 14 failed in 7 files. These are the same environmental files that fail on cleanorigin/mainon this host: Hopper not installed, Command Line Tools only (ibtool),hdiutil, and inspector target-location cases.Unable to access process … from the current user account). Instrumentation itself was not exercised here, only the pre-start rejection and the absence of the target run.Remaining
The separate MCP
load_frida_scriptoperation still reports a file read failure asAnalysisInputError("load_frida_script")without an issue naming the path, fromFridaInstrumentationManager.#loadScript. There the caller has already started the session explicitly, so no side effect is introduced by REA. I left it out to keep this change to the pre-start ordering.🤖 Generated with Claude Code