Back to skill

Security audit

xiaofei自用-WeChat Article Scraper

Security checks for vulnerabilities and agentic risk

Overview

The skill is broadly a WeChat article scraper, but it needs review because it can drive unsandboxed Chrome to weakly validated URLs and download files without strong limits.

Review before installing. Use this only in a constrained environment, only with trusted WeChat article URLs, and avoid pointing --cache-dir at an important existing directory. The publisher should add strict HTTPS hostname and redirect allowlists, remove or isolate --no-sandbox Chrome, cap image downloads, and correct the Feishu automation claims.

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 (3)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/scrape.py:19
Finding

Insufficient URL Validation Allows Unintended Browser Navigation

Content
View full analysis
dict: """抓取微信公众号文章""" if not url or "mp.weixin.qq.com" not in url: raise ValueError("请提供有效的微信公众号文章链接(mp.weixin.qq.com)") ``` The URL is then passed directly to Chrome: ```python cmd = [ chrome_path, "--headless=new", "--disable-gpu", "--no-sandbox", f"--user-agent={ua}", "--disable-blink-features=AutomationControlled", "--no-first-run", "--no-default-browser-check", "--virtual-time-budget=20000", "--dump-dom", url ] result = subprocess.run( cmd, capture_output=True, text=True, timeout=40 ) ``` The importer performs no equivalent validation before navigation: ```python def fetch_article_html(url: str, timeout: int = 40) -> str: """用 Chrome headless 抓取文章完整 HTML""" cmd = [CHROME_PATH] + ANTI_DETECT_ARGS + [ f"--virtual-time-budget=20000", "--dump-dom", url ] result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout) ``` ```python url = args.url.strip() # 自动生成带时间戳的缓存目录 if args.cache_dir: cache_dir = args.cache_dir else: ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") cache_dir = f"/tmp/wechat_article_{ts}" os.makedirs(cache_dir, exist_ok=True) # Step 1: 抓取 HTML html = fetch_article_html(url) ``` ### Technical Analysis A substring test does not verify the actual URL scheme or hostname. For example, the following attacker-controlled URL contains the required string but does not navigate to WeChat: ```text https://attacker.example/article?source=mp.weixin.qq.com ``` The import script i ...[truncated 2068 chars]
Remediation
View remediation
str: parsed = urlsplit(value) if parsed.scheme != "https": raise ValueError("Only HTTPS article URLs are allowed") if parsed.hostname != "mp.weixin.qq.com": raise ValueError("Only mp.weixin.qq.com article URLs are allowed") if parsed.username or parsed.password: raise ValueError("URLs containing credentials are not allowed") if parsed.port not in (None, 443): raise ValueError("Unexpected URL port") return value ``` ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/scrape_and_import.py:38
Finding

Headless Chrome Processes Untrusted Pages with Sandbox Disabled

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/scrape_and_import.py:64
Finding

Unbounded and Weakly Validated Image Downloads Enable Resource Exhaustion

Content
View full analysis
str: """下载单张图片,返回本地文件名""" headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'Referer': 'https://mp.weixin.qq.com/' } try: req = urllib.request.Request(url, headers=headers) with urllib.request.urlopen(req, timeout=15) as resp: data = resp.read() with open(fpath, 'wb') as f: f.write(data) fname = os.path.basename(fpath) print(f" [OK] {fname} ({len(data)//1024}KB)") return fpath except Exception as e: print(f" [FAIL] {url[:60]}... → {e}") return None ``` Image URLs are accepted using a substring check rather than parsed hostname validation: ```python for m in img_pattern.finditer(content): url = decode_html(m.group(1)) if 'data:image' in url or 'svg' in url.lower(): continue url = urllib.parse.unquote(url) if 'mmbiz.qpic.cn' not in url: continue img_start = m.start() img_end = m.end() # 图片前的文字 text_chunk = content[last_pos:img_start] text_clean = _clean_text(text_chunk) if len(text_clean) > 15: blocks.append({'type': 'text', 'content': text_clean}) is_gif = '.gif' in url.lower() or '/mmbiz_gif/' in url # 下载图片 img_counter += 1 if is_gif: print(f" [GIF] img_{img_counter:03d} (视频预览,跳过)") blocks.append({'type': 'video', 'url': url, 'local': None}) else: fname = f"img_{img_counter:03d}.png" fpath = os.path.join(cache_dir, fname) local_path = ...[truncated 2426 chars]
Remediation
View remediation
MAX_IMAGE_BYTES: raise ValueError("Image exceeds the permitted size") output.write(chunk) ``` ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (14)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This second mismatch finding highlights undeclared anti-detection browser automation and overstated Feishu/video support, which are operationally significant behaviors. Such discrepancies reduce user consent quality and may bypass expected review because the skill appears narrower and safer than it really is.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

