Skip to content

fix(frida)!: require an absolute script path over MCP - #11580

Merged
morluto merged 5 commits into
mainfrom
fix/frida-script-absolute-path
Nov 16, 2026
Merged

morluto merged 5 commits into
mainfrom
fix/frida-script-absolute-path

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #11506. MCP load_frida_script and instrument_with_frida admitted a relative script path, which the server read against its own working directory, not the caller's. Both now require an absolute path, matching the sibling local-file contracts (#11079 / #11508). The CLI keeps accepting a relative --script-file and resolves it against the caller's directory.

Problem and expected behavior

Trigger: load_frida_script {source_kind: "file", path: "script.js"} over MCP read <server cwd>/script.js. Expected: a relative path is refused as invalid input before any session work; the CLI, which runs in the caller's directory, resolves it.

Change and scope

  • src/contracts/fridaToolContracts.ts: the script path of both contracts uses absoluteLocalPathStringSchema.
  • src/cli/fridaCommands.ts: instrument-with-frida declares callerPaths: ["path"], so the shared CLI projection resolves --script-file with absoluteCallerPath before the contract admits it.
  • Not included: program (spawn target). On a remote device it may name a path on that device, so it stays as is (per the issue).

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: The tool contracts own path admission; the CLI projection's callerPaths owns caller-relative resolution. No downstream repair.
  • Contribution scope fit and linked maintainer decision: Ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: Advertised path schemas gain the absolute-path pattern (breaking for MCP callers that sent relative paths). verify:advertised-schemas -- --update-summary produced no summary change.
  • Provider, bridge, target-format, or platform compatibility: None.
  • Evidence, artifact, provenance, or reconstruction contract: source_path is the path read; from the CLI with a relative spelling it is now the resolved absolute path.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): A refused path never starts or loads anything.
  • 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): Catalog regenerates from the contract; no committed generated file changed.

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: tests/boundary/mcp/fridaLifecycleMcp.test.ts: both MCP tools refuse a relative path with invalid_request at ["path"] and load nothing. tests/boundary/cli/fridaCli.test.ts: the script-identity test passes one file as a path relative to the CLI's cwd and asserts the bytes loaded and an absolute source_path.
  • Base reproduction or other evidence: With the two production files restored from main, the three new/changed assertions fail (MCP tools accept the relative path; CLI source_path is relative).
  • User-visible CLI/MCP output (if applicable): MCP: {"code":"invalid_request","details":{"operation":"load_frida_script","issues":[{"path":["path"],"reason":"invalid_format",...}]}}.
  • Remaining proof gaps: Simulated Frida bindings only; no real Frida device run (the change is input admission before any provider call).

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

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/boundary/cli/fridaCli.test.ts tests/boundary/mcp/fridaLifecycleMcp.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts — 3 files, 92 passed.
  • Same two Frida files against main's production code — 3 failed (the new assertions), 64 passed.
  • npm run verify:advertised-schemas -- --update-summary — passed, summary unchanged.
  • npm run docs:check — passed. npm run check:fast — passed. npx oxfmt --check on changed files — clean. Pre-push hook ran.
  • Local gate (merger) refused the previous head: src/contracts/fridaToolContracts.test.ts still used a relative script.js. Fixed in f5ecffe (absolute path for accepted inputs); b48624b drops a contract-level relative-path check that the MCP lifecycle test already covers. npm run test:local -- src/contracts/fridaToolContracts.test.ts: 6 passed. The same gate run's tests/acceptance/applications/bundleResourceRootCliMcp.test.ts failures also fail on main (subject shape after feat(evidence)!: name the Evidence subject by its target identity (format revision 2) #11416) and are not from this PR.

Compatibility, safety, and release

  • Breaking changes or migration steps: BREAKING CHANGE: MCP load_frida_script and instrument_with_frida refuse a relative script path (previously read against the server's cwd). Migration: send an absolute path. CLI --script-file still accepts a relative path. A compatibility path cannot be kept: the server cannot know the caller's directory.
  • Real Hopper/Ghidra, browser, or OS coverage: None needed; macOS local tests.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Removes reads of a file the caller did not select.

Author readiness

Human owner:

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

`load_frida_script` and `instrument_with_frida` admitted a relative script
`path`, which the MCP server read against its own working directory rather
than the caller's. Both contracts now admit only an absolute local path, as
the pcap and debugger contracts do. The `instrument-with-frida` CLI resolves a
relative `--script-file` against its working directory before the contract
sees it. `program` is unchanged: on a remote device it may name a path there.

BREAKING CHANGE: MCP `load_frida_script` and `instrument_with_frida` refuse a
relative script `path` with `invalid_request`; send an absolute path. CLI
`--script-file` still accepts a relative path, and Evidence `source_path` is
now the resolved absolute path.

Fixes #11506
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T23:16:09.696712Z
We couldn’t complete this review. Comment @codex review to try again.
840e7bb PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; the removed test duplicates stronger MCP checks.

Summary

The PR requires absolute script paths over MCP while keeping caller-relative --script-file paths working in the CLI. The latest change removes a weaker, duplicate contract test.

  • Frida script files use absolute paths at the shared tool boundary.

Reviews (5) · Last reviewed commit: "test(frida): drop the contract-level rel..." · Reviewed by Greptile

Comment thread tests/boundary/cli/fridaCli.test.ts Resolved
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Greptile Issue 1 (relative-path fixture on Windows drives): valid, fixed in 18ad54e. The CLI test now checks that the fixture's spelling is relative (expect(isAbsolute(relativeSpelling)).toBe(false)) on POSIX, where it always can be. On Windows the temporary directory can sit on another drive than the checkout; that case has no relative spelling, so the test passes the absolute path there and says so, rather than silently passing an absolute path as "relative". Windows relative resolution itself is the shared absoluteCallerPath owner's (win32 resolve), covered by its own tests. Issue 2 was answered on its thread (5009ac7).

@greptileai review

The load and instrument contracts admit only an absolute script path, so
the contract test's relative script.js no longer parsed. Use a resolved
path for the accepted inputs and refuse the relative spelling in its own
test.
@morluto
morluto merged commit 9699ce9 into main Nov 16, 2026
7 of 9 checks passed
@morluto
morluto deleted the fix/frida-script-absolute-path branch November 16, 2026 00:54
@morluto morluto added area: mcp MCP server, transport, and tool registration bug Something isn't working provider: frida Analysis provider / engine: frida labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration bug Something isn't working provider: frida Analysis provider / engine: frida

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frida script file contracts admit relative paths over MCP

1 participant