Back to skill

Security audit

Xiaohongshu Post Gen

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward Xiaohongshu image-post generator that uses a Gemini API key and writes generated images locally, with no evidence of hidden or destructive behavior.

Install only if you are comfortable giving the skill a Gemini API key and allowing it to send your post text to Gemini for image generation. For higher-security use, run it in a restricted environment and pin or lock the Python dependencies before use.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
scripts/gen_post.py:2
Finding
Unbounded Third-Party Dependency Resolution## Vulnerability Details **File Location**: `scripts/gen_post.py`, lines 2-7 **Vulnerability Type**: Unpinned third-party dependencies **Risk Level**: Medium ```python # /// script # requires-python = ">=3.10" # dependencies = [ # "google-genai>=1.0.0", # "pillow>=10.0.0", # ] # /// ``` ### Technical Analysis The script declares `google-genai` and `pillow` using open-ended minimum-version constraints. The documented `uv run` workflow can resolve and install any future release satisfying these constraints. No lockfile, exact version, package hash, or upper version boundary is present in the audited project. Consequently, the code ultimately installed and imported when the Skill runs may differ from the dependency versions originally reviewed. If a permitted future release is compromised, malicious package installation or import-time code could execute with the privileges of the user running the Skill. This finding concerns supply-chain integrity. The audited source does not itself contain a malicious dependency, and exploitation requires compromise of a dependency release or its distribution channel. ### Attack Path 1. An attacker compromises the publisher account, release process, or package-distribution path for a declared dependency. 2. The attacker publishes a malicious version satisfying `google-genai>=1.0.0` or `pillow>=10.0.0`. 3. A user invokes the documented command through `uv run` in an environment without a trusted lockfile or cached reviewed version. 4. The resolver selects and installs the malicious compatible release. 5. Malicious installation or import-time code executes when the script imports the affected package. 6. The malicious code operates with the invoking user's permissions and can access resources available to the process. ### Impact Assessment Successful exploitation could permit arbitrary code execution under the invoking user's account. The resulting scope may include ...[truncated 352 chars]
Remediation
## Remediation Suggestions 1. Pin each dependency to an exact, reviewed version rather than using an open-ended lower bound. 2. Generate and commit a lockfile that records the complete transitive dependency graph. 3. Require package hashes or equivalent integrity verification during dependency installation. 4. Install dependencies only from an explicitly configured, trusted package index. 5. Update dependencies through a controlled review process that includes vulnerability scanning and verification of publisher and release provenance. 6. Run the Skill with least privilege and expose only the environment variables and filesystem paths required for image generation. 7. Where supported, use a restricted virtual environment or container to limit the impact of a compromised dependency.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • 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 (4)

Credential Access

High
Category
Privilege Escalation
Content
def get_api_key() -> str | None:
    """Get API key from environment."""
    return os.environ.get("GEMINI_API_KEY")
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
prompt += f", date '{date}' at bottom of the image"
    
    prompt += ", inspiring mood, dreamy atmosphere, professional graphic design"
    return prompt


def generate_page_prompt(page: dict, style: str) -> str:
Confidence
88% confidence
Finding
The script directly interpolates untrusted user input such as title, subtitle, date, and page text into image-generation prompts without any sanitization or delimiting. This can enable prompt injection against the downstream model, causing unintended content generation, policy bypass attempts, leakage of hidden prompt structure, or abuse of the model in ways the caller did not intend.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill requires access to the GEMINI_API_KEY environment variable but does not declare any explicit tool scope, permissions, or allowed-tools metadata. This creates an authorization and transparency gap: a runner may grant broader environment access than necessary, making accidental exposure of secrets more likely if the implementation or future changes read additional variables.

Natural-Language Policy Violations

Medium
Confidence
82% confidence
Finding
The file mixes English headings with substantial Chinese-only examples, parameter values, and usage content, which effectively biases the skill toward a specific language experience. The policy allows locale constraints when explicitly justified or optional, but this document does not offer users a language choice or explain that Chinese is required because the target platform is Xiaohongshu.

Static analysis

No suspicious patterns detected.