T09 · Insecure Skill Coding Practices
- Location
auto-optimizer.sh:326- Finding
Path Traversal Through Session Name Allows Filesystem Writes Outside the Results Directory
- Content
View full analysis
"$TSV_FILE" # Initialize hypothesis log touch "$HYPOTHESIS_LOG" ``` ### Technical Analysis The value supplied through `--session` is inserted directly into a filesystem path without validation or canonicalization. A session name containing traversal components such as `../` can cause `RESULTS_DIR` to resolve outside the intended `$SKILL_DIR/results` directory. The script subsequently performs `mkdir -p`, output redirection, `touch`, and `cp` operations using paths derived from this value. These operations create or overwrite files named: - `results.tsv` - `report.md` - `best.md` - `hypothesis_log.jsonl` - `prompt_iterN.txt` when the fallback agent path is used The attack is limited to the privileges of the account running the optimizer. Direct writes use predictable filenames, but the scope can become broader if an attacker can pre-create symbolic links with those names in the selected destination directory. ### Attack Path 1. An attacker causes the optimizer to be invoked with a crafted session name, for example: ```bash ./auto-optimizer.sh \ --file ./target.md \ --metric "bash ./metric.sh" \ --session "../../../../tmp/attacker-controlled" ``` 2. The script constructs: ```text $SKILL_DIR/results/../../../../tmp/attacker-controlled ``` 3. `mkdir -p` creates the escaped destination directory if permissions allow. ...[truncated 973 chars]- Remediation
View remediation
