T09 · Insecure Skill Coding Practices
- Location
scripts/M3u8Download.py:119- Finding
Server-Side Request Forgery Through Unrestricted Playlist and Media URLs
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent M3U8 downloader, but its downloader code uses unsafe network and file handling that deserves manual review before installation.
Install only after reviewing or fixing the downloader. Use it only with trusted M3U8 URLs, prefer a sandbox with limited network and filesystem access, avoid sensitive output paths, and remove TLS bypasses and URL/path validation gaps before routine use.
scripts/M3u8Download.py:119Server-Side Request Forgery Through Unrestricted Playlist and Media URLs
scripts/M3u8Download.py:91TLS Certificate Verification Disabled for All Downloads
scripts/M3u8Download.py:78Arbitrary File Write and Unsafe Directory Removal Through User-Controlled Output Path
scripts/M3u8Download.py:160Untrusted Playlist Directives Passed to ffmpeg With Broad File Acceptance
The skill instructs use of filesystem access, network access, and shell execution via Python and ffmpeg, but it does not declare any tool scope or permission boundaries. That makes the skill harder to sandbox and review, and increases the risk of unintended or excessive capability use if invoked automatically or in a permissive agent environment.
The trigger phrases are broad enough to match generic requests like 'download video from URL' or 'download streaming video,' which could cause the skill to activate in contexts the user did not specifically intend. Because the skill performs network fetching, decryption-key retrieval, file writes, and shell-based media processing, unintended invocation materially increases exposure.
The skill explicitly supports downloading remote playlists, TS segments, and AES-128 keys, but it does not warn users that their supplied URLs and related resources will be fetched over the network and written locally. In this context, the missing warning is more significant because key retrieval and remote media processing can expose sensitive URLs, access internal resources if misused, or surprise users about what external requests are being made.
The code disables TLS certificate verification when fetching the M3U8 playlist, allowing an attacker on the network or a malicious proxy to intercept and modify the playlist contents without detection. In this skill's context, that is especially dangerous because the playlist controls subsequent segment and key URLs, enabling silent redirection to attacker-chosen media, keys, or internal endpoints.
print("m3u8_url: ", m3u8_url)
if m3u8_url.startswith("http"): # is url
try:
with requests.get(m3u8_url, timeout=(3, 30), verify=False, headers=self._headers) as res:
self._front_url = res.url.split(res.request.path_url)[0]
print("res: ", res.status_code)
if "EXT-X-STREAM-INF" in res.text: # 判定为顶级M3U8文件,则再调用一次本函数
Disabling TLS verification for TS segment downloads permits tampering with the downloaded media stream in transit. Because this downloader fetches many attacker-influenced URLs from a playlist, a man-in-the-middle can replace segments, corrupt output, or redirect requests to unintended hosts while the user sees a seemingly successful download.
try:
if not os.path.exists(name):
with requests.get(ts_url, stream=True, timeout=(5, 60), verify=False, headers=self._headers) as res:
if res.status_code == 200:
with open(name, "wb") as ts: # 这里原来是chunk 分块下载
ts.write(res.content)
Fetching encryption keys with TLS verification disabled is particularly sensitive because the key determines decryption of the media and trust in the final output. A man-in-the-middle attacker can substitute the key or redirect retrieval, causing decryption failure, content tampering, or covert replacement of protected streams.
true_key_url = self._m3u8_url.rsplit("/", 1)[0] + '/' + may_key_url
try:
with requests.get(true_key_url, timeout=(5, 30), verify=False, headers=self._headers) as res:
with open(key_path, 'wb') as f:
f.write(res.content)
# 使用相对路径引用key文件
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
'-c', 'copy', '-f', 'mp4', mp4_path]
print(f"\n执行命令: {' '.join(cmd)}\n")
print("正在合并视频...")
subprocess.run(cmd, check=True)
print("视频合并完成!")
def delete_file(self):
Natural-language policy issues apply to all file types, including code comments, docstrings, and string literals. This file presents its usage instructions, notices, and interactive prompts entirely in Chinese, with no option for another language and no indication that the tool is intentionally region-specific.
The manifest describes a skill for parsing playlists, downloading segments, handling keys, and merging to MP4. Launching the OS file browser via os.startfile is a separate local-application interaction capability that is not necessary to perform the advertised download task.
No suspicious patterns detected.