T09 · Insecure Skill Coding Practices
- Location
SKILL.md:214- Finding
User-Controlled Topic Enables Path Traversal and Arbitrary File Overwrite
- Content
View full analysis
"round1-${DATE}.txt" # 第二轮:聚焦搜索(基于领先轮结果细化) echo "=== 第二轮:聚焦搜索 ===" .sh "${TOPIC} 优选实践" 5 > "round2-${DATE}.txt" # 合并结果 cat "round1-${DATE}.txt" "round2-${DATE}.txt" > "research-${TOPIC}-${DATE}.md" echo "调研结果已归档到 research-${TOPIC}-${DATE}.md" ``` ### Technical Analysis The documented archival workflow accepts the first command-line argument as `TOPIC` and inserts it directly into the destination pathname: ```bash > "research-${TOPIC}-${DATE}.md" ``` Shell quoting prevents word splitting and command substitution from values already stored in the variable, but it does not make the value safe for use as a filename. Path separators and traversal components such as `../` remain effective. An attacker who can influence `TOPIC` can therefore direct the shell redirection outside the intended working directory. Shell output redirection opens the resolved destination with truncation by default. If the selected path already exists and is writable by the Agent process, its contents can be destroyed before `cat` writes the search results. If it does not exist, the process may create it where parent-directory permissions allow. The project only contains `SKILL.md`, and the referenced `.sh` search command is absent or malformed. Consequently, the issue exists in the workflow instructions rather than in a packaged executable script. Exploitation requires an Agent or user to implement or execute the documented example. ### Attack Path 1. An attacker supplies or influences the topic passed to the documented workflow. 2. The attacker selects a traversal-bearing value that resolves to a writable location outside the intended archive dire ...[truncated 1470 chars]- Remediation
View remediation
&2 exit 1 fi cat "round1-${DATE}.txt" "round2-${DATE}.txt" > "$DESTINATION" printf 'Research results archived to %s\n' "$DESTINATION" ``` If a human-readable name is required, apply a strict allowlist such as ASCII letters, digits, underscores, and hyphens, enforce a short maximum length, and still verify that the canonical destination remains inside `ARCHIVE_DIR`. ]]>
