Join our Newsletter — 33% off our NHI Course

CSV Injection

CSV injection is a technique where attacker-controlled cell content is interpreted as a formula when a spreadsheet is opened, exported, or reimported. The danger is not the file format itself but the receiving application’s handling of leading characters such as equals, plus, minus, or at-sign.

How CSV injection works

CSV injection occurs when spreadsheet software treats a cell value as a formula instead of inert text. The trigger is usually a leading character such as equals, plus, minus, or at-sign, which can cause the receiving application to evaluate the content on open, export, or reimport.

The core issue is parsing behavior, not the CSV file format itself. A file can be syntactically valid and still become dangerous if the consuming application allows formula execution from untrusted data.

Where the attack surface appears

CSV injection typically enters through user-controlled fields that later leave an application as a spreadsheet export, report, import template, or data exchange file. Common examples include names, comments, addresses, support tickets, and other free-text fields that are not expected to contain executable spreadsheet syntax.

The risk grows when exported data is later opened in spreadsheet software by staff, partners, or customers who trust the file. In some environments, the attacker does not need to compromise the application directly, only to influence the exported content.

Common formula payload behavior

A malicious cell can be crafted to force a spreadsheet to execute a function, reach out to an external resource, or present a misleading prompt to the user. Even when the spreadsheet platform restricts some actions, the formula context can still expose data, manipulate display logic, or trigger follow-on actions when the file is opened.

The exact effect depends on the spreadsheet application, its security settings, and whether formulas are enabled by default. That variability is why CSV injection is best understood as an application handling flaw rather than a property of CSV itself.

Defensive handling and safe export design

Defenses focus on ensuring that untrusted text is never interpreted as executable spreadsheet content. The safest pattern is to neutralize formula-triggering prefixes before export, preserve plain-text semantics, and treat spreadsheet generation as a security-sensitive output path.

For broader web-application risk context around input handling and output safety, the OWASP Top 10 remains a useful baseline reference for understanding how untrusted input can become a security issue when applications fail to constrain it.

Risk and Threat Considerations

CSV injection is a data-to-code conversion problem: attacker-controlled text can become active spreadsheet logic once a file is opened. That makes exported reports, customer exports, and import templates a surprisingly effective delivery path for abuse, especially when recipients assume the file is safe because it came from a trusted system.

Failure mechanism: A spreadsheet application interprets a leading formula character as executable syntax, allowing untrusted cell content to run in a formula context rather than remain plain text.

Impact: The result can include data disclosure, misleading output, unwanted external requests, or user-driven follow-on actions that expand the original injection into a broader compromise or fraud path.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP ASVS V1 — Encoding and Sanitization CSV injection hinges on untrusted text being parsed as executable spreadsheet syntax.
V15 — Secure Coding and Architecture Safe export design is an application architecture and output-handling concern.
Recommendation — Encode exported cell values so formula-triggering prefixes remain inert text. Design CSV export paths to preserve text semantics for attacker-controlled fields.
CIS Controls v8 CIS-16 — Application Software Security CSV injection arises from insecure handling of application-generated output.
Recommendation — Validate export logic to prevent spreadsheet formula execution from untrusted input.

Practitioner Guidance

What to watch for: Any feature that exports user-influenced text into CSV, especially if the file is intended for spreadsheet opening, should be treated as a security boundary. Review how the application serializes values that begin with formula-triggering characters and whether it preserves text semantics consistently across export and reimport paths.

Practitioner takeaway: Treat spreadsheet export as an output-encoding problem, not just a file-format problem. If untrusted content can reach a spreadsheet formula parser, it needs explicit neutralization before the file leaves the application.