T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:61
- Finding
- Shell and Python Injection Through Unsafe Input Interpolation<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:61`, `SKILL.md:78`, `SKILL.md:205-207`, `references/rclone-ops.md:18-24`, `references/rclone-ops.md:30`, `references/http-temp-link.md:25-26` **Vulnerability Type**: Command injection through unsafe shell and Python interpolation **Risk Level**: High ### Vulnerable Code `SKILL.md:61`: ```bash rclone lsf nas:<SHARE> --recursive --include "*关键词*" ``` `SKILL.md:78`: ```bash rclone lsl nas:<SHARE>/path/to/file.pdf ``` `SKILL.md:205-207`: ```text 🔍 搜索: rclone lsf nas:<SHARE> --recursive --include "*keyword*" 📏 大小: rclone size nas:<SHARE>/path --json 📥 下载: rclone copy nas:<SHARE>/path /tmp/openclaw/nas-courier/ ``` `references/rclone-ops.md:18-24`: ```bash rclone lsf nas:<SHARE> --recursive --include "*关键词*" # 按扩展名 + 关键词 rclone lsf nas:<SHARE> --recursive --include "*关键词*.pdf" # 按修改时间过滤(最近 N 天) rclone lsf nas:<SHARE> --recursive --include "*关键词*" --max-age 30d ``` `references/rclone-ops.md:30`: ```bash rclone lsl nas:<SHARE>/path/to/file.pdf ``` `references/http-temp-link.md:25-26`: ```bash FILENAME="file.pdf" # 替换为实际文件名 ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('${FILENAME}'))") ``` ### Technical Analysis The documented commands interpolate user-controlled search terms, share names, paths, and potentially NAS-controlled filenames into shell commands. Several rclone examples do not establish safe argument boundaries around the remote specification. Even where double quotes are shown, double quotes do not neutralize shell command substitution constructs such as `$(...)` or backticks when generated command text is subsequently interpreted by a shell. The HTTP-link procedure introduces an additional injection boundary by embedding `FILENAME` directly into Python source code. A filename containing a single quote can terminate the `urllib.parse.quote()` string literal and append attacker-controlled Python syntax. Because the Python interpreter is launched by the ...[truncated 1320 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Invoke rclone through an execution API that accepts an argument array and does not invoke a shell. - Treat search terms, share names, remote paths, and filenames as untrusted data. - Validate share names against an explicit allowlist of configured NAS shares. - Reject control characters, path traversal, unexpected remote syntax, and embedded shell metacharacters where they are not required. - Preserve user values as individual arguments rather than concatenating them into command strings. - Pass the filename to Python through `argv` rather than embedding it in Python source: ```bash ENCODED=$(python3 -c \ 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' \ "$FILENAME") ``` - If shell execution cannot be avoided, use positional parameters with a fixed script body and never evaluate dynamically generated command text. - Add tests using filenames and search terms containing spaces, quotes, backticks, `$()`, semicolons, newlines, and leading hyphens. ]]>
