Back to skill

Security audit

Xhsfenxi

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a Xiaohongshu public-account analysis workflow, but its Word-generation path can lead users or agents to run unsafe external shell commands built from creator names.

Review this skill before installing. Use it only for public Xiaohongshu/RED creator analysis, and do not run the printed DOCX commands with untrusted creator names. Verify any external build_docx or fix scripts yourself, quote or sanitize filenames, choose a dedicated output directory, and confirm before creating or repairing Word files.

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/docx-plan.js:19
Finding

Shell Command Injection Through an Unvalidated Creator Name

Content
View full analysis

Vulnerability Details

File Location: scripts/docx-plan.js, lines 19–105
Vulnerability Type: Shell command injection in generated commands
Risk Level: Medium

Vulnerable Code

js
const args = process.argv.slice(2);
const tocFix = args.includes('--toc-fix');
const modeIdx = args.indexOf('--mode');
const mode = modeIdx !== -1 ? args[modeIdx + 1] : 'single';
const name = args.filter((a, i) => {
  if (a.startsWith('--')) return false;
  if (modeIdx !== -1 && i === modeIdx + 1) return false;
  return true;
})[0];

// ...

const isComparison = mode === 'comparison';
const mdFile = isComparison
  ? `选题公式学习-综合版.md`
  : `${name}-结构化总结报告.md`;
const docxFile = isComparison
  ? `选题公式学习-综合版.docx`
  : `${name}-结构化总结报告-商业版.docx`;

console.log(`
=== xhsfenxi Word generation plan: ${name || 'comparison'} ===

Mode: ${isComparison ? 'comparison / 综合版' : 'single creator'}

─────────────────────────────────────────────
STEP 1 — Confirm Markdown is complete
─────────────────────────────────────────────
Make sure this file is finalized:
  ${mdFile}

─────────────────────────────────────────────
STEP 2 — Run build_docx6.py (recommended)
─────────────────────────────────────────────
Primary script (most stable):
  python3 ${ARCHIVE_BASE}/build_docx6.py ${mdFile} ${docxFile}

If build_docx6.py fails, fall back to earlier versions:
  build_docx5.py → build_docx4.py → build_docx3.py
`);

Technical Analysis

The script accepts a creator name from command-line arguments and interpolates it directly into Markdown and DOCX filenames. Those filenames are then embedded in a shell command without validation or shell-safe quoting.

