Back to skill

Security audit

China Tax Calculator

Security checks for vulnerabilities and agentic risk

Overview

This is a purpose-aligned China tax calculator, but exported payroll CSV/report data can expose sensitive information and the batch CSV export needs careful handling.

Use this skill only with payroll or tax data you are authorized to process. Avoid unnecessary real names, check sharing permissions before placing generated reports in collaboration tools, and sanitize or quote CSV fields before opening batch exports in spreadsheet software when any employee data may be untrusted.

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
lib/tax_calc.py:2165
Finding

Spreadsheet Formula Injection in Batch CSV Export

Content
View full analysis

Vulnerability Details

File Location: lib/tax_calc.py, lines 2165-2169
Vulnerability Type: CSV/spreadsheet formula injection
Risk Level: Medium

Vulnerable Code

python
for emp in batch_result["员工明细"]:
    csv += f"{emp['姓名']},{emp['月薪']:.2f},{emp['年终奖']:.2f},"
    csv += f"{emp['年度税前']:.2f},{emp['月度个税']:.2f},"
    csv += f"{emp['月度到手']:.2f},{emp['年度个税']:.2f},"
    csv += f"{emp['年度到手']:.2f}\n"

Technical Analysis

The employee name inserted through emp['姓名'] originates from caller-controlled employee data and is concatenated directly into CSV output. The code performs neither standards-compliant CSV quoting nor spreadsheet formula neutralization.

If a name begins with a spreadsheet formula marker such as =, +, -, or @, spreadsheet software may interpret the cell as a formula rather than plain text. For example:

text
=HYPERLINK("https://attacker.example","Open")

Names containing commas, quotation marks, carriage returns, or newlines can also alter the CSV structure and inject additional cells or rows.

Attack Path

  1. An attacker or untrusted data source supplies an employee record whose name starts with a spreadsheet formula marker.
  2. batch_calculate_tax() copies the supplied name into the batch result under the employee-name field.
  3. generate_batch_excel_data() concatenates that value directly into the first CSV column.
  4. The generated data is saved as a CSV file and opened by an HR or payroll user in spreadsheet software.
  5. The spreadsheet application may evaluate the attacker-controlled value as a formula.
  6. The formula may display deceptive links, initiate external resource lookups, or perform other actions allowed by the spreadsheet application and its security configuration.

Impact Assessment

Successful exploitation occurs in the context of the user opening the exported CSV, not with the privileges of the Python calculator itself. The potential scope includes:

  • Execution of attacke ...[truncated 650 chars]
Remediation
View remediation

Remediation Suggestions

  1. Generate CSV through Python's csv.writer rather than manual string concatenation so commas, quotation marks, carriage returns, and newlines are escaped correctly.
  2. Treat every user-controlled textual field as potentially formula-bearing.
  3. Before writing a text cell, inspect its first non-whitespace character. If it is =, +, -, or @, prefix the value with an apostrophe or use another neutralization strategy compatible with the intended spreadsheet software.
  4. Preserve the original name separately if exact round-trip fidelity is required, and document any neutralization applied to exported values.
  5. Open output streams with newline="" and an explicit encoding such as UTF-8 with BOM when compatibility with common spreadsheet applications is required.
  6. Add regression tests for names containing formula markers, commas, quotation marks, tabs, carriage returns, and newlines.

Example hardening pattern:

python
import csv
import io

def neutralize_spreadsheet_formula(value: object) -> str:
    text = str(value)
    if text.lstrip().startswith(("=", "+", "-", "@")):
        return "'" + text
    return text

output = io.StringIO(newline="")
writer = csv.writer(output)
writer.writerow([
    "Name", "Monthly Salary", "Bonus", "Annual Gross",
    "Monthly Tax", "Monthly Net", "Annual Tax", "Annual Net",
])

for emp in batch_result["Employee Details"]:
    writer.writerow([
        neutralize_spreadsheet_formula(emp["Name"]),
        f"{emp['Monthly Salary']:.2f}",
        f"{emp['Bonus']:.2f}",
        f"{emp['Annual Gross']:.2f}",
        f"{emp['Monthly Tax']:.2f}",
        f"{emp['Monthly Net']:.2f}",
        f"{emp['Annual Tax']:.2f}",
        f"{emp['Annual Net']:.2f}",
    ])

csv_data = output.getvalue()

The field names in the example should be adapted to the application's existing result structure.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (8)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Excel export and Feishu document report features create a realistic risk of sensitive tax and payroll data being written to disk or shared to collaboration platforms, where access may be broader than intended. The absence of any warning about local persistence, sharing permissions, retention, or redaction makes accidental disclosure of financial and personal information more likely.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The batch tax calculation example explicitly involves multiple employees' names and compensation data, which are sensitive personal and employment-related information. Although the file is only documentation, presenting this workflow without privacy guidance, minimization advice, or consent/authorization expectations can normalize unsafe handling of employee payroll data and increase the chance that users paste real sensitive records into the agent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This Python file contains natural-language descriptions and user-facing outputs that assume Chinese as the only interaction language, starting from the module docstring and continuing throughout the file. Under the policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly justified.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest describes a personal income tax calculator for scenarios like tax consultation, salary calculation, bonus optimization, and job-change salary negotiation. This function adds bulk processing of multiple employees with per-employee outputs and aggregate totals, which is a broader HR/payroll management capability rather than an individual-facing calculator feature.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

描述全文以中文表述技能能力,但未说明是否必须以中文交互,亦未为非中文用户提供语言选择。根据语言/地区策略,若技能对语言有约束,应明确写明原因或提供用户选择。

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The manifest presents the skill as a tax calculator and advisory tool, but this section generates Feishu-formatted Markdown reports tailored for a specific document platform. Report/export formatting may be adjacent to the purpose, but platform-specific document generation is additional behavior not stated in the description.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · lib/tax_calc.py (reported line 2077)May include surrounding context.

python
unused = []
    for name, amount in available_deductions.items():
        if getattr(special_deduction, name.replace("子女教育", "children_education")
                                          .replace("婴幼儿照护", "infant_care")
                                          .replace("继续教育", "continuing_education")
                                          .replace("住房贷款利息", "housing_loan")

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This manifest presents the skill description, keywords, and capabilities only in Chinese, which can amount to a language/locale policy issue when the skill does not explicitly state that it is region-specific or offer an alternative language option. While the subject matter is China tax, the manifest does not clearly document that the language restriction is intentional and limited to that locale.

Content

No source excerpt is available for this finding.