Back to skill

Security audit

Bilibili AI Subtitle

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Bilibili subtitle downloader, but it automatically reuses local browser cookies, including Windows Edge profiles under WSL, without clear opt-in or privacy warning.

Install only if you are comfortable with the skill automatically using browser cookies from local Chromium or Windows Edge profiles to access Bilibili. Prefer running it in a limited environment or after changing it to require an explicit cookie flag or user-supplied cookie file.

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
scripts/bilibili_ai_subtitle.sh:109
Finding
Predictable Temporary File Allows Symlink-Based File Overwrite## Vulnerability Details **File Location**: `scripts/bilibili_ai_subtitle.sh`, lines 109–123 **Vulnerability Type**: Predictable temporary file and unsafe symbolic-link handling **Risk Level**: Medium ### Vulnerable Code ```bash " "$VIDEO_TITLE" "$VIDEO_AUTHOR" > /tmp/safe_name_$$ SAFE_NAME=$(cat /tmp/safe_name_$$) DATE_SHORT=$(echo "$VIDEO_DATE" | sed 's/-//g') # Simplify duration DURATION_SIMPLE=$(echo "$VIDEO_DURATION" | sed 's/分/./g; s/秒//g') [ -z "$SAFE_NAME" ] && SAFE_NAME="video_unknown" # Filename: video title, uploader, date, duration, and BVID FILENAME="${SAFE_NAME}_${DATE_SHORT}_${DURATION_SIMPLE}_${BVID}.txt" OUTPUT_FILE="${OUTPUT_DIR}/${FILENAME}" rm -f /tmp/safe_name_$$ ``` The first line shown is the closing portion of a multiline `python3 -c` command whose standard output is redirected to the temporary path. ### Technical Analysis The script constructs a temporary filename in the shared `/tmp` directory using the process ID: ```bash /tmp/safe_name_$$ ``` A process ID is predictable and does not provide secure uniqueness. The file is opened through ordinary shell redirection without atomic exclusive creation, ownership verification, restrictive permissions, or symbolic-link rejection. If the path already exists as a symbolic link, the shell follows that link when processing `>`, truncating and writing to its target with the privileges of the user running the script. The subsequent `cat` and `rm` operations do not mitigate the initial unsafe write. In addition, `rm` removes the symbolic link itself rather than reversing modifications made to its target. Exploitation requires local access sufficient to create entries in `/tmp`, an ability normally available to local users. The attacker must predict or observe the victim process ID and win the race before the redirection occurs. ### Attack Path 1. A local attacker predicts or observes the process ID that will be assigned to the script. 2. The attacker creates `/tmp/safe_name_<PI ...[truncated 1194 chars]
Remediation
## Remediation Suggestions Avoid creating the temporary file because the Python output can be captured directly: ```bash SAFE_NAME=$(python3 -c ' import sys title = sys.argv[1] author = sys.argv[2] # Apply the existing sanitization logic here. print(f"{title}_{author}") ' "$VIDEO_TITLE" "$VIDEO_AUTHOR") || exit 1 ``` If a temporary file is necessary: 1. Create it atomically with `mktemp` rather than constructing a PID-based path. 2. Restrict permissions with `umask 077`. 3. verify that `mktemp` succeeded before writing. 4. Register a quoted cleanup trap immediately after creation. 5. Do not use a caller-controlled directory for security-sensitive temporary files. Example: ```bash umask 077 SAFE_NAME_FILE=$(mktemp "${TMPDIR:-/tmp}/bilibili-safe-name.XXXXXX") || { echo "Failed to create a secure temporary file" >&2 exit 1 } trap 'rm -f -- "$SAFE_NAME_FILE"' EXIT HUP INT TERM python3 -c '...' "$VIDEO_TITLE" "$VIDEO_AUTHOR" > "$SAFE_NAME_FILE" || exit 1 SAFE_NAME=$(cat -- "$SAFE_NAME_FILE") || exit 1 ``` Direct command substitution is preferable because it removes the temporary-file attack surface entirely.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The skill’s declared purpose is narrowly framed as downloading AI subtitles, but the documentation also reveals materially broader behavior: automatic use of local browser cookies, collection of additional video metadata, content transformation into a derived transcript/summary document, and file creation on disk. This mismatch undermines informed user consent and can lead an agent or user to authorize access to credentials and local resources they would not reasonably expect from the description alone.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
FILENAME="${SAFE_NAME}_${DATE_SHORT}_${DURATION_SIMPLE}_${BVID}.txt"
OUTPUT_FILE="${OUTPUT_DIR}/${FILENAME}"

