Skip to content

feat: add Frida instrumentation support - #1359

Merged
N0zoM1z0 merged 15 commits into
morluto:mainfrom
dandgabr:feat/frida-instrumentation-upstream
Oct 12, 2026
Merged

N0zoM1z0 merged 15 commits into
morluto:mainfrom
dandgabr:feat/frida-instrumentation-upstream

Conversation

@dandgabr

@dandgabr dandgabr commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Frida device and process discovery, attach/spawn sessions, script loading, message capture, and cleanup through the CLI and MCP.
  • Keep Frida bindings optional and lazily loaded; do not install Frida Server on targets.
  • Record bounded instrumentation evidence with source digests while excluding remote authentication values.
  • Document supported behavior and add a real-target verification script.

Verification

  • npm run build:cached
  • 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/cli/productCatalog.test.ts
  • npm run check:ci
  • npm run docs:check

Real Frida target verification was not run; it requires a configured Linux host and reachable Frida server.

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

@morluto

morluto commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Review of 52e77f1: request changes before merge — cancellation and cleanup ownership have gaps.

  1. P1: already-cancelled requests still start instrumentation. src/application/frida/FridaInstrumentationService.ts:37-40 calls provider.startSession before checking the signal. A production-service fault-injection probe with AbortSignal.abort() recorded starts=1, closes=1 and then returned AnalysisCancelledError. A spawn can therefore occur despite cancellation predating the operation; the cleanup policy may then resume that target. Check prior cancellation before any provider effects, and check it between later awaited workflow stages.
  2. P1: failed script cleanup is silently discarded. src/frida/FridaInstrumentationManager.ts:361-366 catches and ignores an unload failure after load() rejects. My injected native-script probe returned cleanupIncomplete=false, with status.scripts=[], despite unload failing. Closing the session never retried that script handle. Preserve/report the cleanup failure and keep ownership of the script until unloading or parent-session cleanup establishes that it is released.
  3. P2: ephemeral Evidence loses non-secret target selection. FridaInstrumentationService.ts:197-217,246-257 records only session_id in parameters and drops device/remote endpoint identity, mode and argv from the observation. Once the ephemeral session is closed, its UUID cannot recover that context. Preserve caller-selected non-authentication fields; continue excluding authentication credentials.

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.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Local device only. No frida-server.
  • Target: a tiny C program I built with clang.
  • I attached to no other process.

Results

  • Focused tests: 28 of 28 pass, in 6 files.
  • list-frida-devices works. It shows local, socket and barebone.
  • list-frida-processes works. It found 142 local processes.
  • CLI spawn works. The hook replaced a return value.
  • CLI attach works with the verifier's marker script.
  • MCP works too. I ran the full flow.
  • That flow was start, load, resume, status and close.
  • Messages came back as expected.
  • After close, the Frida agent left the target.
  • The target kept running, unhooked.

scripts/verify-frida.mjs could not run here. It needs --address. It has no local-device path. Against 127.0.0.1:27042 it exits 1. There is no server to connect to.

P1: cancelled requests still start work

I called the built service with AbortSignal.abort(). The target still spawned. It was then resumed and ran to the end. The result was AnalysisCancelledError. I used the service API. I did not use the CLI or MCP.

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 start_frida_session. The target still spawned and ran. That is the path the docs describe.

P1: cleanup failure is swallowed

A top-level throw does not hit this path. Real Frida resolves load(). The error comes back as a message.

A script that crashes the target does hit it. load() rejects with "The connection is closed". With the raw binding, unload() then rejects. It says "Script is destroyed". REA drops that. Status then showed scripts: []. Close then reports success.

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. parameters held only session_id. The result had the program path, PID and state. It had no device_id, mode or argv.

Not run

  • Remote devices or a frida-server.
  • Android, iOS, macOS or Windows.
  • Attach to any process I did not start.

The head will change after your fixes. I'm happy to rerun this then.

Edit: Rerun on 4e766550 is done, in a new comment. Four of the five findings are fixed.

Thanks, dandgabr, for the PR.

