T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/humanize.sh:35
- Finding
- Sensitive file protections can be bypassed through incomplete path validation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/humanize.sh:35-50` **Vulnerability Type**: Incomplete sensitive-file path validation **Risk Level**: Medium ### Vulnerable Code ```bash SAFE_DIR="${HUMANIZE_SAFE_DIR:-$HOME/.openclaw/workspace}" # Normalize: ensure SAFE_DIR ends with / SAFE_DIR="${SAFE_DIR%/}/" if [[ "$resolved" != "$SAFE_DIR"* ]]; then echo "Error: Access restricted to $SAFE_DIR" >&2 exit 1 fi # 4. Filename blacklist local basename basename=$(basename "$resolved") case "$basename" in .env*|*.key|id_rsa*|authorized_keys|.bash_history|config.json|.ssh|*.pem|*.p12|*.pfx|shadow|passwd) echo "Error: Access to sensitive files is blocked." >&2 exit 1 ;; esac ``` ### Technical Analysis The script intends to prevent sensitive files from being uploaded to the Evolink API, but its protection is based only on the final basename of the resolved input path. Sensitive directory components are not inspected. For example, blacklisting the basename `.ssh` does not block files located inside a `.ssh` directory. A path ending in `.ssh/id_ed25519` has the basename `id_ed25519`, which does not match `.ssh` or `id_rsa*`. Other private-key names not covered by the patterns may similarly pass validation. The configurable `HUMANIZE_SAFE_DIR` is normalized only by appending a slash; it is not canonicalized or constrained against excessively broad values. Setting it to `/` makes the prefix check accept any resolved absolute path. The resulting exposure remains limited to files readable by the account running the Skill, but it exceeds the minimum file-access scope needed for text rewriting. The scanner warning about SSH-key writes is a false positive: these strings form a read denylist, and the script does not write to SSH key files. The actual issue is that the denylist does not reliably prevent sensitive-file reads and subsequent network transmission. ### Attack Path 1. An attacker or unsafe configuration sets ` ...[truncated 1043 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Canonicalize the permitted root using `realpath -e` before performing containment checks. 2. Reject unsafe roots such as `/`, the user's home directory, and other broad system locations. 3. Compare the canonical target against the canonical safe directory with a boundary-safe check. 4. Inspect every path component, not only the final basename, and reject sensitive directories such as `.ssh`, `.gnupg`, and cloud credential directories. 5. Add common credential filenames such as `id_ed25519`, `id_ecdsa`, and `credentials` where appropriate. 6. Prefer an explicit allowlisted upload directory over a filename denylist. 7. Require clear user confirmation before sending file contents to a third-party service. 8. Add tests covering nested sensitive directories, alternative private-key names, symlinks, broad safe-directory settings, and prefix-confusion paths. ]]>