rm -f /tmp/safe_name_$$

# ===== 检测浏览器Cookie =====
echo "🔍 检测浏览器Cookie..."
Confidence
95% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

YARA rule 'info_stealer': Information stealer patterns (credential harvesting, browser data theft) [malware]

High
Category
YARA Match
Content
fi
fi

# 2. 尝试 Windows Edge
if [ "$FOUND_COOKIE" = false ]; then
    WIN_USER=$(ls /mnt/c/Users/ 2>/dev/null | grep -v "Public\|Default\|All Users" | head -1)
    if [ -n "$WIN_USER" ]; then
        EDGE_PATH="/mnt/c/Users/$WIN_USER/AppData/Local/Microsoft/Edge/User Data"
        if [ -d "$EDGE_PATH" ]; then
            echo "   🔑 使用 Windows Edge Cookie"
            COOKIE_PARAM="--cookies-from-browser edge:C:/Users/$WIN_USER/AppData/Local/Microsoft/Edge/User Data"
            FOUND_COOKIE=true
        fi
    fi
fi

[ "$FOUND_COOKIE" = false ] && echo "   ℹ️ 无可用Cookie,尝试无Cookie模式"
echo ""

# ===== 检测AI字幕 =====
echo "🔍 检测AI字幕..."
echo "   🌐 语言优先级: $LANG_PRIORITY"

if [ "$FOUND_COOKIE" = true ]; then
    SUB_LIST=$(yt-dlp --list-subs --write-auto-subs $COOKIE_PARAM "$VIDEO_URL" 2>&1)
else
    SUB_LIST=$(yt-dlp --list-subs --write-auto-subs "$VIDEO_URL" 2>&1)
fi

echo "$SUB_LIST" | grep -E "(subtitle|Available|ai-)" | he
Confidence
98% confidence
Finding
The Windows Edge cookie access pattern is a real credential/session access concern, not just an abstract malware signature hit. In context, the script enumerates Windows user directories and points yt-dlp at an Edge profile to extract cookies, which can expose authenticated browser data beyond what is necessary for a simple subtitle task.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The skill states that it will automatically detect and use Chromium/Edge cookies for access to member-only videos, but it does not clearly warn that this involves accessing local authenticated browser data. In an agent setting, silent credential reuse can expose private account context, enable unintended access to gated content, and surprise users who did not intend to share browser session material with the tool.

Context-Inappropriate Capability

Medium
Confidence
97% confidence
Finding
The script probes local browser profiles and uses browser cookies from Chromium and Windows Edge without explicit user opt-in. Accessing browser cookie stores is broader than necessary for a subtitle downloader and can expose authenticated session material to downstream tooling, especially in mixed WSL/Windows environments.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The script accesses browser cookies without any upfront warning in the header or help output, so users may unknowingly allow local credential/session access. Hidden credential access is risky because users cannot make an informed consent decision and may run the skill in privileged environments where browser profiles contain active sessions.

Description-Behavior Mismatch

Medium
Confidence
96% confidence
Finding
The manifest describes a skill for downloading Bilibili AI-generated subtitles, which implies fetching subtitle data. Here the script transforms the subtitles into a formatted report containing video metadata, a derived summary section, and full transcript text, then writes it to a text file rather than simply returning/downloading subtitles.

Static analysis

No suspicious patterns detected.