T09 · Insecure Skill Coding Practices
- Location
scripts/skill-sandbox.sh:108- Finding
Path Traversal Enables Destructive Filesystem Operations
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 fi ``` 2. Explicitly reject `/`, backslashes, control characters, and traversal components. 3. Canonicalize the parent directories with `realpath` before destructive operations. 4. Verify that each resolved target is an immediate child of the expected canonical parent: ```bash staging_root=$(realpath -m -- "$STAGING_DIR") staged_path=$(realpath -m -- "$STAGING_DIR/$SKILL_NAME") if [[ "$(dirname -- "$staged_path")" != "$staging_root" ]]; then echo "Staged path escapes staging root" >&2 exit 1 fi ``` 5. Apply equivalent containment checks to `LIVE_PATH`. 6. Reject dangerous custom roots, including empty values, `/`, the user's home directory, and the workspace root where inappropriate. 7. Before `rm -rf`, require that the target is nonempty, canonicalized, contained beneath the expected root, and not equal to the root itself. ]]>