The script does not itself execute the generated command. However, the surrounding Skill documentation describes the output as the exact Word build command and instructs the operator or agent to run it. Consequently, shell metacharacters in an attacker-controlled creator name remain active if the printed command is copied into ...[truncated 2344 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not construct executable shell commands from untrusted text. If the package must launch the DOCX builder, use child_process.spawn() or execFile() with an argument array and shell: false:

    js
    const { spawn } = require('node:child_process');
    
    const child = spawn('python3', [
      resolvedBuilderPath,
      mdFile,
      docxFile
    ], {
      shell: false,
      stdio: 'inherit'
    });
    
  2. Validate and normalize creator names before using them in filenames. Apply a strict allowlist and reject or replace shell metacharacters, path separators, control characters, traversal sequences, and leading option markers. For example:

    js
    function safeFilenameComponent(value) {
      const normalized = value.normalize('NFKC').trim();
      const safe = normalized.replace(/[^\p{L}\p{N}._ -]/gu, '_');
    
      if (!safe || safe === '.' || safe === '..') {
        throw new Error('Invalid creator name');
      }
    
      return safe.slice(0, 100);
    }
    
  3. Use the sanitized value only for filenames. Preserve the original creator name solely as display text where appropriate.

  4. If commands must be displayed rather than executed, quote every dynamic argument with a robust, tested POSIX shell-quoting function. Clearly label the output as requiring review and avoid describing dynamically generated commands as automatically safe.

  5. Resolve and verify the builder path. Avoid relying on a hard-coded script directory outside the package. Bundle the required scripts, accept an explicitly configured trusted path, or verify the external script against a trusted cryptographic hash before execution.

  6. Add regression tests covering semicolons, command substitutions, pipes, redirections, newlines, quotes, path traversal, Unicode normalization, and creator names beginning with hyphens.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared description promises an end-to-end Xiaohongshu creator analysis system with multiple deliverables, evidence grading, comparison features, and export to Markdown/Word. The supplied code only outputs static text: either a cheatsheet of three archetypes or a prompt template for classifying a named creator into one of those archetypes. While the script is related to the declared domain and reflects the three-type classification system mentioned in the description, it implements only a narrow subcomponent—a prompt for archetype classification. Its actual primary behavior is materially narrower than the declared full workflow, so the description does not accurately represent what this code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents a substantive Xiaohongshu analysis skill with classification, evidence handling, account breakdown, comparison, and business deliverable generation. The supplied code does none of that analytical work. It is a command-line helper that outputs a procedural plan for creating and fixing a Word document after analysis is already complete. Its behavior is limited to parsing CLI arguments, choosing filenames, and printing workflow steps and troubleshooting commands for external Python scripts. While this loosely relates to the declared deliverable-conversion aspect, that is only a small support function and not the main advertised capability. Therefore the description materially overstates and misrepresents the code’s actual behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description promises a comprehensive Xiaohongshu analysis system with substantive analytical capabilities and deliverable generation. The supplied code only prints a recommendation plan and filenames based on command-line arguments. This is a materially different primary purpose: planning/report naming rather than analysis and production. There is no sign of account data processing, comparison logic beyond labeling mode, evidence grading, classification frameworks, or document export functionality. Therefore the description significantly overstates what the code chunk actually does.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The listed triggers include phrases like "拆一下这个账号", "帮我做对标分析", and "做成商业版 Word", which are broad enough to match everyday analysis or formatting requests outside this skill's intended Xiaohongshu-specific scope. The file provides examples of positive triggers, but does not give negative examples or explicit boundaries clarifying when these phrases should not activate the skill.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs running build and repair commands that create or modify local DOCX files, but it does not clearly disclose those filesystem side effects before invocation. In agent environments, unclear file-writing behavior can lead to unintended local modifications, overwriting prior work, or users authorizing actions they did not realize would change the workspace.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The file names and report templates are explicitly fixed in Chinese, and the instruction says to always produce the output directly as .docx. This imposes a specific language/locale on generated deliverables without indicating that the user can choose another language or opt in to Chinese output.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The manifest description at L004 says deliverables can be converted to Markdown + Word, implying Markdown is part of the supported output path. But the workflow and deliverables sections at L239-L254 explicitly state to always output DOCX directly with no intermediate Markdown step, creating an internal intent/documentation contradiction about expected behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The description is written as a Xiaohongshu-specific workflow and includes Chinese-only classification labels, which signals a fixed language/locale context. The file does not indicate that users can choose another language or that the locale restriction is required for compliance or other documented reasons.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

L007 states output should always be .docx directly, but the subsequent sections define the report structures inside fenced ```markdown blocks (L019-L065, L071-L105, L111-L145, etc.). This is a documentation-level contradiction about the expected output format, even though both may be part of a broader workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The document consistently assumes use of Chinese platform context and Chinese-language archetype labels, phrases, and framing systems throughout the workflow. Because the file does not indicate that the user can choose another language or locale, it may impose a language/locale convention without explicit opt-in.

Content

No source excerpt is available for this finding.

Scope Creep

Low
Category
Excessive Agency
Confidence
65% confidence
Finding

Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Content

Scanner excerpt · references/workflow.md (reported line 173)May include surrounding context.

md
Focus questions:
- What life stages or emotional states does the account name?
- How does private experience become universal proposition?
- What are the signature conceptual phrases?
- What is the "new way to understand yourself" users get?

Static analysis

No suspicious patterns detected.