T09 · Insecure Skill Coding Practices
- Location
SKILL.md:45- Finding
Unvalidated Circle Name Allows Path Traversal and Unintended File Access
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 45-52, with additional affected uses at lines 61-74 and 84-94
Vulnerability Type: Path traversal and unsafe shell path construction
Risk Level: MediumVulnerable Code
bash CIRCLE="team-alpha" NEW_MEMBER="agent4.pilot" jq --arg member "$NEW_MEMBER" '.members += [$member]' \ ~/.pilot/circles/$CIRCLE.json > /tmp/circle.json && \ mv /tmp/circle.json ~/.pilot/circles/$CIRCLE.jsonAdditional affected path constructions include:
bash cat ~/.pilot/circles/$CIRCLE.json | jq -r '.members[]' | \ while read -r MEMBER; do pilotctl --json handshake "$MEMBER" "Trust circle: $CIRCLE" || true donebash if cat ~/.pilot/circles/$CIRCLE.json | jq -e --arg h "$HOSTNAME" '.members[] | select(. == $h)' >/dev/null; thenbash cat > ~/.pilot/circles/$CIRCLE.json <<EOFTechnical Analysis
The
CIRCLEvariable is inserted directly into filesystem paths without validation or shell quoting. A circle name containing path traversal sequences such as../, or shell word-separation and glob characters, is therefore not constrained to~/.pilot/circles.For example, a value such as
../../targetmakes the destination resolve outside the intended circle directory. In the add-member workflow,mvmay consequently replace another file writable by the current user. In the bootstrap workflow, traversal can cause the recipe to read an unintended JSON file and treat its contents as trusted agent membership data.Because the paths are also unquoted, spaces and wildcard characters in
CIRCLEcan cause shell word splitting or pathname expansion. The documented static examples are safe, but the recipe becomes exploitable if a circle name is supplied by a user, automation pipeline, or other untrusted source.Attack Path
- An attacker obtains control over, or persuades the operator to use, a crafted circle name such as
../../target. - The agent or ...[truncated 1148 chars]
- An attacker obtains control over, or persuades the operator to use, a crafted circle name such as
- Remediation
View remediation
Remediation Suggestions
Validate circle names before using them in any path and quote every path expansion:
bash case "$CIRCLE" in ''|*[!A-Za-z0-9_-]*) printf 'Invalid circle name\n' >&2 exit 1 ;; esac CIRCLE_DIR="$HOME/.pilot/circles" CIRCLE_FILE="$CIRCLE_DIR/$CIRCLE.json" mkdir -p -- "$CIRCLE_DIR"Use only the validated
CIRCLE_FILEvariable afterward:bash jq --arg member "$NEW_MEMBER" '.members += [$member]' \ "$CIRCLE_FILE" > "$TEMP_FILE"Further hardening should include:
- Rejecting
/,\,.., whitespace, glob characters, and control characters. - Resolving or canonicalizing the final path and verifying that it remains beneath
$HOME/.pilot/circles. - Quoting all variable expansions used as command arguments.
- Using
jqdirectly on files instead of unnecessarycatpipelines. - Requiring explicit operator confirmation before approving a node derived from mutable circle configuration.
- Rejecting