Test setup
  • Box: Nobara 44 Linux, x86_64
  • Kernel: 7.2.9. ptrace_scope was 0.
  • Node: 24.18.0
  • Head: 52e77f1a4
  • Other: Frida Node binding 17.23.2, from npm ci

🤖 Generated with Claude Code (Opus 5.5) 🦊

@dandgabr

Copy link
Copy Markdown
Contributor Author

Reply to @morluto's review comment: all three findings are addressed in commit 4e766550.

  1. Cancellation before/within the workflow: the service checks an already-aborted signal before calling the provider, then checks again between session start, script load, resume, and observation. Cancellation closes the acquired session and returns partial Evidence, including cleanup status.
  2. Script cleanup ownership: the manager records each native script handle before loading it, retains the handle if unload fails, and retries cleanup. A destroyed script or confirmed parent-session detach releases ownership. A paused spawn is not resumed while a script remains active; failed resume and remote cleanup retain their pending state and device reference for retry.
  3. Evidence target selection: Evidence now includes device, remote endpoint (without token/certificate), mode, PID or program, and argv.

Verification on this commit: npm run check:fast passed; the focused Frida contract, service, CLI, and MCP suite passed (31 tests); and npm run verify:frida passed against a short-lived local Node spawn (script_message_observed: true, cleanup_error: null). The verifier's remote mode and other platforms were not exercised.

@dandgabr

Copy link
Copy Markdown
Contributor Author

Reply to @CassieFox23's real-Frida report: the reported issues are addressed in commit 4e766550.

  • npm run verify:frida now defaults to a local Node fixture spawned by the verifier, so it no longer requires --address or a Frida server. The optional --address HOST:PORT --pid PID path remains for an explicitly selected remote target.
  • Pre-cancelled operations make no provider calls. During cancellation, REA waits for the current native call, closes the session, and returns partial Evidence. It records whether resume was observed, whether instrumentation cleanup completed, and that final target liveness is unknown.
  • Script handles survive failed unload attempts for cleanup retries. isDestroyed and confirmed session detach release handles when the target exits. Close detaches before resuming a paused spawn; it leaves the target paused if scripts and session cleanup both fail. Failed resume and remote cleanup remain retryable, with remote device references retained until cleanup finishes.
  • Evidence preserves target selection and spawn arguments while omitting authentication values.

Verification on this commit: npm run check:fast passed; 31 focused contract/service/CLI/MCP tests passed; and the real-provider verifier passed on Linux with its local Node spawn fixture (script_message_observed: true, cleanup_error: null). I did not run the remote lane or test other operating systems/providers.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I reran this on real Frida at 4e766550. Four of the five things I flagged are fixed. The fifth looks the same on real Frida, and I can't test it here. Cancel now cleans up at every step. One small Evidence quirk is left.

Edit: I retested at b2d2b8b in my new comment. The Evidence quirk in this comment is fixed there.

Earlier findings, now

Finding at 52e77f1a4 At 4e766550
P1: a pre-cancelled call still spawned Fixed. Zero provider calls, no process.
P1: cleanup failure after a crash dropped Same result as before. Can't test it here.
Close fails once the target exits Fixed. Close works, CLI exits 0.
P2: Evidence held only session_id Fixed for one-shot runs.
verify:frida needed --address Fixed. Passed 3 of 3.

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 paused, with one script loaded. It says target_resume_observed: false. But close then detaches and resumes it. The target runs on to the end, unhooked. The Evidence is a snapshot from before close. A note that cleanup resumed it would help.

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: check:fast passes from a real clone, in the follow-up. Still not run: the remote lane, remote auth, a failing unload, and other OSes.

  • check:fast. Lint needs git history, and my copy has none. Typecheck on its own passed.
  • The remote lane. I had no frida-server.
  • Remote auth in Evidence, on real Frida. I used a stub provider instead.
  • An unload that fails on a live script. I can't force that on real Frida.
  • Other OSes, like macOS or Windows.

Thanks, dandgabr, for the quick and careful fixes.

Crash case and P2 detail

Crash 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. load_frida_script and frida_session_status still hold only session_id. That may be fine, since the session is live. With a stub provider, remote Evidence kept address, origin and keepalive_interval. No token or certificate showed up.

