T09 · Insecure Skill Coding Practices
- Location
scripts/timer.sh:85- Finding
Timer Cancellation Does Not Terminate the Associated Subagent
- Content
View full analysis
Vulnerability Details
File Location:
scripts/timer.sh:85-88
Supporting Location:scripts/state.sh:64-70,SKILL.md:78-79
Vulnerability Type: Incomplete cancellation and unsafe lifecycle management
Risk Level: MediumVulnerable Code
The cancellation command only delegates to the state-management script:
bash cancel) name="${1:?Usage: timer.sh cancel <timer-name>}" "$STATE_SCRIPT" cancel "$name" ;;The state-management script merely updates the local JSON record:
bash cancel) name="${1:?Usage: state.sh cancel <timer-name>}" _read_state | jq --arg name "$name" --arg cancelledAt "$(date -u +%Y-%m-%dT%H:%M:%SZ)" ' .timers[$name].status = "cancelled" | .timers[$name].cancelledAt = $cancelledAt ' | _write_state echo "Timer '$name' cancelled." ;;This conflicts with the documented behavior in
SKILL.md:markdown ### `$timer cancel <name>` Kill the subagent session and mark timer as cancelled.Technical Analysis
The implementation treats cancellation as a state transition rather than an execution-control operation. It does not store the spawned subagent's session identifier, invoke a session termination API, or verify that execution has stopped.
Consequently, the local state can report that a timer is cancelled while the associated subagent continues sleeping or executing its assigned task. This is a time-of-check/time-of-use lifecycle inconsistency and violates the documented cancellation guarantee.
Attack Path
- A user creates a timer.
- The host Agent reads the emitted task information and spawns a subagent.
- The timer state is stored locally without a usable subagent session identifier.
- The user invokes
timer.sh cancel <timer-name>. - The script changes the timer's JSON status to
cancelled. - No session-termination operation occurs.
- The subagent remains active and may execute the delayed task or send results despite the appare ...[truncated 550 chars]
- Remediation
View remediation
Remediation Suggestions
- Persist the spawned subagent's verified session identifier in each timer record.
- On cancellation, retrieve that identifier and invoke the host platform's supported session-termination API.
- Mark the timer as cancelled only after termination is confirmed.
- If termination fails, preserve an explicit state such as
cancellation_failedand return a nonzero exit status. - Make cancellation idempotent and safely handle completed, missing, and already-cancelled sessions.
- Reconcile state against the actual subagent status before displaying a timer as cancelled.
- Add integration tests verifying that a cancelled timer cannot subsequently execute or report completion.
