T09 · Insecure Skill Coding Practices
- Location
scripts/add-program.sh:22- Finding
Program Name Path Traversal and Unsafe JSON Construction
- Content
View full analysis
"$PROG_DIR/config.json" << EOF { "name": "$DISPLAY_NAME", "slug": "$NAME", "tracker": "$TRACKER", "workstreams": [ { "name": "$DISPLAY_NAME", "jira_project": "$PROJECT", "linear_team": "$PROJECT", "github_repos": [$([ -n "$REPO" ] && echo "\"$REPO\"" || echo "")], "exec": [], "slack_channel": "" } ] } EOF ``` ### Technical Analysis The `--name` value is concatenated directly into `PROG_DIR` without validating that it is a safe single path component. Shell quoting prevents word splitting and shell metacharacter execution, but it does not neutralize filesystem traversal sequences such as `../`. The script subsequently creates directories and writes `config.json` through the resulting path. A name containing traversal components can therefore escape `$BASE_DIR/programs`. The impact remains limited by the operating-system privileges of the user running the Skill. The same program-name path construction is used by: - `scripts/status-report.sh:20` - `scripts/risk-radar.sh:20` - `scripts/dependency-map.sh:20` - `scripts/meeting-prep.sh:18` - `scripts/dashboard.sh:10` Those scripts can consequently access a directory outside the intended `programs` root if a crafted program argument resolves to an existing directory. In addition, `NAME`, `DISPLAY_NAME`, `TRACKER`, `PROJECT`, and `REPO` are inserted into a JSON heredoc without JSON escaping. Quotes, backslashes, control characters, or newlines can produce invalid JSON or alter the generated JSON structure. ### Attack Path 1. An attacker persuades an authorized user or automation process to invoke `add-program.sh` with a crafted name such as `../../attacker-selected-directory ...[truncated 1138 chars]- Remediation
View remediation
