Back to skill

Security audit

保险费率二维表生成工具

Security checks for vulnerabilities and agentic risk

Overview

This skill appears to be a legitimate Excel rate-table generator, but it needs review because its generated output path is not safely constrained and it uses a vulnerable spreadsheet dependency.

Review before installing. Use it only in a contained workspace, avoid product names containing slashes, backslashes, dot-dot traversal, or path-like text, and update or replace the xlsx dependency before handling untrusted spreadsheet-related inputs.

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-rate-table.js:121
Finding

Unrestricted Output Path Traversal and File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/generate-rate-table.js:38-39, 121-124
Vulnerability Type: Path traversal and unrestricted file overwrite
Risk Level: Medium

Vulnerable Code

javascript
function parseArgs() {
  const args = process.argv.slice(2);
  const productName = args[0] || '费率表';
  const params = { ...DEFAULT_PARAMS };

  // ...
  
  return { productName, params };
}

// ...

const fileName = `${productName}费率表.xlsx`;
const filePath = path.join(process.cwd(), fileName);
XLSX.writeFile(wb, filePath);

Technical Analysis

The product name is read directly from the command line and incorporated into the output filename without validation or sanitization. An attacker can include absolute or relative path components, including ../, in this value.

path.join() normalizes path traversal segments but does not verify that the resulting path remains under the intended working directory. The resulting path is passed to XLSX.writeFile(), which creates the file or replaces an existing file at that location.

The .xlsx suffix restricts the final filename but does not prevent directory traversal or replacement of writable files whose names end with that suffix.

Attack Path

  1. An attacker or untrusted caller controls the product-name argument passed to the generator.

  2. The attacker invokes the script with a traversal value, for example:

    bash
    node scripts/generate-rate-table.js "../../shared/report"
    
  3. The script constructs a filename equivalent to:

    text
    ../../shared/report费率表.xlsx
    
  4. path.join(process.cwd(), fileName) normalizes the path outside the current working directory.

  5. If the destination directory exists and is writable by the process, XLSX.writeFile() creates or overwrites the target file there.

The same input can pass through scripts/generate-rate-table.sh because the wrapper correctly quot ...[truncated 620 chars]

Remediation
View remediation

Remediation Suggestions

  1. Treat the product name as a display label rather than a path. Reject path separators, traversal segments, control characters, and platform-specific reserved names.
  2. Generate files only inside a dedicated output directory.
  3. Resolve both the output directory and candidate path to absolute paths, then verify that the candidate remains inside the approved directory.
  4. Avoid replacing existing files unless overwrite behavior is explicitly requested and authorized.
  5. Apply a reasonable filename-length limit and reject empty names after sanitization.
  6. Return an error rather than silently transforming clearly malicious input.

Example hardening approach:

javascript
const fs = require('fs');
const path = require('path');

function validateProductName(value) {
  if (
    typeof value !== 'string' ||
    value.length === 0 ||
    value.length > 100 ||
    value === '.' ||
    value === '..' ||
    /[\/\\\0-\x1F\x7F]/.test(value)
  ) {
    throw new Error('Invalid product name');
  }

  return value;
}

const safeProductName = validateProductName(productName);
const outputDir = path.resolve(process.cwd(), 'workspace');
fs.mkdirSync(outputDir, { recursive: true });

const fileName = `${safeProductName}费率表.xlsx`;
const filePath = path.resolve(outputDir, fileName);
const relativePath = path.relative(outputDir, filePath);

if (
  relativePath === '' ||
  relativePath.startsWith(`..${path.sep}`) ||
  path.isAbsolute(relativePath)
) {
  throw new Error('Output path escapes the workspace');
}

if (fs.existsSync(filePath)) {
  throw new Error('Output file already exists');
}

XLSX.writeFile(wb, filePath);
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (5)

Known Vulnerable Dependency: xlsx==0.18.5 — 2 advisory(ies): CVE-2023-30533 (Prototype Pollution in sheetJS); CVE-2024-22363 (SheetJS Regular Expression Denial of Service (ReDoS))

High
Category
Supply Chain
Confidence
98% confidence
Finding

The lockfile pins xlsx to version 0.18.5, which is affected by publicly disclosed vulnerabilities including prototype pollution and a regular-expression denial of service. If this skill processes untrusted spreadsheet content or attacker-controlled workbook data, those flaws can lead to application instability, denial of service, or unsafe object mutation that may affect downstream logic.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: xlsx==0.18.5 — 2 advisory(ies): CVE-2023-30533 (Prototype Pollution in sheetJS); CVE-2024-22363 (SheetJS Regular Expression Denial of Service (ReDoS))

High
Category
Supply Chain
Confidence
99% confidence
Finding

The package depends on xlsx 0.18.5, which has known published vulnerabilities including prototype pollution and a regular-expression denial of service. Because this skill is explicitly an Excel/rate-table generator, the dependency is central to its functionality, so any parsing or processing of workbook data could expose the host environment to denial of service or unsafe object manipulation if untrusted files or crafted workbook content are handled.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The package description is written only in Chinese, which may indicate a language-specific constraint without any documented user opt-in or justification. Under the policy, language or locale restrictions should either be optional for the user or clearly documented as region-specific.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
87% confidence
Finding

The dependency is specified with a caret range (^0.18.5), which allows future compatible updates within the major version and can introduce unreviewed package changes during installation. In isolation this is a supply-chain hardening issue rather than an immediate exploit, but it increases risk and is more concerning here because the referenced package version is already known to have vulnerabilities.

Content

Scanner excerpt · package.json (reported line 10)May include surrounding context.

json
"generate": "node scripts/generate-rate-table.js"
  },
  "dependencies": {
    "xlsx": "^0.18.5"
  },
  "keywords": [
    "insurance",

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This markdown specification is entirely fixed to Chinese field names and requires the Excel sheet name to be 费率表, which imposes a specific language/locale in the skill behavior. The file does not mention any user opt-in, language selection, or justification that this is a region-specific requirement.

Content

No source excerpt is available for this finding.