T09 · Insecure Skill Coding Practices
- Location
scripts/memory-write-tag.sh:17- Finding
Arbitrary File Write Through Unrestricted Target Path
- Content
View full analysis
"$ABS_TARGET" else cat "$CONTENT_FILE" >> "$ABS_TARGET" fi ``` ### Technical Analysis The script is presented as a helper for writing Markdown memory, but it does not constrain the target to the workspace's `memory` directory. It accepts: - Absolute target paths. - Relative paths containing traversal sequences such as `../../`. - Targets that resolve through symbolic links. - Files without a `.md` extension. - Any mode other than `write`, which silently falls into append behavior. Shell quoting prevents direct shell metacharacter injection, but it does not prevent path traversal or unrestricted filesystem modification. The write occurs with the privileges of the user running the Skill. The subsequent tagger does not mitigate the issue. The dangerous write is completed before tagging begins, and the tagger only processes existing `.md` files. ### Attack Path 1. An attacker supplies content or instructions that influence the arguments passed to `memory-write-tag.sh`. 2. The attacker chooses an absolute path or a traversal path, for example: `../../.config/example/config.yaml`. 3. The attacker supplies a controlled content file and selects `write` or append behavior. 4. The script resolves the path without checking whether it remains under `$WORKSPACE/memory`. 5. `cat` overwrites or appends attacker-controlled content to the selected file. 6. If the affected file is later loaded or executed by another application, the modification can produce additional effects under that application's privileges. ### Impact Assessment An attacker can m ...[truncated 484 chars]- Remediation
View remediation
