T09 · Insecure Skill Coding Practices
- Location
scripts/benchmark_models.py:61- Finding
Spreadsheet Formula Injection Through Untrusted Model Names in CSV Output
- Content
View full analysis
Vulnerability Details
File Location:
scripts/benchmark_models.py, lines 61-64; untrusted value introduced at line 80
Vulnerability Type: CSV/spreadsheet formula injection
Risk Level: MediumVulnerable Code
python with output_path.open("w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=["rank", "name", "score"]) writer.writeheader() writer.writerows(result["details"]["leaderboard"])The model name included in the exported rows is obtained directly from input:
python name = str(model.get("name", "unknown-model"))Technical Analysis
Model names originate from an externally supplied JSON document and are copied into the leaderboard without validation or spreadsheet-specific output encoding. Although
csv.DictWritercorrectly escapes CSV delimiters and quotes, CSV escaping does not neutralize spreadsheet formulas.If a model name starts with a formula indicator such as
=,+,-, or@, spreadsheet software may interpret the cell as a formula when a user opens the generated CSV file. The exact behavior and available formula capabilities depend on the spreadsheet product and its security configuration.Attack Path
- An attacker supplies or influences the benchmark input JSON.
- The attacker sets a model name to a formula-like value, such as
=HYPERLINK("https://attacker.example","Open report"). - An operator runs the script with
--format csv. - The model name passes through
str()without formula neutralization. csv.DictWriterwrites the attacker-controlled value into thenamecolumn.- A user opens the resulting file in spreadsheet software.
- The application may evaluate or display the value as a formula, potentially enabling deceptive links or other spreadsheet-supported actions.
Impact Assessment
The vulnerability does not grant privileges in the Python process and does not itself e ...[truncated 471 chars]
- Remediation
View remediation
Remediation Suggestions
Treat all text fields exported to CSV as untrusted. Before writing a cell, detect values whose first non-whitespace character is
=,+,-, or@and neutralize them using a strategy compatible with the intended spreadsheet consumers, such as prefixing an apostrophe.Example:
python def sanitize_csv_cell(value: object) -> object: if not isinstance(value, str): return value if value.lstrip().startswith(("=", "+", "-", "@")): return "'" + value return valueApply the function to model names before passing rows to
DictWriter. Add tests for formula prefixes, leading whitespace, tabs, delimiters, quotes, and multiline values. Document that candidate names are untrusted and that CSV artifacts should not be allowed to contain active spreadsheet content.