This second mismatch finding highlights undeclared anti-detection browser automation and overstated Feishu/video support, which are operationally significant behaviors. Such discrepancies reduce user consent quality and may bypass expected review because the skill appears narrower and safer than it really is.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest describes a fuller pipeline: fetching public WeChat articles with text, images, and video, preserving content block order, downloading images, and writing the result to Feishu. This script strips HTML to plain text, returns metadata in JSON, and contains no image/video extraction, block-order preservation, download logic, or Feishu write operations.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares capabilities that clearly involve network access and shell execution via python3 and headless Chrome, but it does not define any explicit tool scope or permission boundary. In an agent environment, missing scope declarations increase the chance of overbroad execution and make it harder to constrain what the skill is allowed to do.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill description says it downloads article media locally and writes content into Feishu, but it does not prominently warn about outbound data transfer and local storage side effects. Users may unintentionally process third-party or sensitive content without understanding where copies are stored or sent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The description is written entirely in Chinese and specifically targets WeChat official account articles, which implies a fixed language/locale context. There is no indication that users can choose another language or that this locale restriction is explicitly documented as a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The top-level documentation says the tool 'bypasses WeChat anti-bot detection using browser fingerprint spoofing.' In code, the behavior is limited to launching headless Chrome with a forged user agent and a few automation-related flags; there is no broader fingerprint-spoofing implementation such as navigator, canvas, WebGL, timezone, fonts, or other browser-surface manipulation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This code file includes core natural-language descriptions and user-facing messages in Chinese, including the module docstring and function docstring, without any indication that the language is optional or region-specific. That can violate language/locale policy because the skill effectively forces a specific language for understanding errors and behavior without user opt-in.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
86% confidence
Finding

The script invokes a local Chrome binary on attacker-controlled input URLs, which creates a network-capable subprocess that will fetch arbitrary remote content. While it avoids shell injection by passing an argument list, this still enables SSRF-style access from the host/container, potential interaction with internal services, and execution of complex browser parsing logic against untrusted pages.

Content

Scanner excerpt · scripts/scrape.py (reported line 47)May include surrounding context.

python
]

    try:
        result = subprocess.run(
            cmd,
            capture_output=True,
            text=True,

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module docstring says the workflow creates a Feishu document and writes Markdown into it, and the manifest likewise describes writing into Feishu knowledge base. However, the implemented code only fetches article HTML, parses text/images, stores images under /tmp or a user-supplied cache directory, and then prints instructions for a separate manual Feishu import flow. This is a direct mismatch between the described end-to-end behavior and what this file actually does.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The top-level documentation explicitly lists steps 3 and 4 as creating a Feishu document, writing Markdown, and inserting images. In reality, after scraping and parsing, the code only prints human instructions naming hypothetical Feishu operations; there are no Feishu API calls or integrations in the implementation. This is an active contradiction between the documented workflow and the actual executable behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The script is explicitly designed to bypass anti-bot controls using headless Chrome with anti-detection flags, then fetches remote content and downloads linked images without host allowlisting or strong user-facing warnings. In an agent skill context, this increases legal/compliance risk and can expose the runtime to untrusted external content, SSRF-like misuse if arbitrary URLs are accepted, and unwanted network activity beyond what a user may expect.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/scrape_and_import.py (reported line 56)May include surrounding context.

python
"--dump-dom",
        url
    ]
    result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
    if result.returncode != 0:
        raise RuntimeError(f"Chrome 退出失败: {result.returncode}")
    html = result.stdout

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The workflow documents automatic image downloads to a cache directory but does not clearly disclose local file creation as a side effect at the point of use. In managed agent environments, undisclosed artifact creation can create data residue, compliance issues, or accidental exposure through shared storage.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.