Skip to content

fix(frida): attach by PID when process lookup omits target - #3099

Closed
LcokHcak wants to merge 3 commits into
morluto:mainfrom
LcokHcak:codex/frida-attach-pid-fix
Closed

LcokHcak wants to merge 3 commits into
morluto:mainfrom
LcokHcak:codex/frida-attach-pid-fix

Conversation

@LcokHcak

@LcokHcak LcokHcak commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On a controlled Windows x64 Python fixture with Frida 17.23.2, enumerateProcesses() omitted the running PID and getProcessByPid(pid) returned Process not found, while device.attach(pid) succeeded. REA calls getProcessByPid before attach and therefore rejects a target that Frida can attach to.

Change

  • Keep the existing lookup-before-attach resource order, but treat a failed metadata lookup as nonfatal and use pid <PID> as the target label.
  • Attach the caller-selected PID even when Frida omits it from process enumeration.
  • Preserve real attach failures and the existing session cleanup path.

Verification

  • Two new manager regression tests first reproduced the false lookup failure, then verified the PID actually passed to attach() and preservation of a real attach error.
  • FridaInstrumentationManager.test.ts: 33/33 passed on the isolated branch based on upstream b3c5672c.
  • Full TypeScript typecheck, direct compile, targeted formatting, lint, and diff checks passed. Lint reports existing manager size/complexity warnings; compile reports two existing ineffective dynamic-import chunk warnings.
  • A real controlled Windows x64 run with the same production source at b7817bf8 attached the otherwise unlisted Python fixture, loaded two scripts, retained 20 attributed Frida messages, and observed the fixture's independent returns 42,17,42. The current 71b6706a adds only the test assertion that verifies the attach() argument. A separate local trace projection accepted 12 selected function/basic-block events; its saved-evidence verifier passed. This is one fixture and one host, not general Windows or target coverage.

No trace provider, script RPC, CLI/MCP operation, or target mutation workflow is added. The controlled raw capture remains local; no private binaries, credentials, or local paths are attached.

@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 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The changes appear safe to merge; no actionable new issues were found.

Summary

The manager now attaches to the caller-selected PID when Frida cannot find its process metadata.

  • Frida sessions can attach to PIDs missing from process lookup.

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@LcokHcak
LcokHcak force-pushed the codex/frida-attach-pid-fix branch from 6ed9d2a to b7817bf Compare October 14, 2026 02:55
@LcokHcak
LcokHcak force-pushed the codex/frida-attach-pid-fix branch from b7817bf to 71b6706 Compare October 14, 2026 03:01
@LcokHcak

Copy link
Copy Markdown
Contributor Author

I checked the failing Source tests job against the main-branch run at the PR's branch-point commit (b3c5672c). Both jobs fail the same five tests:

  • JavaScriptSemanticGraphResources.test.ts — config precedence and boundaries
  • electronWrappedCallPaths.test.ts — dynamic isolated world ID
  • javascriptSemanticAmbientWrites.test.ts — growing self-reference projections
  • javascriptSemanticAnalysis.native_bindings.test.ts — configuration/request recovery
  • IdaNativeProtocol.test.ts — headless-only operation admission

The main run reports 5 failed / 7,344 passed / 8 skipped; the PR run reports 5 failed / 7,346 passed / 8 skipped. The two additional passing tests are the Frida manager regressions added here. This comparison is to the branch-point main run; it does not claim that all current main checks are green.

@LcokHcak

Copy link
Copy Markdown
Contributor Author

CI follow-up for the remaining red jobs: Test shard 4/5 on this PR fails the same 10 named tests as the branch-point main run's shard 4/5. Portable tests on this PR reports 24 distinct failing test names; each also occurs in the branch-point main run's Source tests, shard 4/5, or Portable tests logs (34 distinct names across those three baseline jobs). No Frida manager test failed. Build package, static checks, and bundled Windows x64 native controls passed on this PR.

This is a named-test comparison against the exact branch-point main commit b3c5672c, not a claim that the current main head or this PR's full CI is green. CI required remains red because its test dependencies failed.

@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: none of the failures came from this PR. IDA native admission, the JavaScript semantic, source-map and contextBridge tests, ghidraJavaLaunch and developmentTests all broke on main while it was red, and #3080 fixed them. I merged current main (no conflicts) so CI re-runs. The Frida instrumentation tests pass on the merged tree (49), and check:fast is clean.

@kaoru0822-kitauji kaoru0822-kitauji added ci-fix-wip Claimed by the CI-fix track and removed ci-fix-wip Claimed by the CI-fix track labels Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: the latest failures (fridaMcp, ghidraRoutingMcp, goBinaryMcp, providerSelectionMcp) came from main's state during that run. I merged current main again (no conflicts), and on the merged tree those MCP tests and the Frida instrumentation tests all pass (60). check:fast is clean.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Treat process lookup as optional display metadata, attach to the caller-selected PID, and reconcile already-detached sessions after subscribing to events. Tests observe the actual attach target and the detach race.

Reviewed-PR: #3099
Co-authored-by: LcokHcak <[email protected]>
@morluto

morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Superseded by 56128a8424d8922fe3d4a45faed9e29989e5924d. Process lookup is now optional display metadata; attach uses the caller-selected PID, and the manager subscribes to detach then reconciles already-detached sessions. Validation: src/application/frida/FridaInstrumentationManager.test.ts (35 tests), including the actual attach target and early detach race, passed in the phase-five source log. The controlled binding tests do not verify native Frida or Windows behavior. Thanks to the PR author and reviewers.

@morluto morluto closed this Oct 14, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added area: runtime Process capture and runtime observation provider: frida Analysis provider / engine: frida labels Nov 23, 2026
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 area: runtime Process capture and runtime observation bug Something isn't working provider: frida Analysis provider / engine: frida

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants