T09 · Insecure Skill Coding Practices
- Location
scripts/sync.sh:55- Finding
Destination Path Traversal Allows Writes Outside the Obsidian Vault
- Content
View full analysis
/dev/null ``` ### Technical Analysis The optional `DEST_SUBDIR` argument is concatenated directly with the supplied Vault path. The script does not reject absolute paths or `..` path components, canonicalize the resulting destination, or verify that the resolved destination remains beneath the canonical Vault directory. For example, a value such as `../../outside` causes `DEST_DIR` to resolve outside the intended Vault. Existing symbolic links in destination path components may similarly redirect the write operation outside the Vault boundary. Although the values are shell-quoted and therefore do not provide shell command injection, quoting does not prevent filesystem path traversal. ### Attack Path 1. An attacker obtains influence over the third argument passed to `sync.sh`, such as through an automated agent request or a wrapper that forwards untrusted destination names. 2. The attacker supplies a traversal value: ```bash bash scripts/sync.sh /path/to/source /home/user/Vault ../../target ``` 3. The script constructs: ```text /home/user/Vault/../../target ...[truncated 890 chars]- Remediation
View remediation
&2 exit 1 ;; ..|../*|*/../*|*/..) echo "Error: destination subdirectory cannot contain '..'" >&2 exit 1 ;; esac VAULT_REAL="$(cd "$OBSIDIAN_VAULT" && pwd -P)" mkdir -p -- "$VAULT_REAL/$DEST_SUBDIR" DEST_REAL="$(cd "$VAULT_REAL/$DEST_SUBDIR" && pwd -P)" case "$DEST_REAL" in "$VAULT_REAL"|"$VAULT_REAL"/*) ;; *) echo "Error: destination escapes the Obsidian Vault" >&2 exit 1 ;; esac ``` If symlink traversal is unacceptable, additionally inspect each destination component or create directories using a mechanism that refuses symlink components. ]]>
