Repository navigation
Description
Problem Statement
Windows Ghidra P0 currently stops the launcher tree with bounded taskkill /T /F. This is useful cleanup but is not an operating-system ownership proof: it is PID-based, cannot establish that every descendant remained in the tree, and cannot provide kill-on-owner-close behavior.
Node/libuv's implicit Windows job is also insufficient for the stronger claim. It enables silent breakaway for descendants and tolerates some assignment failures so ordinary child_process.spawn can continue without containment.
Purpose and Benefit
Give each Windows Ghidra session an OS-owned process lifetime. Closing or losing the owner handle should terminate the associated launcher, Java process, and descendants without enumerating PIDs.
This would:
- remove PID-reuse ambiguity from provider cleanup;
- make cancellation, timeout, protocol failure, and parent crash converge on one cleanup primitive;
- prevent untracked Ghidra descendants from surviving a failed session; and
- replace the current Windows cleanup limitation with verifiable evidence.
Proposed Direction
Add a Windows process-owner adapter beneath ProviderProcess that:
- creates a dedicated unnamed Job Object;
- applies JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE without silent breakaway;
- creates the launcher already assigned to the job, preferably with PROC_THREAD_ATTRIBUTE_JOB_LIST to avoid a create-then-assign race;
- retains the job handle for the full provider lifetime; and
- reports typed launch, assignment, termination, and settlement outcomes.
The Ghidra launcher should consume the provider-neutral ownership interface. Raw Win32 handles and Job Object policy must not enter the domain or application layers.
Desired Outcome
- Ghidra cannot execute before successful Job Object assignment.
- Child and grandchild fixtures remain in the owned job unless an explicitly unsupported breakaway attempt causes launch or verification to fail closed.
- Closing the final owner handle terminates all associated live processes.
- Cleanup reports distinguish already empty, terminated, assignment unavailable, nested-job conflict, and incomplete settlement.
- Doctor/capability output reports whether this ownership backend is available.
- The real Windows verifier proves normal exit, cancellation, timeout, parent-handle close, descendant cleanup, and no unrelated-process termination.
Constraints and Non-goals
- Depends on the packaging and adapter decision in Define a trusted Windows native authority and packaging boundary #287.
- Preserve the existing taskkill implementation only as an explicitly limited fallback; it must not satisfy the Job Object capability claim.
- Do not broaden this into Windows PTY capture, replay, or resource-limit policy.
- Do not rely on a create-then-assign sequence that lets child code run before ownership is established.
Evidence and References
- Parent roadmap: Add first-class Windows artifact and analysis support #38
- Current implementation: src/process/ProcessOwnership.ts, src/process/ProviderProcess.ts, and src/ghidra/GhidraLauncher.ts
- Job Object process-tree and kill-on-close semantics: https://learn.microsoft.com/en-us/windows/win32/procthread/job-objects
- Atomic process-creation job list: https://learn.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute
- Assignment and nested-job constraints: https://learn.microsoft.com/en-us/windows/win32/api/jobapi2/nf-jobapi2-assignprocesstojobobject
- libuv's breakaway and assignment behavior: https://github.com/libuv/libuv/blob/v1.x/src/win/process.c
Activity
morluto commentedon Jul 17, 2026
Status after #287 packaging research: this remains an active implementation gap. It can proceed once the Windows native platform package/loader/typed port from #287 is accepted, and it does not need to wait for reparse-safe file handles or DACL work. The implementation must use Job Objects for owned-tree cleanup and retain a real non-admin Windows verifier; taskkill is not equivalent ownership proof.
morluto commentedon Jul 17, 2026
Current-main contract update (2026-07-17):
The provider-neutral process boundary now refuses to publish a WindowsOwnedProcess unless the native result reports the exact initial Job Object policy:
The application derives a versioned SHA-256 commitment from every normalized field; it no longer trusts an opaque addon digest. Any broader, missing, malformed, or unknown ownership report returns native_contract_mismatch and closes the process/Job token before publication. Focused tests reject named/shared Jobs, post-create assignment, pre-assignment execution, disabled kill-on-close, breakaway, nested Jobs, inheritable or duplicate owner handles, ambient inherited handles, unverified membership, and extra fields, with exactly-once cleanup.
Independent review also clarified the last-handle boundary: an unnamed/non-inheritable Job does not prevent another same-user process with PROCESS_DUP_HANDLE access from duplicating REA's retained handle. ADR-0004 now limits last-handle kill-on-close claims to processes outside that handle-theft boundary. Stronger same-user proof requires process-handle protection plus real duplication attempts.
The exact final tree passes npm run check: 160 test files, 1,088 tests, plus generated docs, build, typecheck, lint, and formatting. Independent follow-up review is clean.
This issue remains open for the native Node-API Job implementation, queried-limit/membership proof, real descendant/breakaway/normal-exit/cancellation/timeout/parent-close tests, doctor/capability wiring, and the explicit same-user handle-theft decision. taskkill remains a limited fallback and does not satisfy this contract.
morluto commentedon Jul 20, 2026
Split into focused child issues:
These replace the broad remaining scope in this issue. Closing this parent can happen once all children are closed.
feat(ghidra): implement Windows x64 P0 native authority (Job Objects,…
morluto commentedon Nov 24, 2026
Closing as implemented: Windows Ghidra process trees are now owned by an unnamed, non-inherited Job Object with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, breakaway disabled, and atomicPROC_THREAD_ATTRIBUTE_JOB_LISTassignment innative/windows/src/process.cc(createJob,spawnProcess), wrapped bysrc/windows/WindowsOwnedProcess.tsandsrc/process/ProviderProcess.ts. Capability/doctor reporting is wired insrc/process/WindowsAuthority.tsandsrc/ghidra/GhidraDoctor.ts, and real-Windows verification runs inscripts/verify-windows-native.mjs,scripts/verify-real-ghidra-windows.mjs, andscripts/verify-packaged-ghidra-windows.mjs(landed in PR #699 /26881da76a).