Back to skill

Security audit

Clip

Security checks for vulnerabilities and agentic risk

Overview

This skill does what it says: it downloads a YouTube video, clips the requested range, and saves it locally, with a minor temporary-file safety weakness to be aware of.

Install only if you are comfortable with the skill downloading media from supplied URLs and writing clips to ~/Desktop/Clips. Use unique clip names to avoid overwriting outputs, and avoid running it in a hostile shared-machine environment because its temporary work directory is predictable.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
clip.sh:7
Finding
Predictable Shared Temporary Directory Enables File Races and Symlink Attacks<![CDATA[ ## Vulnerability Details **File Location**: `clip.sh`, lines 7-8 and 38-53 **Vulnerability Type**: Predictable and insecure temporary-file handling **Risk Level**: Medium ### Vulnerable Code ```bash WORK_DIR="/tmp/youtube-clipper" mkdir -p "$OUT_DIR" "$WORK_DIR" ``` ```bash SRC="$WORK_DIR/${NAME}_source.mp4" OUT="$OUT_DIR/${NAME}.mp4" REAL_OUT="$(cd "$OUT_DIR" && realpath -m "$OUT")" [[ "$REAL_OUT" == "$OUT_DIR/"* ]] || { echo "Invalid clip name: escapes output directory"; exit 2; } rm -f "$SRC" echo "Downloading..." yt-dlp --no-playlist -f "bv*+ba/b" --merge-output-format mp4 -o "$SRC" -- "$URL" [[ ! -f "$SRC" ]] && { echo "Download failed"; exit 1; } echo "Clipping..." # ffmpeg -y -ss "$START" -to "$END" -i "$SRC" -c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart "$OUT" ffmpeg -y -ss "$START" -to "$END" -i "$SRC" -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart "$OUT" rm -f "$SRC" ``` ### Technical Analysis The script stores downloaded media in the fixed directory `/tmp/youtube-clipper` and derives the source filename solely from a predictable, sanitized clip name. It does not create a private per-execution directory with an unpredictable name, verify ownership and permissions of an existing directory, or atomically reserve the source file. The initial `rm -f "$SRC"` does not eliminate the vulnerability because checking or removing a pathname and subsequently passing that same pathname to `yt-dlp` are separate operations. Another local process can alter the path between those operations. An attacker may also pre-create `/tmp/youtube-clipper` before the skill is first executed, causing the script to reuse an attacker-controlled directory because `mkdir -p` accepts an existing directory without validating its owner or mode. Depending on the filesystem and downloader behavior, an attacker-controlled file or symbolic link can redirect or interfere with w ...[truncated 2279 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Create a private, unpredictable temporary directory for every execution using `mktemp -d`. Restrict its permissions and install an exit trap so cleanup occurs on success, failure, interruption, or termination. ```bash WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/youtube-clipper.XXXXXX")" chmod 700 "$WORK_DIR" cleanup() { rm -rf -- "$WORK_DIR" } trap cleanup EXIT HUP INT TERM SRC="$WORK_DIR/source.mp4" ``` Additional hardening measures: 1. Do not reuse a fixed directory under `/tmp`. 2. Fail immediately if `mktemp -d` cannot securely create the directory. 3. Keep all intermediate files inside the private per-run directory. 4. Use a constant source filename inside that unpredictable directory rather than deriving it from user input. 5. Retain quoting and `--` argument separators when invoking tools and deleting files. 6. Use the cleanup trap instead of relying only on the final `rm -f`, ensuring downloaded media is removed after errors. 7. If a shared directory must be used, validate that it is a real directory, is owned by the invoking user, is not a symbolic link, and has mode `0700`; a private `mktemp` directory is nevertheless preferable. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Missing User Warnings

Low
Confidence
92% confidence
Finding
This markdown file describes file-creating and file-deletion behavior, but presents it as ordinary operation without an explicit caution or warning to the user about modifying local files. Under the markdown-specific warning rule, behaviors affecting user data or system state should be clearly disclosed as warnings, especially the cleanup deletion step.

Static analysis

No suspicious patterns detected.