Back to skill

Security audit

Cost Report Generator

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent cost-reporting purpose, but generated Excel reports can preserve formula-like text from source files as active spreadsheet content.

Review this skill before using it with files from customers, vendors, or other untrusted sources. It is suitable for user-directed cost report generation, but the generated workbook should not preserve formulas from text fields; sanitize spreadsheet text or use only trusted input workbooks.

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_cost_report.py:26
Finding

Excel Formula Injection Through Untrusted Text Fields

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_cost_report.py, lines 26–28 and 198–199
Vulnerability Type: Excel formula injection
Risk Level: Medium

Vulnerable Code

python
customers = [str(df.iloc[i]['客户大类']) if pd.notna(df.iloc[i]['客户大类']) else '' for i in range(len(df))]
projects = [str(df.iloc[i]['项目大类']) if pd.notna(df.iloc[i]['项目大类']) else '' for i in range(len(df))]
order_ids = [str(df.iloc[i]['内部订单号']) if pd.notna(df.iloc[i]['内部订单号']) else '' for i in range(len(df))]
python
for c, val in enumerate([customers[idx], projects[idx], order_ids[idx]], 1):
    cell = ws.cell(row=row, column=c, value=val)

Technical Analysis

The Skill reads the customer category, project category, and internal order identifier from an untrusted source workbook and writes those values directly into a generated Excel workbook. It does not validate or neutralize spreadsheet formula prefixes.

When openpyxl receives a string beginning with =, it can store that value as a formula cell rather than inert text. Other spreadsheet-sensitive prefixes, including +, -, @, tab, and carriage return, may also require neutralization because their interpretation varies across spreadsheet applications and import workflows.

Although the customer category is constrained to four accepted values before output, the corresponding project category and internal order identifier remain attacker-controlled. A malicious source workbook can therefore place formula content in either of those fields and preserve it in the generated report.

Attack Path

  1. An attacker prepares a source workbook with an accepted customer category such as BAT.
  2. The attacker places a malicious formula-like value in the same row's project category or internal order identifier.
  3. A user invokes the Skill with that workbook.
  4. The script reads the value and converts it to a Python string without validation.
  5. The value is passed directly to openpyxl as the out ...[truncated 968 chars]
Remediation
View remediation

Remediation Suggestions

Treat every text value copied from an input workbook as untrusted spreadsheet content.

  1. Create a centralized sanitization function that neutralizes values beginning with =, +, -, @, tab, or carriage return.
  2. Prefix dangerous values with an apostrophe or otherwise encode them as literal text according to the target spreadsheet application's requirements.
  3. Explicitly set sanitized cells to the string data type where appropriate.
  4. Apply sanitization to all source-derived text fields, not only the currently identified columns.
  5. Preserve the original value only if it passes a strict allowlist suitable for that field. For example, internal order identifiers can be restricted to expected letters, digits, spaces, underscores, and hyphens.
  6. Add regression tests covering every dangerous prefix and values containing leading whitespace before a formula marker.
  7. Document that source workbooks are untrusted input and that generated reports must not retain formulas from source text fields.

Example hardening pattern:

python
def sanitize_excel_text(value):
    text = '' if value is None else str(value)
    dangerous_prefixes = ('=', '+', '-', '@', '\t', '\r')
    if text.startswith(dangerous_prefixes):
        return "'" + text
    return text

for c, val in enumerate([customers[idx], projects[idx], order_ids[idx]], 1):
    cell = ws.cell(row=row, column=c, value=sanitize_excel_text(val))
    cell.data_type = 's'

Field-specific allowlist validation should be preferred where the expected data format is known.

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill metadata and description use broad natural-language activation cues around generating cost reports from Excel files, which can overlap with ordinary user requests about organizing expenses or summarizing spreadsheets. In an agent environment, this can cause unintended invocation on sensitive financial files, increasing the chance of unnecessary file processing or disclosure beyond what the user explicitly intended.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger section defines activation using vague phrases like customer cost extraction and project expense organization without clear boundaries, exclusions, or confirmation requirements. Because the skill processes local files and produces derived financial reports, ambiguous triggering raises the risk of accidental execution on confidential business data or running when the user only wanted advice rather than file processing.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring and CLI/output text are written entirely in Chinese, which imposes a specific language on users without opt-in. Under the policy, locale or language constraints should either provide user choice or be clearly documented as region-specific and justified.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.