Repository navigation
feat: add Frida instrumentation support - #1359
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Review of 52e77f1: request changes before merge — cancellation and cleanup ownership have gaps.
Local validation: build passed; the existing service/manager/MCP subset passed 12 tests. The additional probes above used injected production-boundary ports/handles; I am not claiming real-Frida verification. CI/approval is still separate from these findings. |
|
TL;DR: I ran this PR against real Frida. Most of it works. Both P1s reproduce on real Frida. I also found a new close bug. This is the first real-Frida run of this PR. As far as I know. What ran
Results
P1: cancelled requests still start work I called the built service with The CLI shows a near cousin. I sent SIGINT while a script loaded. The target was still resumed with the hook live. The hook fired once before close. The CLI then said "cancelled", with cleanup "complete". On MCP, I sent a cancel right after P1: cleanup failure is swallowed A top-level A script that crashes the target does hit it. New: close fails after the target exits Say a spawned target exits before close. Then close fails with "Script is destroyed". It fails again on every retry. The session stays in the list. So the CLI exits 1 for any short-lived spawn. So the same error is dropped in one path. In another it blocks close for good. P2: Evidence loses the target choice I ran a real spawn with arguments. Not run
The head will change after your fixes. I'm happy to rerun this then. Edit: Rerun on Thanks, dandgabr, for the PR. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Reply to @morluto's review comment: all three findings are addressed in commit
Verification on this commit: |
|
Reply to @CassieFox23's real-Frida report: the reported issues are addressed in commit
Verification on this commit: |
|
TL;DR: I reran this on real Frida at Edit: I retested at b2d2b8b in my new comment. The Evidence quirk in this comment is fixed there. Earlier findings, now
Cancel races I cancelled at attach, load, resume and observation. I did each 3 times. All 12 runs cleaned up. Each session left the list. The Frida agent left each target. A CLI Ctrl+C sweep agreed. Before, a cancel during load let one hooked call through. Now none do. One small quirk Say you cancel before resume. The Evidence says the target is Is that the plan for spawn mode? A cancelled spawn keeps running. I'm only asking, not calling it a bug. Tests: the 31 Frida tests you listed pass on Node 22, 24 and 26. The six files from my first run now hold 42 tests, and those pass too. Edit: Made the two test counts clearer. Nothing else changed. Not run Edit:
Thanks, dandgabr, for the quick and careful fixes. Crash case and P2 detailCrash case: the outcome matched my first run. Load fails with "The connection is closed". Status shows no scripts. Close works. The script handle is destroyed after the crash. The new code checks for that and drops the handle. So there is nothing left to unload. The live-script unload failure is the real P1. I can't reach it on real Frida. Your unit tests cover it. P2: one-shot Evidence now has device, mode, program and argv. Cancel Evidence has them too. Cancel race detailThe races used the built service. A wrapper on the real manager fired the abort as each step began. After each run I read
"Running" means state CLI Ctrl+C sweep, 10 delays from 0.3 s to 4.5 s. All exit 130. Below 1.2 s the CLI quit before it spawned anything. From 1.2 s to 2.4 s the cancel hit script load: 0 hooked calls. At 3.0 s and 4.5 s it hit after resume: 2 and 9 hooked calls, then clean.
Tests per file
My first run used these six files, 28 tests then. Now it's 42. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
TL;DR:
All on Node 24.18.0. Turbo ran both tasks fresh, with 0 cached. My last run failed on Lint warnings. These don't fail the lane. Still, the PR adds 14. Head has 471 and base has 457. All 14 sit in files this PR touches. The list is in the fold. Still not run
New lint warnings (14)Line numbers left out. All are warnings.
One more file changed but is not in the 14. In CommandsThen I checked out Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
There was a problem hiding this comment.
Real local Frida injection works at 4e766550b31b8451121f5d98e2eed6be2ded3e42, but this head needs changes before merge. In particular, a normal successful one-shot MCP request performs the target operation and then returns an output-validation error.
Independent verification:
- Linux: Node 24.18.0, freshly installed native Frida 17.23.2, exact PR source.
build:cached,check:fast, and 42 focused tests across 6 files passed. The real verifier passed. Public CLI interception captured 7 actual native function calls with correct arguments/returns, source path/hash, unchanged executable, and successful cleanup. - Real pinned-SDK stdio MCP: all 148 tools advertised; all 9 Frida input/output schemas valid under 2020-12. Discovery and the persistent spawn→load two scripts→resume→status→unload→close workflow passed without
open_binary, and the fixture exited naturally. One-shot output validation, message provenance, target-free availability, and cancellation-ledger failures below were reproduced on both Linux and Windows. - Windows x64: work performed only in an isolated Windows verification directory. Existing supported Node 22.19.0; exact PR tarball SHA256
9f80d4b8984a2b1601d67dbb29982ae05a4b7adad47b0941747edfe647ebf524; official Frida 17.23.2 Windows N-API 8 AMD64 addon verified against GitHub's release-asset digest. Native CLI injection and real MCP persistent workflow passed. Fresh online npm installation was denied by host-networkEACCES; offline verification reused existing Windows dependencies whose 32 direct runtime versions exactly match this PR. This is not a claim that fresh online Windows installation succeeded. - Paused-spawn cancellation used real native attach/detach/resume with a timing-control seam only; the fixture actually executed after cleanup while Evidence said no resume was observed. Remote removal retry used the production adapter with a representative transient-failure seam; a real remote-server removal failure was not observed.
- Source build with Frida omitted fails at the unconditional vendor declaration import. Keepalive units were checked against pinned Frida Core 17.23.2 implementation. Remote-server/authentication and macOS workflows remain unverified.
The existing focused tests pass despite the defects, so please add regressions through the failed consumer boundaries. The stdout-corruption hypothesis was withdrawn after the real Linux probe showed valid CLI JSON, no MCP transport errors, and isolated target sockets; it is not included as a finding.
Please address the inline findings and integrate current main while preserving your existing commits/credit. Then run the relevant real workflows and CI on the exact final head; the PR currently has no recorded checks and has reported merge conflicts.
N0zoM1z0
left a comment
There was a problem hiding this comment.
Re-tested exact head b4b8f8bd855743c69bc0acade9771e6eb23269bf. Basic Frida instrumentation is usable on Linux and Windows, and the previous eight findings are addressed. Two remaining Evidence correctness issues are reproduced in the inline comments, so changes are still requested.
| Previous finding | Revised verification |
|---|---|
| One-shot required output fields | Real Linux/Windows SDK calls validate and succeed. |
| Remote lease cleanup retry | Production adapter seam keeps B's live lease after A's failed removal/retry. |
| Target-free availability | All nine tools available without open_binary; missing binding reports provider remediation and preserves MCP health. |
| Message producer identity | Real overlapping A/B scripts retain exact producer IDs and per-script load observations. |
| Cancellation partial Evidence | Real SDK cancellation is retained in the complete Evidence bundle; subsequent calls work. |
| Paused-spawn cleanup resume | Real attach/detach/resume and fixture PID marker pass; only cancellation timing is controlled. |
| Optional binding source build | Full build:cached passes with the binding absent; dedicated vendor declaration verification passes when present. |
| Keepalive units | CLI/MCP/docs consistently use the pinned producer's seconds; no remote timing claim. |
Independent verification:
- Linux Node 24.18.0, Windows Node 22.19.0, official native Frida 17.23.2 on both. Linux CLI captured eight real native function calls with exact arguments/returns, source path/digest and unchanged executable. Windows CLI returned the actual injected target PID and Frida version. Owned fixtures exited naturally; guards report clean shutdown.
- Public SDK 2.3.1 stdio MCP exposes 179 tools; all nine Frida input/output schemas validate as 2020-12. Device/process discovery and persistent spawn→load two scripts→resume→status→unload→close, one-shot instrumentation, cancellation/export and recovery pass on both platforms, with the Windows initialization qualification below.
- 47 focused tests across six files pass. Complete typechecking (the pinned native compiler’s
--singleThreadedmode), lint/module boundaries, Knip and docs checks pass under the unchanged 2,304 MiB family guard. Earlier default/serial compiler runs reached that guard and remain recorded. - The source-built package's 1,122 compiled files match the reviewed worktree by SHA-256. Windows used a separate fresh offline
npm ci(185 packages), with lifecycle scripts disabled and verified official native assets extracted explicitly. Linux reused matching locked common dependencies and freshly installed the optional binding. The ignored Windows helper was reused from source-equivalent main. This does not verify ordinary online install lifecycle execution or a fresh Windows helper compilation.
Windows qualification: the default 60-second SDK initialization failed once before the catalog or any Frida call. An initialization-only 120-second option then passed; tool deadlines and receive buffers were unchanged. That successful profiled connection took 58.97 seconds. Actual Flameox 0.2.9 rank_cpu_hotspots analysis of the complete server-lifetime capture reports 34,150 samples, with 10,887 hits in internalModuleStat and 6,053 in lstat. The returned hotspot page covers 100/1,146 observed rows and has additional provider truncation. This is a module-resolution investigation lead, not initialization-only attribution, a causal regression claim, or memory/leak evidence; no latest-main control is claimed.
Real remote-server failure/recovery and macOS remain unverified. The pending exact-head CI workflow run 38114739677 is now approved; results are pending. The two inline findings require fixes before merge.
|
The newly approved exact-head CI run has a concrete failure at The failing assertion is the CLI help-description check, despite the test's short-alias title. Its received list contains 20 Frida option lines without descriptions, including This is additional CI evidence beyond the previously reported 47 focused tests and the two current inline findings. The dependent coverage aggregate also fails because a shard failed; it is not a second independently reproduced product defect. No blind rerun was requested. |
…-instrumentation-upstream # Conflicts: # docs/testing.md # src/server/createServer.ts
Follow-up outside the Frida scopeThe full local Suggested follow-up: make the assertion compare the observed paths independent of order if callback order is not part of the contract. If order is required, define and test that ordering at the owning filesystem boundary instead. This was deliberately left unchanged here because it is outside the Frida feature scope; changing shared filesystem behavior or its test expectations without a focused review could introduce unrelated regressions. |
|
TL;DR: I reran this on real Frida at b2d2b8b. The Evidence quirk I asked about is fixed: a cancelled spawn now says it was resumed. Everything fixed at 4e76655 is still fixed, and the Frida tests pass on Node 22, 24 and 26. My last run was in this comment. My five earlier findings, now
The Evidence quirk is fixed Before, a cancel before resume said What the new commits added
Tests The five Frida test files now hold 41 tests, up from 31. The author added tests. With Edit: I ran three of these on main 9d6651e (#4131) after the merge. Results are in my new comment. Still not run: a failing unload on a live script, attach to a process I did not start, macOS, Windows, Android and CI. Still not run
Thanks, dandgabr, for the quick fixes. Cancel race detailThe races used the built service with the real manager wrapped. The abort fired as each step began. The Before cleanup column shows
Every run: CLI Ctrl+C sweep, 10 delays from 0.3 s to 4.5 s. All exit 130. At 0.3 s and 0.6 s the CLI quit before it spawned anything. From 0.9 s to 2.1 s the cancel hit script load: 0 hooked calls. At 2.4 s, 3.0 s and 4.5 s it hit after resume: 1, 4 and 11 hooked calls. The cut-offs sit earlier than at 4e76655 (1.2 s then). The box was shared, so I read that as load, not a code change. That is unverified. Tests per file
Timing came from a shared box. At the end the load average was 4.1, 11.1 and 7.3 over 1, 5 and 15 minutes. It counts tasks waiting for a CPU, and the box has 24 threads. The Frida files took 9.2, 7.8 and 7.1 seconds on Node 22, 24 and 26. CommandsThe live runs used the built Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Regarding comment 6106513972: the CLI help description fix is included in ancestor commit |
|
Regarding comment 6113265492: the described crash path reports a closed connection, no remaining scripts, and a destroyed script handle; |
…ida-instrumentation-upstream
Keep failed startup session and spawn handles owned until detach, resume, and remote lease cleanup complete. Serialize retries and release each remote reference once. Await CLI provider cleanup while preserving the primary failure and any completed observations. Add regressions for retained startup resources, concurrent cleanup, shared remote leases, and CLI cleanup outcomes. Validation: 41 focused tests pass on the PR head and its latest-main integration; serial static and docs checks pass. Real Linux Frida 17.23.2 workflows and the native spawn/controlled-failure cleanup probe pass. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
Integrate main through 58fb372 while preserving the contributor's feature commits and startup cleanup fix. Resolve MCP bootstrap initialization by retaining both the Frida manager and the WASM module descriptor introduced on main. Verification: 84 focused tests across 12 files, all eight serial static tasks, generated documentation, and architecture guards passed. Real Linux Frida 17.23.2 Node spawn and ten CLI/MCP workflows passed, including native hooks, persistent sessions, cancellation Evidence and authenticated remote sessions. Local runs were limited to two CPUs and an 8 GiB memory ceiling; the full static run peaked at approximately 2 GiB.
|
TL;DR: This PR merged, so I reran my open items on main. The remote lane works on a real frida-server, with a token and TLS, and no secret shows up in the results. A flood of 60,000 messages keeps the newest ones. This comment is a record. The PR merged as 4a4ae9b (#1359). My last comment tested b2d2b8b and listed five Not run items. I ran three of them on main at 9d6651e (#4131), plus the full
How the flood ended: the first kept message was number 32,452 (counting from 0), and the last was the "done" marker. The newest messages are the ones kept. The target kept running, and the cleanup error was null. The source caps one session's capture at 16 MiB. I read that in The remote auth checks used a small script of mine, not a repo test. It calls the built service. It sees only the returned results. I did not search the server or client logs for the token. Still not run
Commands# frida-server 17.23.2 linux-x86_64 from the Frida release page, unpacked in /tmp
# sha256 matched the digest GitHub lists for the file
frida-server --listen 127.0.0.1:27142
frida-server --listen 127.0.0.1:27143 --certificate=both.pem --token=<test token> --directory=<tmp dir>
# the target is a Node process I started: node -e "setTimeout(()=>{},1200000)"
npm run verify:frida -- --address 127.0.0.1:27142 --pid <target pid> # 3 runs
npm run verify:frida # 3 runs
npm run verify:frida:bindings
npm run test:focused -- src/application/frida/FridaInstrumentationManager.test.ts \
src/application/frida/FridaInstrumentationService.test.ts \
src/contracts/fridaToolContracts.test.ts tests/boundary/cli/fridaCli.test.ts \
tests/boundary/mcp/fridaMcp.test.ts tests/boundary/filesystem/productCatalog.test.ts \
tests/boundary/cli/cliOptionAliases.test.ts
npm run check:ci && npm run check
# my own scripts: remote-auth.mjs (token, TLS, wrong and missing token), flood.mjs (60,000 send() calls of 512 bytes)The TLS certificate was self-signed for 127.0.0.1 and made with Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
Summary
Verification
npm run build:cachednpm run test:focused -- src/application/frida/FridaInstrumentationManager.test.ts src/application/frida/FridaInstrumentationService.test.ts src/contracts/fridaToolContracts.test.ts tests/boundary/cli/fridaCli.test.ts tests/boundary/mcp/fridaMcp.test.ts tests/boundary/cli/productCatalog.test.tsnpm run check:cinpm run docs:checkReal Frida target verification was not run; it requires a configured Linux host and reachable Frida server.