Cancel race detail

The races used the built service. A wrapper on the real manager fired the abort as each step began. After each run I read /proc/<pid>/status. I also counted frida lines in /proc/<pid>/maps.

Cancel during Result Target after Hooked calls
Attach (×3) Cancelled, released Running, 0 Frida maps 0
Script load (×3) Cancelled, released Running, 0 Frida maps 0
Resume (×3) Cancelled, released Running, 0 Frida maps 1
Observation (×3) Cancelled, released Running, 0 Frida maps 3

"Running" means state S (sleeping) and its output kept growing. All later output was unhooked. Each cancel gave back part of the Evidence. status() found no session after.

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.

Check Result
Pre-cancelled instrument (×3) AnalysisCancelledError, 0 provider calls, no process
MCP cancel right after start_frida_session (×3) Fails in under 0.1 ms, no process
Short spawn exits before close (×3, MCP) Close ok, session gone
Short spawn via CLI (×3) Exit 0, cleanup_error: null
verify:frida, no flags (×3) Exit 0, script_message_observed: true, cleanup_error: null
Tests per file
Test file Tests Node 22 Node 24 Node 26
FridaInstrumentationManager.test.ts 18 pass pass pass
FridaInstrumentationService.test.ts 7 pass pass pass
fridaToolContracts.test.ts 4 pass pass pass
fridaCli.test.ts 1 pass pass pass
fridaMcp.test.ts 1 pass pass pass
productCatalog.test.ts 11 pass pass pass

My first run used these six files, 28 tests then. Now it's 42.

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 (build and live runs on 24.18.0)
  • Head / base: 4e766550 / 9c4a68bc
  • Frida: Node binding 17.23.2 from npm ci, CLI tools 17.23.3 (wxWindows Library Licence 3.1)
  • Target: a tiny C program, built with clang 22.1.8 (Apache-2.0 with LLVM exception)
  • Local device only, ptrace_scope 0. I attached to nothing I didn't start.

🤖 Generated with Claude Code (Opus 5.5) 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: check:fast passes at 4e766550, run from a real clone this time. Every step passed. Lint added 14 warnings, but no errors.

check:fast step Head 4e766550 Merge base 750fb656
deps:check pass pass
typecheck pass pass
lint: oxlint pass, 0 errors pass, 0 errors
lint: verify:module-boundaries pass pass
Whole check:fast pass, exit 0 pass, exit 0

All on Node 24.18.0. Turbo ran both tasks fresh, with 0 cached.

My last run failed on verify:module-boundaries. That step calls git ls-files. My old copy had no .git folder. A real clone fixed that.

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

  • The rest of check: format:check, knip and metadata:check.
  • Node 22 and 26 for this lane.
  • The items still open in my last comment.
New lint warnings (14)

Line numbers left out. All are warnings.

  • src/frida/FridaInstrumentationManager.ts
    • complexity: one function at 30
    • complexity: closeSession at 25
    • complexity: recordMessage at 29
    • max-lines: 1,060 lines in the file
    • max-lines-per-function: one function at 111 lines
    • max-lines-per-function: recordMessage at 121 lines
    • unicorn(no-useless-spread): two spreads
  • src/server/registerFridaTools.ts
    • max-lines-per-function: one function at 269 lines
    • max-params: one arrow function with 5
  • src/application/frida/FridaInstrumentationService.ts
    • max-lines-per-function: instrument at 120 lines
    • max-params: one function with 5
  • src/cli/fridaCommands.ts
    • max-lines-per-function: one function at 211 lines
  • src/contracts/fridaRemoteAddress.ts
    • no-control-regex: one regex

One more file changed but is not in the 14. In scripts/lib/catalog-builders.mjs, two old warnings grew. One function went from 102 to 107 lines. The other went from 174 to 178.

Commands
git clone --no-checkout <local mirror> repo
git -C repo checkout --detach 4e766550b31b8451121f5d98e2eed6be2ded3e42
npm ci
npm run check:fast
npm run deps:check
npm run typecheck
npx --no-install oxlint
npm run verify:module-boundaries

