T09 · Insecure Skill Coding Practices
- Location
scripts/batch_http.py:65- Finding
Private-Network and Cloud-Metadata SSRF Through Unvalidated Scraping URLs
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a disclosed webpage archiving skill, but its default live-browser access and local CDP proxy can expose logged-in browser sessions and need careful review.
Install only if you genuinely need authenticated browser archiving. Prefer --isolated or HTTP mode, avoid running it with your real Chrome profile, use a disposable browser/VM for login-required pages, validate input URLs, and stop/clean the CDP proxy state after use.
scripts/batch_http.py:65Private-Network and Cloud-Metadata SSRF Through Unvalidated Scraping URLs
scripts/cdp_proxy.py:370CDP Proxy Authentication Token Disclosure and Unauthenticated Browser-Control Endpoints
Running a local CDP proxy with HTTP endpoints for target management, background daemon behavior, temp state files, PID files, and auth tokens is a substantial hidden capability compared with a claimed conversion tool. Even if bound to localhost, such a proxy expands attack surface and can enable local abuse, session brokering, or persistence-like behavior if mishandled or left running.
Running a local CDP proxy with HTTP endpoints for target management, background daemon behavior, temp state files, PID files, and auth tokens is a substantial hidden capability compared with a claimed conversion tool. Even if bound to localhost, such a proxy expands attack surface and can enable local abuse, session brokering, or persistence-like behavior if mishandled or left running.
Running a local CDP proxy with HTTP endpoints for target management, background daemon behavior, temp state files, PID files, and auth tokens is a substantial hidden capability compared with a claimed conversion tool. Even if bound to localhost, such a proxy expands attack surface and can enable local abuse, session brokering, or persistence-like behavior if mishandled or left running.
Running a local CDP proxy with HTTP endpoints for target management, background daemon behavior, temp state files, PID files, and auth tokens is a substantial hidden capability compared with a claimed conversion tool. Even if bound to localhost, such a proxy expands attack surface and can enable local abuse, session brokering, or persistence-like behavior if mishandled or left running.
Running a local CDP proxy with HTTP endpoints for target management, background daemon behavior, temp state files, PID files, and auth tokens is a substantial hidden capability compared with a claimed conversion tool. Even if bound to localhost, such a proxy expands attack surface and can enable local abuse, session brokering, or persistence-like behavior if mishandled or left running.
The skill explicitly states that default mode reuses the real Chrome profile and can access cookies and logged-in sessions. In context, this is not merely an informational false positive: a URL-conversion skill with browser-profile reuse and CDP control has information-stealer-like capability because it can access authenticated browser state unrelated to the user’s expectation of simple document export.
e | Public content / 公开内容 |
| **Default / 默认** | `main.py <URL>` | Reuse Chrome real Profile / 复用 Chrome 真实 Profile | WeChat articles requiring login / 需登录态的微信文章 |
### 风险与缓解 | Risks & Mitigations
| Risk / 风险项 | Description / 说明 | Mitigation / 缓解措施 |
|--------|------|----------|
| Profile reuse / Profile 复用 | Can access Chrome cookies/login sessions / 可访问 Chrome Cookie/登录态 | ✅ Always use `--isolated` for public content / 公开内容一律用 `--isolated` |
| CDP remote debugging / CDP 远程调试 | Enables Chrome DevTools protocol / 开启 Chrome DevTools 协议 | Only listens on `127.0.0.1:9222~9232` (localhost) / 仅监听本机 |
| CDP Proxy | Creates local proxy daemon / 创建本地代理守护进程 | Only bound to `127.0.0.1`, external access blocked / 仅绑定本机;WS 需 Token 验证 |
| Browser launch / 浏览器启动 | May reuse existing browser window / 可能复用已有浏览器窗
The module exposes arbitrary JavaScript execution through both the evaluate() method and the CLI eval subcommand, which goes well beyond a URL-to-PDF/Markdown archival purpose. In the stated context, browser mode may reuse a real Chrome profile, so arbitrary page-context JS can interact with authenticated sessions, inspect page data, and trigger privileged actions on sites the user is logged into.
get_cookies() provides direct access to browser cookies, a sensitive credential source unrelated to ordinary webpage-to-PDF conversion. Because the skill explicitly warns that default browser mode reuses the user's Chrome profile, this capability could expose authenticated session tokens and materially increase account compromise risk.
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
SKILL_DIR = os.path.dirname(os.path.abspath(__file__))
# 调用子脚本时注入环境变量(强制入口检查)
ENV_MAIN = {**os.environ, 'URL2PDFMK_ENTRY': 'main'}
# ══════════════════════════════════════════════════════════════
# 0. 检测 Chrome 是否可用
The skill requests or implies broad capabilities including environment access, file read/write, network, and shell execution, but does not declare an explicit tool scope. That makes the effective privilege boundary opaque to users and reviewers, increasing the chance of unintended high-privilege execution paths for a skill that drives a browser, touches temp files, and writes output.
The activation description includes broad phrases such as "网页保存" and "保存链接," which can easily occur in ordinary conversation and are not specific to this skill's exact behavior. The trigger list also ends with "等时触发此技能," making the invocation scope open-ended rather than tightly constrained.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
4. **CDP Port Security / CDP 端口安全**: CDP debugging ports are bound to `127.0.0.1` only, external network cannot access. WebSocket connections require Token verification.
5. **Don't Run as Root / 不要以 root 运行**: Run with normal user privileges recommended / 建议以普通用户权限运行此工具。
6. **VM / Sandbox / 虚拟机 / 沙箱**: If you must run browser mode with your real profile, do so inside a VM or disposable environment to limit exposure.
The module docstring states it generates Markdown files and that PDF must be produced manually in a browser, and the implementation only writes a .md file. This is materially narrower than the manifest's promise of converting URLs into offline-readable PDF and Markdown files automatically.
The file implements broad browser automation primitives including click, keypress, fill, select, tab control, scrolling, and DOM-triggered interaction. While such capabilities can be useful in scraping or rendering difficult pages, they also enable full session automation on authenticated websites, which is materially broader than simple archival and becomes more dangerous given Chrome-profile reuse.
The arbitrary JS execution feature is not just powerful but also insufficiently disclosed within the code path itself, despite enabling execution in the context of visited pages. In this skill, lack of in-product warning is significant because users may reasonably expect document conversion, not page-side code execution against live logged-in sessions.
Cookie access is implemented as a callable helper without any user-facing prompt, consent flow, or runtime warning. In a tool whose advertised purpose is webpage conversion, undisclosed access to session cookies creates a transparency and trust violation with real security consequences if the capability is exposed upstream.
This Python file contains extensive natural-language documentation and runtime prompts in Chinese, including the module docstring and many printed guidance/error messages. Because the file does not offer a locale selection, fallback language, or explicit justification for a China-specific audience, it violates the language/locale policy for natural-language behavior.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
pattern = exe_patterns.get(browser)
if pattern:
try:
result = subprocess.run(
['pgrep', '-f', pattern],
capture_output=True, text=True, timeout=5,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
exe = exe_names.get(browser)
if exe:
try:
result = subprocess.run(
['tasklist', '/FI', f'IMAGENAME eq {exe}', '/FO', 'CSV', '/NH'],
capture_output=True, text=True, timeout=5,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
}
for p in patterns.get(browser, []):
try:
result = subprocess.run(
['pgrep', '-f', p],
capture_output=True, text=True, timeout=5,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
try:
if SYSTEM in ('Darwin', 'Linux'):
# lsof -iTCP:9222 -sTCP:LISTEN -nP -t → prints PIDs only
result = subprocess.run(
['lsof', f'-iTCP:{port}', '-sTCP:LISTEN', '-nP', '-t'],
capture_output=True, text=True, timeout=3,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
f'-ErrorAction SilentlyContinue | '
f'Select-Object -First 1 -ExpandProperty OwningProcess'
)
result = subprocess.run(
['powershell', '-NoProfile', '-NonInteractive',
'-Command', ps_cmd],
capture_output=True, text=True, timeout=5,
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
f'-ErrorAction SilentlyContinue | '
f'Select-Object -First 1 -ExpandProperty OwningProcess'
)
result = subprocess.run(
['powershell', '-NoProfile', '-NonInteractive',
'-Command', ps_cmd],
capture_output=True, text=True, timeout=5,
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
# --- Strategy 2: netstat -ano (fallback) ---
try:
result = subprocess.run(
['netstat', '-ano'],
capture_output=True, text=True, timeout=5,
creationflags=getattr(subprocess, 'CREATE_NO_WINDOW', 0),
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
try:
if SYSTEM == 'Darwin':
result = subprocess.run(
['ps', '-p', str(pid), '-o', 'command='],
capture_output=True, text=True, timeout=3,
)