T09 · Insecure Skill Coding Practices
- Location
scripts/xhs_crawler.py:37- Finding
Arbitrary Python Code Execution Through Keyword Configuration Injection
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill has a plausible sentiment-analysis purpose, but it includes under-scoped browser scraping and an unsafe external config rewrite that could run injected code.
Install only after review. Use a sandboxed environment and an ephemeral browser profile, pin and inspect MediaCrawler before running it, avoid untrusted keyword input, do not expose personal browser sessions or OAuth tokens unnecessarily, and define retention/redaction rules for collected social-media data.
scripts/xhs_crawler.py:37Arbitrary Python Code Execution Through Keyword Configuration Injection
SKILL.md:23Execution of an Unpinned External MediaCrawler Dependency
The code partially matches the declared reporting goal: it does generate a structured sentiment-style report with keyword heat, product mention counts, pricing-related comment samples, comparison comment samples, and top-note summaries. However, the declared purpose emphasizes a multi-platform monitoring/analysis capability spanning XHS plus Twitter/Reddit, while the actual code only analyzes local JSON files corresponding to XHS crawl outputs. There is no evidence of English-platform support, social data collection, MCP integration, or broader cross-platform market intelligence workflows. Because the description materially overstates the scope and primary capability of the supplied code chunk, this is a mismatch.
The declared description presents a broader sentiment-monitoring and analysis tool spanning XHS, Twitter, and Reddit, with structured reporting and insight generation. The supplied code instead implements a very specific Douyin video-search scraper. Its primary function is DOM extraction of search result cards via Playwright automation, followed by saving raw output. There is no sentiment classification, opinion aggregation, pricing complaint detection, comparison analysis, or report generation. The platform is also materially different: Douyin is not listed in the description, while the described platforms and collection methods (MediaCrawler for XHS, Xpoz MCP for Twitter/Reddit) do not appear in the code. This is a clear description-behavior mismatch.
The declared description presents a broad sentiment intelligence skill covering Chinese and English platforms plus downstream analysis and reporting. The supplied code chunk only supports a narrow subset: crawling Xiaohongshu data via MediaCrawler and exporting JSON. While XHS collection is consistent with one part of the description, the primary described capabilities—cross-platform monitoring and sentiment/report analysis—are absent from this code. This is a material description-to-behavior mismatch rather than a mere partial implementation detail.
The script explicitly uses browser automation to 'bypass API-level blocking' by attaching to a local Chrome instance over CDP and scraping a site through an interactive browser session. In an agent skill, this creates a risky capability expansion beyond ordinary sentiment analysis because it can leverage an authenticated/local browser context to access or extract data in ways not transparently declared, increasing the chance of misuse, policy evasion, and unintended data collection.
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
print("ERROR: MediaCrawler venv not found. Run 'uv sync' in media-crawler/ first.")
sys.exit(1)
env = os.environ.copy()
env["MPLBACKEND"] = "Agg"
if "/usr/sbin" not in env.get("PATH", ""):
env["PATH"] = f"/usr/sbin:{env['PATH']}"
The skill instructs cloning repositories, reading tokens from the user's home directory, editing config files, running shell commands, and writing output files, but it declares no tool scope or permissions boundaries. That mismatch is dangerous because an agent or user may grant broader filesystem, environment, and shell access than expected, increasing the chance of unintended data exposure or command execution.
The skill instructs collection, storage, and analysis of social-media posts and comments, including output to local JSON and reports, but provides no privacy, retention, consent, or sensitive-data-handling guidance. That omission is dangerous because social content can contain personal data, account identifiers, and sensitive opinions, and users may unknowingly create local datasets or reports that violate policy, law, or internal handling requirements.
The skill explicitly recommends CDP browser use 'for anti-detection' and QR-login-based crawling, which normalizes evasion of platform defenses and may induce users or agents to automate authenticated sessions in ways that violate safeguards. In a sentiment-analysis context, that guidance is riskier because the stated purpose does not require stealth or bypass-oriented operational advice, yet it encourages techniques that can capture session context and broaden account-exposure risk.
The template hardcodes Chinese section titles and report wording, which imposes a specific language/locale on the generated report. Under the policy, locale constraints should either be optional for the user or clearly documented as justified for a region-specific use case.
The manifest describes sentiment monitoring on Chinese platforms via 小红书/XHS and English platforms via Twitter/Reddit, but this file is explicitly a Douyin scraper and collects raw video search data from douyin.com. That expands the implemented platform coverage beyond what the skill claims to support.
The script edits base_config.py inside an external MediaCrawler installation in place, which creates side effects outside the skill's own workspace and changes future behavior of that tool. Because it rewrites executable Python config text using unescaped user-supplied keywords, it can also corrupt the external installation or inject unintended content into the config file.
The script silently rewrites files in an external dependency without prominently informing the user that persistent changes will be made. In a skill context, this is risky because users may expect a read-only analysis tool, while the script alters another project's configuration and potentially affects later runs or other workflows.
The script launches a separate Python interpreter from an external repository and executes its main.py with inherited environment variables. This creates a trust boundary issue: if the MediaCrawler checkout is malicious, compromised, or replaced via MEDIA_CRAWLER_PATH, the skill will run arbitrary code under the user's privileges.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
print("Starting XHS crawler (CDP mode)...")
print("If login required, scan QR code on your phone.")
result = subprocess.run(
[str(venv_python), "main.py", "--platform", "xhs", "--lt", "qrcode"],
cwd=str(crawler_path),
env=env,
No suspicious patterns detected.