Skip to content

Own Windows Ghidra process trees with kill-on-close semantics #288

Done

Description

@morluto

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:

  1. creates a dedicated unnamed Job Object;
  2. applies JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE without silent breakaway;
  3. creates the launcher already assigned to the job, preferably with PROC_THREAD_ATTRIBUTE_JOB_LIST to avoid a create-then-assign race;
  4. retains the job handle for the full provider lifetime; and
  5. 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

Activity

  1. added
    enhancement
    P1: high
    roadmap
    on Jul 16, 2026
  2. morluto commented on Jul 17, 2026

    @morluto
    OwnerAuthor

    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.

  3. morluto commented on Jul 17, 2026

    @morluto
    OwnerAuthor

    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:

    • dedicated unnamed Job;
    • PROC_THREAD_ATTRIBUTE_JOB_LIST assignment;
    • process execution assigned at creation rather than create-then-assign;
    • kill-on-close enabled;
    • breakaway disabled;
    • no admitted nested Job;
    • retained non-inheritable owner handle;
    • exactly one addon-owned Job handle;
    • stdio-only inherited handles; and
    • verified process membership.

    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.

  4. morluto commented on Jul 20, 2026

    @morluto
    OwnerAuthor
  5. added
    area: native
    on Oct 14, 2026
  6. added
    area: runtime
    provider: ghidra
    area: providers
    and removed on Nov 23, 2026
  7. morluto commented on Nov 24, 2026

    @morluto
    OwnerAuthor

    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 atomic PROC_THREAD_ATTRIBUTE_JOB_LIST assignment in native/windows/src/process.cc (createJob, spawnProcess), wrapped by src/windows/WindowsOwnedProcess.ts and src/process/ProviderProcess.ts. Capability/doctor reporting is wired in src/process/WindowsAuthority.ts and src/ghidra/GhidraDoctor.ts, and real-Windows verification runs in scripts/verify-windows-native.mjs, scripts/verify-real-ghidra-windows.mjs, and scripts/verify-packaged-ghidra-windows.mjs (landed in PR #699 / 26881da76a).

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

Metadata

Metadata

Assignees

Labels

P1: higharea: nativearea: providersarea: runtimeenhancementprovider: ghidraroadmap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions