Finding
File: .claude/skills/setup-agent-team/qa.sh:17-21
Severity: HIGH
Description
The SPAWN_ISSUE validation checks if the value is a positive integer using a regex, but it does NOT prevent:
- Leading zeros (e.g., "00123" passes validation)
- Integer overflow (extremely large numbers)
- Use in arithmetic contexts where leading zeros could cause issues
Vulnerable code:
# Validate SPAWN_ISSUE is a positive integer to prevent command injectionif [[ -n"${SPAWN_ISSUE}" ]] && [[ \!"${SPAWN_ISSUE}"=~ ^[0-9]+$ ]];thenecho"ERROR: SPAWN_ISSUE must be a positive integer, got: '${SPAWN_ISSUE}'">&2exit 1
fiAttack Vectors
Leading zeros in octal context: If ISSUE_NUM (derived from SPAWN_ISSUE) is used in arithmetic expansion $(( )), bash interprets leading zeros as octal:
SPAWN_ISSUE="0123"# Passes validation
num=$((SPAWN_ISSUE))# Interpreted as octal 83 decimal
Filesystem path manipulation: Leading zeros could bypass path-based access controls:
SPAWN_ISSUE="00001"
WORKTREE_BASE="/tmp/spawn-worktrees/qa-issue-00001"# Different path than expected
Integer overflow in downstream consumers: If SPAWN_ISSUE is passed to commands expecting bounded integers (e.g., gh issue), extremely large values could cause errors or undefined behavior.
Current Usage
The validated SPAWN_ISSUE is used in:
- Line 26:
ISSUE_NUM="${SPAWN_ISSUE}" - Line 27:
WORKTREE_BASE="/tmp/spawn-worktrees/qa-issue-${ISSUE_NUM}" - Line 28:
TEAM_NAME="spawn-qa-issue-${ISSUE_NUM}" - Line 296:
safe_substitute "ISSUE_NUM_PLACEHOLDER" "${ISSUE_NUM}" "${PROMPT_FILE}"
While the current usage is mostly safe (string concatenation), the lack of canonical validation could lead to unexpected behavior or bypass defenses in future code changes.
Impact
- Path confusion: Different paths for the same issue number
- Arithmetic errors: Octal interpretation in future arithmetic contexts
- Bypass of rate-limiting or deduplication: If downstream systems treat "123" and "0123" as different issues
Recommendation
Strip leading zeros before use:
if [[ -n"${SPAWN_ISSUE}" ]];then# Validate formatif [[ \!"${SPAWN_ISSUE}"=~ ^[0-9]+$ ]];thenecho"ERROR: SPAWN_ISSUE must be a positive integer">&2exit 1
fi# Strip leading zeros (convert to decimal)
SPAWN_ISSUE=$((10#${SPAWN_ISSUE}))# Validate range (GitHub issue numbers are 32-bit)if [[ "${SPAWN_ISSUE}"-lt 1 ||"${SPAWN_ISSUE}"-gt 2147483647 ]];thenecho"ERROR: SPAWN_ISSUE out of range: ${SPAWN_ISSUE}">&2exit 1
fifiUse consistent validation pattern across all scripts (refactor.sh, trigger-server.ts, etc.)
References
- Similar validation exists in refactor.sh and trigger-server.ts
- GitHub API enforces issue number as 32-bit integer (max 2^31-1)
-- security/shell-scanner
Finding
File: .claude/skills/setup-agent-team/qa.sh:17-21
Severity: HIGH
Description
The
SPAWN_ISSUEvalidation checks if the value is a positive integer using a regex, but it does NOT prevent:Vulnerable code:
Attack Vectors
Leading zeros in octal context: If
ISSUE_NUM(derived fromSPAWN_ISSUE) is used in arithmetic expansion$(( )), bash interprets leading zeros as octal:Filesystem path manipulation: Leading zeros could bypass path-based access controls:
Integer overflow in downstream consumers: If SPAWN_ISSUE is passed to commands expecting bounded integers (e.g.,
gh issue), extremely large values could cause errors or undefined behavior.Current Usage
The validated
SPAWN_ISSUEis used in:ISSUE_NUM="${SPAWN_ISSUE}"WORKTREE_BASE="/tmp/spawn-worktrees/qa-issue-${ISSUE_NUM}"TEAM_NAME="spawn-qa-issue-${ISSUE_NUM}"safe_substitute "ISSUE_NUM_PLACEHOLDER" "${ISSUE_NUM}" "${PROMPT_FILE}"While the current usage is mostly safe (string concatenation), the lack of canonical validation could lead to unexpected behavior or bypass defenses in future code changes.
Impact
Recommendation
Strip leading zeros before use:
Use consistent validation pattern across all scripts (refactor.sh, trigger-server.ts, etc.)
References
-- security/shell-scanner