Then I checked out 750fb656 in the same clone. I ran npm ci, check:fast and oxlint again.

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: 24.18.0, npm 11.16.0
  • Head / base: 4e766550 / 750fb656
  • Other: TypeScript 7.0.2, oxlint 1.87.0, turbo 2.11.7 (from the lockfile)

🤖 Generated with Claude Code (Opus 5.5) 🦊

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

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-network EACCES; 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.

Comment thread src/contracts/fridaToolContracts.ts Resolved
Comment thread src/server/registerFridaTools.ts Resolved
Comment thread src/cli/fridaCommands.ts Resolved

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

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 --singleThreaded mode), 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.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

The newly approved exact-head CI run has a concrete failure at b4b8f8bd: test shard 4/4 passes 1,703 tests but fails tests/boundary/cli/cliOptionAliases.test.ts.

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 instrument-with-frida --remote-address <string>, --script-file <string>, and --keepalive-interval <number>. The source fields have .describe(...), so that guidance is being lost before rendered help. Please apply the existing CLI schema-presentation boundary to these registrations and verify the actual help output; retain the repository-wide regression rather than excluding the new commands.

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.

@dandgabr

Copy link
Copy Markdown
Contributor Author

Follow-up outside the Frida scope

The full local npm run check:pr run exposed an unrelated order-dependent assertion in tests/boundary/filesystem/referenceSourceReader.test.ts, in “applies exclusions to normalized paths after no-follow type inspection.” It expects the shouldExclude callback to be invoked in directory creation order (ignored, then kept), while filesystem iteration returned (kept, then ignored). The focused test reproduces the mismatch; the full run reported 840 files passed, 1 failed, 13 skipped (8,070 tests passed, 1 failed, 94 skipped).

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. npm run check:ci and the focused Frida suite pass for this change.

@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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

Finding At 4e76655 At b2d2b8b
P1: a pre-cancelled call spawned Fixed Still fixed. 3 of 3: zero provider calls, no process.
P1: cleanup failure after a crash Same as the first run Same. Can't test it here.
Close fails once the target exits Fixed Still fixed. MCP close works 3 of 3. CLI exits 0 3 of 3.
P2: Evidence held only session_id Fixed for one-shot runs Same.
verify:frida needed --address Fixed Still fixed. Passed 3 of 3.

The Evidence quirk is fixed

Before, a cancel before resume said target_resume_observed: false. Close then resumed the target anyway. Now the Evidence says true. It also keeps target_state_before_cleanup: "paused", so the snapshot is still there. I cancelled at attach, load, resume and observation, 3 times each. All 12 runs cleaned up, and the counts of hooked calls match 4e76655. A CLI Ctrl+C sweep agreed.

What the new commits added

  • Two scripts in one session: each load result holds only its own script's messages. Every message carries its script_id.
  • Cancelling a one-shot instrument_with_frida over MCP now leaves its partial Evidence in get_evidence_bundle. I did not test 4e76655 for this.
  • instrument-with-frida --help now shows a description for every option. The keepalive says seconds. The cliOptionAliases test that failed in CI at b4b8f8b passes here.
  • frida_session_status output now has device_id and mode. Its parameters still hold only session_id.

Tests

The five Frida test files now hold 41 tests, up from 31. The author added tests. With productCatalog that is 52 in six files, up from 42. All pass on Node 22, 24 and 26. On Node 24, check:fast exits 0 and test:fast passes 4,623 tests with 3 skipped.

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

  • The remote lane. I have no frida-server. Ran on real frida-server 17.23.2, over loopback.
  • Remote auth on real Frida. A stub provider kept the token and certificate out of Evidence. Ran with a token and TLS. No secret in any result.
  • An unload that fails on a live script.
  • A real-Frida message flood for the new bucket fix. Only its unit test ran. Ran with 20,000 and 60,000 messages.
  • Other OSes, CI, and the full check. (npm run check passed on main. Other OSes and CI are still not run.)

Thanks, dandgabr, for the quick fixes.

Cancel race detail

