Back to skill

Security audit

xiaohongshu-image-generator

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its stated image-card purpose, but it renders unescaped user text through a local browser/server workflow that could run injected HTML or script.

Review before installing. Use only trusted prompts/content, write outputs into a dedicated empty directory, stop the localhost server after screenshotting, and prefer a fixed implementation that HTML-escapes all displayed fields and adds a restrictive content security policy.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_image.py:275
Finding

Unescaped User Input Allows Script Execution in Generated HTML

Content
View full analysis
{line}' for line in content_lines if line.strip()) # 作者首字母 author_initial = config.get('author', 'P')[0] # 当前日期 date = datetime.now().strftime('%Y-%m-%d') html = TEMPLATE.format( title=config.get('title', '今日分享'), content_html=content_html or '

每天进步一点点

', tag=config.get('tag', '📌 今日分享'), author=config.get('author', '袁佳鹏'), author_initial=author_initial, date=date, emoji=config.get('emoji', '💜'), bg_start=color['start'], bg_end=color['end'], border_radius=style['border_radius'], shadow=style['shadow'], title_size=style['title_size'], content_size=style['content_size'], ) with open(output_path, 'w', encoding='utf-8') as f: f.write(html) ``` ### Technical Analysis The generator accepts user-controlled values through command-line arguments or the `--prompt` option. The title, content, tag, author, author initial, and emoji fields are inserted directly into the HTML template without context-appropriate escaping. In particular, content is enclosed in a `

` element through string concatenation, but the content itself is not escaped: ```python content_html = ''.join(f'

{line}

' for line in content_lines if line.strip()) ``` An attacker can supply markup that closes the generated element and inserts an executable element or event handler. Other fields can similarly break out of their corresponding HTML contexts. For example, a malicious title could contain: ```html ``` The resulting file is subsequently hosted by `SimpleHTTPRequestHandler` and automatically opened through `webbrowser.open()`. The injected ...[truncated 1709 chars]
Remediation
View remediation
{escape(line, quote=True)}' for line in content_lines if line.strip() ) author_initial = escape(author[:1], quote=True) ``` 2. Keep user content in text contexts. If rich HTML is required, process it through a well-maintained allowlist sanitizer that removes scripts, event-handler attributes, dangerous URLs, embedded frames, and active SVG content. 3. Add a restrictive Content Security Policy to generated documents, for example: ```html ``` 4. Serve generated files from a dedicated, otherwise empty output directory instead of changing into an arbitrary user-selected directory. This prevents unrelated files from becoming accessible through `SimpleHTTPRequestHandler`. 5. Validate the output path and avoid overwriting arbitrary existing files. Where possible, create a unique temporary output directory with restrictive permissions. 6. Add regression tests using payloads containing `
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The documented behavior says the skill generates images via Playwright screenshotting, but the actual instructions rely on generating HTML, starting a local server, and using an external browser flow. This mismatch is dangerous because operators may approve the skill for a narrow rendering purpose while it actually introduces additional undeclared capabilities and manual steps, increasing the chance of unsafe execution or misuse.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill instructs the agent to write files and run a local HTTP server, but it does not declare any tool scope or allowed-tools boundaries. This is dangerous because undeclared shell and file-write capabilities reduce reviewability and can enable broader-than-expected local side effects such as creating files, exposing content over localhost, or running unintended commands if the workflow is extended or prompt-influenced.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description and title/instructions are entirely in Chinese and specifically frame the skill around generating '小红书' imagery, which implies a fixed language/locale experience. The file does not state that the user can choose another language or that the Chinese-only constraint is an intentional, documented regional limitation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest and module docstring describe a skill that generates Xiaohongshu images using HTML/CSS and browser screenshots. However, this file stops after writing HTML, serving it locally, and instructing the user to take a screenshot manually; no Playwright automation or image generation occurs in code.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The top-level docstring presents the script as a '小红书配图生成器' that generates vertical images from prompts. In practice, the code writes an HTML file, launches a local HTTP server, opens a browser, and prints instructions for a separate screenshot tool rather than generating an image itself.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The HTML document sets lang="zh-CN", which forces a specific language/locale in the rendered output. The file provides no indication that this locale is optional, user-selected, or justified as a region-specific template, so it conflicts with the policy against imposing a locale without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The template hard-codes lang="zh-CN", which imposes a specific language/locale setting on all generated output. The file does not offer a locale option or explain that the tool is intentionally limited to a China-specific context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The document declares lang="zh-CN", which fixes the content language/locale to Simplified Chinese. Under the policy, forcing a specific language without user opt-in or a clearly documented regional justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The document declares lang="zh-CN" and all visible content is presented in Chinese, which indicates a fixed language/locale experience. The file does not provide any opt-in, alternative locale handling, or justification that this is a region-specific skill, so it may conflict with language-choice policy expectations.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.