T09 · Insecure Skill Coding Practices
- Location
scripts/process.sh:169- Finding
Untrusted Markdown Paths Can Upload and Delete Arbitrary User-Readable Files
- Content
View full analysis
/dev/null && pwd)/$(basename "$full_path") 2>/dev/null || true # Check if file exists if [ ! -f "$full_path" ]; then echo " ⚠️ File not found: $image_path" >&2 : $((fail_count++)) continue fi ``` ```bash # Upload image echo " Uploading: $image_path..." local new_url new_url=$(upload_image "$full_path") if [ -n "$new_url" ]; then # Replace all occurrences in content content="${content//"$match"/}" : $((upload_count++)) # Track for deletion (use full_path as key) uploaded_files["$full_path"]=1 # Delete local file immediately after successful upload delete_local_image "$full_path" ``` The deletion function used by this path is: ```bash delete_local_image() { local image_path="$1" if [ "$KEEP_LOCAL" = true ]; then return 0 fi if [ -f "$image_path" ]; then local dir_path dir_path="$(dirname "$image_path")" rm -f "$image_path" echo " 🗑️ Deleted: $image_path" deleted_dirs["$dir_path"]=1 fi } ``` ### Technical Analysis The script treats every non-HTTP Markdown image target as a local file path. It canonicalizes the target but does not verify that the resulting path remains inside the Markdown directory or another explicitly authorized upload root. Consequently, path traversal components such as `../` are accepted. Absolute-path-like and symlink-assisted references may also escape the intended content directory, depending on how the path is represented and resolved. The documented image-extension list is not enforced, and neither the file extension nor the file's MIME signature ...[truncated 1559 chars]- Remediation
View remediation