The races used the built service with the real manager wrapped. The abort fired as each step began. The Before cleanup column shows target_state_before_cleanup, then target_resume_observed.

Cancel at Before cleanup Target after Hooked calls
Attach (×3) paused, resume true Running, 0 Frida maps 0
Script load (×3) paused, resume true Running, 0 Frida maps 0
Resume (×3) running, resume true Running, 0 Frida maps 1
Observation (×3) running, resume true Running, 0 Frida maps 3

Every run: AnalysisCancelledError, instrumentation_cleanup: released, cleanup_error: null, and no session left in the list.

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
Test file At 4e76655 Now Node 22 Node 24 Node 26
FridaInstrumentationManager.test.ts 18 21 pass pass pass
FridaInstrumentationService.test.ts 7 11 pass pass pass
fridaToolContracts.test.ts 4 5 pass pass pass
fridaCli.test.ts 1 1 pass pass pass
fridaMcp.test.ts 1 3 pass pass pass
productCatalog.test.ts 11 11 pass pass pass
cliOptionAliases.test.ts not run 2 pass pass pass

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. test:fast took 87 seconds.

Commands
git clone --no-checkout <local mirror> repo
git -C repo checkout --detach b2d2b8be8
npm ci
npm run build
npm run test:prepare
npm run test:focused -- <the seven files above>
npm run verify:frida
npm run verify:frida:bindings
npm run check:fast
npm run test:fast
node scripts/rea.mjs instrument-with-frida --help

The live runs used the built dist/ service and node scripts/rea.mjs --mcp. The target was a tiny C program that prints compute(2, 3) every 200 ms. A hook script replaced the return value with 42.

Test setup

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

@dandgabr

Copy link
Copy Markdown
Contributor Author

Regarding comment 6106513972: the CLI help description fix is included in ancestor commit b2d2b8be8, which is part of the current head. The reviewer reported tests/boundary/cli/cliOptionAliases.test.ts passing there, and the repository-wide regression was retained.

@dandgabr

Copy link
Copy Markdown
Contributor Author

Regarding comment 6113265492: the described crash path reports a closed connection, no remaining scripts, and a destroyed script handle; closeSession() treats the detached parent as releasing that resource. Existing manager tests cover an already-destroyed script, successful parent detach after unload failure, and retaining ownership when both unload and detach fail. The native live-script unload failure remains unverified, so I have not claimed that provider behavior is reproduced.

@N0zoM1z0
N0zoM1z0 self-requested a review October 12, 2026 06:57
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.
@N0zoM1z0
N0zoM1z0 merged commit 4a4ae9b into morluto:main Oct 12, 2026
32 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@CassieFox23

Copy link
Copy Markdown
Contributor

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 check. Thanks, dandgabr, for the PR.

Check on main 9d6651e Result
Remote lane: verify:frida against a real frida-server 17.23.2 Pass, 3 of 3. Exit 0. remote_target_observed and script_message_observed were true. cleanup_error was null.
Remote auth: server with --token and TLS, right token List and attach both worked. The script's message came back.
Remote auth: wrong token Refused: "Incorrect token".
Remote auth: no token Refused. The server wanted a token.
Secrets in results None. I searched the token and the certificate text in every result and error. 0 hits.
Flood, 20,000 messages (about 12 MB) All kept. messages_truncated false.
Flood, 60,000 messages Kept the newest 27,549, in order. messages_truncated true. Evidence was 16,805,621 bytes.
npm run check from a real clone Pass. Exit 0. Turbo replayed it from the cache.
Local verify:frida and verify:frida:bindings Pass, 3 of 3 and 1 of 1.
Seven Frida test files, Node 24 77 of 77 pass.

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 FridaInstrumentationManager.ts. I did not test other caps.

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

  • An unload that fails on a live script. I can't force that on real Frida.
  • Attach to a process I did not start. I will not run that on this box.
  • macOS, Windows, Android, and CI.
  • A frida-server on another machine. All runs stayed on this machine, over loopback.
  • The Frida tests on Node 22 and 26. These runs used Node 24.
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 openssl req -x509. I stopped both servers and the target when I finished.

Test setup

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

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

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants