T09 · Insecure Skill Coding Practices
- Location
scripts/extract_subtitles.py:103- Finding
Persistent Plaintext Export of Browser Session Cookies
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent video-notes tool, but it needs Review because it can access browser sessions, leave exported cookies in /tmp, install unpinned code at runtime, and generate scriptable HTML from untrusted captions.
Install only if you are comfortable running video-download tooling locally. Avoid using browser-cookie mode for private, paid, or sensitive accounts unless you understand the risk, and delete /tmp/yt-cookies-export.txt after any run. Prefer an isolated environment with pinned dependencies, and treat generated HTML from untrusted videos as potentially active content.
scripts/extract_subtitles.py:103Persistent Plaintext Export of Browser Session Cookies
scripts/extract_subtitles.py:37Automatic Installation of an Unpinned Runtime Dependency
assets/note-template.html:152Stored Script and HTML Injection Through Untrusted Subtitle Data
The skill’s declared purpose is note generation, but the workflow also includes browser-cookie use and authenticated content access that are not transparently declared as sensitive capabilities. This mismatch is dangerous because users and policy systems may approve the skill for summarization while overlooking credential-adjacent behavior and shell-based media retrieval steps.
The skill explicitly instructs use of --cookies-from-browser chrome and even states that cookies may be automatically exported as a fallback. Accessing browser cookies is credential-adjacent and can expose authenticated session tokens for YouTube/Bilibili accounts; if mishandled, those tokens could be abused to access private or paid content or leak user account state.
:不加 --lang
--lang zh 或 --lang zh-HansYouTube 认证问题(常见!):
若直接运行报错 Sign in to confirm you're not a bot 或 No subtitles found,需要传入浏览器 cookies:
# 使用 Chrome cookies(推荐)
python3 ~/.claude/skills/video-notes/scripts/extract_subtitles.py <url> \
--output /tmp/subs.json \
--cookies-from-browser chrome
# 或使用已导出的 cookies 文件
python3 ~/.claude/skills/video-notes/scripts/extract_subtitles.py <url> \
--output /tmp/subs.json \
--cookies /tmp/yt-cookies.txt
脚本内置降级策略(自动执行,无需手动干预):
--skip-download 直接获取字幕(速度最快)-f sb3(storyboard 格式,YouTube 始终可用)触发字幕下载,解析 VTT 格式YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
btitles.py <url> [--output <path>] [--lang <lang>]
[--cookies-from-browser <browser>]
[--cookies <cookie_file>]
Output JSON format:
[{"t": "mm:ss", "s": <seconds_float>, "text": "<content>"}, ...]
YouTube 注意事项:
- 若遇到 "Sign in to confirm" 或 "Requested format is not available",
需要传入 --cookies-from-browser chrome(或 firefox/safari),
脚本会自动先导出 cookies 文件,再以 storyboard 格式触发字幕下载。
- 字幕格式优先尝试 VTT(与 yt-dlp storyboard 下载兼容),失败则回退 SRT。
哔哩哔哩注意事项:
- 用 --lang zh 或 --lang zh-Hans 提取中文字幕。
- 部分视频需要登录 cookie,用 --cookies-from-browser chrome。
- 哔哩哔哩上传字幕(非 AI 生成)用 --write-subs 而非 --write-auto-subs,
脚本已自动兼容处理。
"""
import sys
import re
import json
import subprocess
import temp
The README describes generating subtitles, screenshots, transcripts, and a self-contained local HTML document from video content, but it does not clearly warn users about the resulting data collection, local storage, and possible privacy/copyright implications. In a skill that processes potentially sensitive internal recordings or private/unlisted videos, this omission can lead users to expose or retain more content than they intended.
The skill instructs the agent to read and write local files and execute shell commands, but it declares no explicit tool scope or permission boundaries. That creates an authorization gap: the runtime may permit powerful operations without transparent least-privilege constraints, increasing the risk of unintended file access or command execution beyond the user’s expectations.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
slug: video-notes
version: 1.1.0
author: 2992638402-art
description: 把 YouTube / 哔哩哔哩视频变成一份精美的结构化笔记。自动提取字幕、识别关键时刻并截图、生成核心论点总结和 SVG 图表,输出带侧边导航和全文搜索的单文件 HTML 文档。适用于技术演讲、公开课、播客、产品发布会等场景。This skill should be used when a user provides a YouTube or Bilibili URL and asks to take notes, summarize a video, or create a study document from video content.
---
# Video Notes Skill
Automatically installing yt-dlp at runtime via pip is dangerous because it executes package installation logic and modifies the host environment during normal skill execution. This creates a software supply chain risk, weakens reproducibility, and the use of --break-system-packages explicitly bypasses environment protections, increasing the chance of host compromise or destabilization if package resolution is tampered with or an unsafe mirror/index is used.
try:
import yt_dlp # noqa
except ImportError:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "yt-dlp", "-q", "--break-system-packages"],
stderr=subprocess.DEVNULL,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
"-vf", "scale=960:-2", # resize to 960px wide
out_path,
]
result = subprocess.run(cmd, capture_output=True)
return result.returncode == 0 and os.path.exists(out_path)
Dynamically installing a package at runtime is beyond the minimum permissions and behavior expected from a note-taking/subtitle tool, especially when it modifies system packages. This creates supply-chain and environment-integrity risks, and the skill context makes it more concerning because users would not expect installation side effects from a content-processing helper.
The script installs yt-dlp dynamically at runtime via pip with --break-system-packages, which modifies the host environment and executes package installation code outside the stated subtitle-extraction task. This expands the trust boundary to package indexes/network delivery and can unexpectedly alter the system, making the skill more dangerous than a normal read/process utility.
try:
import yt_dlp # noqa
except ImportError:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "yt-dlp", "-q", "--break-system-packages"],
stderr=subprocess.DEVNULL
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
*extra_args,
url,
]
result = subprocess.run(cmd, capture_output=True, text=True)
for f in os.listdir(tmpdir):
if f.endswith(f".{sub_fmt}") or f.endswith(".srt"):
path = os.path.join(tmpdir, f)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
*extra_args,
url,
]
result = subprocess.run(cmd, capture_output=True, text=True)
for f in os.listdir(tmpdir):
if f.endswith(f".{sub_fmt}") or f.endswith(".srt"):
path = os.path.join(tmpdir, f)
Exporting browser cookies to a fixed file path without explicit user-facing warning or secure lifecycle handling risks disclosure of active authenticated sessions. Because this skill may be run on user machines and the cookies can grant access to YouTube/Bilibili or other browser-scoped services, the context makes credential exposure materially dangerous.
This code exports browser-derived authentication cookies to a fixed path under /tmp, which can expose sensitive session material to other local processes or users depending on system configuration, race conditions, or leftover files. In the context of a skill processing untrusted inputs, handling browser cookies in a predictable shared location increases credential leakage risk beyond what is necessary for subtitle extraction.
# First export cookies to a file so we don't re-authenticate per attempt
if cookies_browser and not cookies_file:
cookies_file = "/tmp/yt-cookies-export.txt"
subprocess.run(
[sys.executable, "-m", "yt_dlp",
"--cookies-from-browser", cookies_browser,
"--cookies", cookies_file,
README 全部以中文描述,并在示例触发语中仅提供中文用法,没有说明是否支持其他语言或给予用户语言选择。按自然语言策略,若技能对语言/locale 作出隐含强制要求而无用户选择,可能构成语言政策问题。
The document root sets lang="zh-CN", which hard-codes a specific language/locale for rendered output. Under the policy, forcing a locale without offering user choice or documenting a justified regional constraint is a natural-language policy concern.
The module docstring presents key usage guidance for YouTube and Bilibili in Chinese only, which imposes a language choice on users without opt-in. This is a natural-language policy concern because the file otherwise uses English for usage text and does not indicate that Chinese-only guidance is intentional or region-specific.