T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/lock-done.sh:21- Finding
Missing authorization allows arbitrary tasks to be marked complete and archived
- Content
View full analysis
/dev/null | head -1) [[ -z "$AGENT_SEARCH" ]] && { echo "Error: lock not found: $TASK_ID"; exit 1; } AGENT_ID=$(echo "$AGENT_SEARCH" | sed "s|$LOCKS_ROOT/||" | cut -d/ -f1) fi LOCK_FILE="$LOCKS_ROOT/$AGENT_ID/locks/active/${TASK_ID}.lock" [[ ! -f "$LOCK_FILE" ]] && LOCK_FILE=$(find "$LOCKS_ROOT/$AGENT_ID/locks" -name "${TASK_ID}.lock" -type f 2>/dev/null | head -1) [[ ! -f "$LOCK_FILE" ]] && { echo "Error: lock does not exist: $TASK_ID"; exit 1; } # Check status CURRENT_STATUS=$(grep -o '"status"[[:space:]]*:[[:space:]]*"[^"]*"' "$LOCK_FILE" | sed 's/.*: *"\([^"]*\)".*/\1/') [[ "$CURRENT_STATUS" == "done" ]] && { echo "Note: already done: $TASK_ID"; exit 0; } DONE_AT=$(date -u +"%Y-%m-%dT%H:%M:%S+08:00") # Update status sed -i 's/"status": "[^"]*"/"status": "done"/' "$LOCK_FILE" sed -i "s/\"done_at\": \"[^\"]*\"/\"done_at\": \"$DONE_AT\"/" "$LOCK_FILE" # Archive immediately ARCHIVE_DIR="$LOCKS_ROOT/$AGENT_ID/locks/archive/$(date +%Y-%m-%d)" mkdir -p "$ARCHIVE_DIR" mv "$LOCK_FILE" "$ARCHIVE_DIR/" ``` ### Technical Analysis The completion operation locates a lock solely by a caller-supplied task and optional agent identifier. It then modifies and moves the lock without authenticating the caller or comparing the caller's session with the lock's `session_id`. This contradicts the ownership model documented in `references/spec.md:80-101`, which requires owner-session validation or an authorized takeover decision. Filesystem permissions alone do not establish task-level ownership when multiple agents or sessions execute under the same operating-system account. ### Attack Path 1. An attacker with permission to invoke the script identifies or guesses another tas ...[truncated 703 chars]- Remediation
View remediation
