T09 · Insecure Skill Coding Practices
- Location
SKILL.md:337- Finding
Excel Formula Injection Through Attacker-Controlled JSON Values
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 337–338
Vulnerability Type: Excel formula injection
Risk Level: Mediumpython ws.cell(row=row, column=4, value=diff["expected"]) ws.cell(row=row, column=5, value=diff["actual"])Technical Analysis
Values originating from the compared JSON files are converted to strings and written directly into Excel cells. The implementation does not neutralize values beginning with spreadsheet formula indicators such as
=,+,-, or@.Consequently, an attacker-controlled JSON value can be interpreted as a formula when the generated workbook is opened in a spreadsheet application. For example:
json { "name": "=HYPERLINK(\"https://attacker.invalid/collect\",\"Open report\")" }If this value appears in the generated difference report, it may be evaluated as a spreadsheet formula rather than displayed as literal text. Although the identified lines directly expose the expected and actual columns, all other input-derived workbook fields should also be treated as potentially unsafe.
Attack Path
- An attacker creates or modifies one of the JSON files supplied to the comparison tool.
- The attacker places a formula-prefixed string in a field that differs between the two JSON documents.
- The comparator stores the malicious string in
diff["expected"]ordiff["actual"]. export_to_excelwrites the value directly into an Excel cell without escaping or forcing a text data type.- A user opens the generated workbook in a spreadsheet application.
- The application evaluates the cell as a formula. Depending on the formula, application security settings, and user interaction, it can display a deceptive link or initiate an external request.
Impact Assessment
The issue affects users who open reports generated from untrusted or attacker-influenced JSON documents. An attacker may create deceptive spreadsheet content or potentially trigger outbound requests, which could ...[truncated 345 chars]
- Remediation
View remediation
Remediation Suggestions
Sanitize every input-derived string before writing it to a workbook cell. At minimum, prefix strings beginning with
=,+,-, or@with an apostrophe so the spreadsheet treats them as text.For example:
python def sanitize_excel_value(value): if isinstance(value, str) and value.startswith(("=", "+", "-", "@")): return "'" + value return value ws.cell( row=row, column=4, value=sanitize_excel_value(diff["expected"]) ) ws.cell( row=row, column=5, value=sanitize_excel_value(diff["actual"]) )Apply the same sanitization to every potentially attacker-controlled field, including paths and descriptions. Where supported, explicitly configure cells as text. Add regression tests covering each formula prefix and verify the resulting workbook does not contain executable formulas in input-derived cells.
