Repository navigation
Description
Current behavior
rocmd's managed-service stop reads engine_pid and supervisor_pid out of a persisted service record and signals them directly — SIGTERM, then SIGKILL 750 ms later — without checking that those PIDs still identify the recorded processes. It then expands descendants against a live process listing, so a stale root PID drags whatever now owns that PID and all of that process's children into the kill set.
Two compounding problems:
-
No identity check at stop time.
apps/rocmdoes the same job correctly: it pairs each PID with its own start-time token and callsrocm_core::terminate_verified, which returnsIdentityMismatchand signals nothing when the identity is refuted.apps/rocmdcontains no reference toterminate_verified,ProcessIdentity, or the token fields, though it reads the same record type from the same location. -
No identity recorded at write time.
apps/rocmdnever capturedsupervisor_start_ticks/engine_start_ticksat all. Every record it wrote hasNone, whichrocm_core::identity_stateclassifies asMatchesvia its documented legacy branch ("no recorded identity: best-effort proceed"). So merely adding a verified stop would have changed nothing for recordsrocmdcreated.
Expected behavior
A recorded PID is signalled only when it still identifies the recorded process, as rocm services stop already does.
Steps to reproduce
Three realistic routes make a recorded PID stale while the record still names it:
- Reboot — records persist under
services/*.json; PIDs restart from low numbers, so a recorded 4-6 digit PID is likely re-allocated. - Repeat stop — the stop set
status = "stopped"but left the PIDs in the record, so a second stop re-signalled them. - Crash — the service dies and the record still reports
readywith the old PIDs.
Then stop the service. Observed with a live bystander occupying the recorded PID: it is SIGTERM'd and SIGKILL'd, and when the bystander has a child, the child is signalled too.
Consequence
SIGTERM followed by SIGKILL of an arbitrary process tree on the user's machine.
Reachability
Both the CLI (rocmd sandbox-tool stop-server --service-id <id>) and the daemon's MCP tool surface (stop_server), so an LLM agent can invoke it.
Environment
- Observed on Linux against
main. The missing identity check is platform-independent; on Windowsrocm_corecannot read process start times at all, so identity is unverifiable there regardless.
Related
rocm comfyui stop has the same shape: ComfyUiState stores only pid with no kernel identity token, and the stop calls terminate_process_tree after a bare liveness check. Fixing it needs a state-schema addition, so it is tracked separately.
How it was found
Property-based testing of the process-lifecycle code. The tree walkers themselves came out clean under properties; this was found by reading outward from them to the callers.
Activity