2 issues
find-bugs: Found 2 issues (1 medium, 1 low)
Medium
PID reuse may cause cleanup of live runtime's transient artifacts - `src/utils/workspace-filesystem-lifecycle.ts:376-380`
cleanupXcodeIdeCallToolTransientArtifacts deletes any owner directory whose PID is not alive via isPidAlive(ownerPid). Since the directory name encodes only the PID and instanceId, and the check is purely PID-based, a long-dead owner whose PID has been recycled by an unrelated process will be considered alive (false negative — safe), but more importantly, the matching only validates ownerPid > 0 without confirming the instanceId belongs to a stale runtime. If two runtimes share a PID across reboots, stale dirs may remain. Conversely, this is a TOCTOU pattern: between isPidAlive and fs.rm, a new runtime could claim that PID/instanceId combo and have its artifacts deleted. Given startup-only invocation with includeCurrentOwner:false, the practical risk is limited but a concurrent startup of another instance with reused PID could lose data.
Low
Sync cleanup does not surface errors when runtime not configured - `src/utils/workspace-filesystem-lifecycle.ts:390-394`
cleanupXcodeIdeCallToolTransientArtifactsSync returns {attemptedCount:0, errors:[]} silently when getRuntimeInstanceIfConfigured() returns null. If this is called from a process-exit handler expecting cleanup, callers cannot distinguish 'no runtime to clean' from 'cleanup skipped'. This is informational rather than a security issue.
Duration: 12m 13s · Tokens: 1.8M in / 14.0k out · Cost: $8.81 (+merge: $0.00)
Annotations
Check warning on line 380 in src/utils/workspace-filesystem-lifecycle.ts
sentry-warden / warden: find-bugs
PID reuse may cause cleanup of live runtime's transient artifacts
`cleanupXcodeIdeCallToolTransientArtifacts` deletes any owner directory whose PID is not alive via `isPidAlive(ownerPid)`. Since the directory name encodes only the PID and instanceId, and the check is purely PID-based, a long-dead owner whose PID has been recycled by an unrelated process will be considered alive (false negative — safe), but more importantly, the matching only validates `ownerPid > 0` without confirming the instanceId belongs to a stale runtime. If two runtimes share a PID across reboots, stale dirs may remain. Conversely, this is a TOCTOU pattern: between `isPidAlive` and `fs.rm`, a new runtime could claim that PID/instanceId combo and have its artifacts deleted. Given startup-only invocation with `includeCurrentOwner:false`, the practical risk is limited but a concurrent startup of another instance with reused PID could lose data.