DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

CSV Formula Injection: When Spreadsheet Exports Turn Data Into Formulas

CSV formula injection occurs when untrusted export data is interpreted as a formula by a spreadsheet. Learn the risks, limits of quoting, and safer testing and mitigation practices.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Opening a CSV can cause a spreadsheet application to evaluate untrusted cell contents as formulas—but only when the exported value and the application’s handling combine to trigger that behavior. The leading characters most often involved are =, +, -, and @. Quoting a field correctly protects CSV structure; it does not, by itself, guarantee that a spreadsheet will treat the contents as plain text.

What CSV formula injection is—and when it matters

CSV formula injection happens when untrusted input is included in a CSV or spreadsheet-compatible export and a spreadsheet program interprets the resulting cell as a formula. The issue is in the path from user-controlled data to a file that someone opens in a spreadsheet—not in the mere presence of a particular character in a CSV.

As an Amazon Associate I earn from qualifying purchases.

Potentially affected data can come from names, email addresses, comments, support tickets, imported records, or any other field that later appears in an export. Risk depends on who can supply or influence that data, who opens the file, and what the spreadsheet application does with the value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why =, +, -, and @ deserve attention

Spreadsheet applications may treat values beginning with an equals sign, plus sign, minus sign, or at sign as formulas. For example, test strings such as =1+1, +1+1, -1+1, and @SUM(1,1) can help reveal whether an export is being evaluated by a target application.

Those four characters are not a complete test set. OWASP also calls out tabs, carriage returns, line feeds, and locale-dependent full-width forms such as =, +, -, and @. Interpretation can vary by spreadsheet product, version, and locale, so a check limited to the first character of the original input can miss relevant cases.

How data can become a formula

The export and spreadsheet application together determine whether a value is evaluated. An attacker may supply a formula-like value directly, or use delimiters and quotes to break out of an intended CSV field and place a formula-leading value at the start of a new cell. That is why the generated file—not just the input string—needs inspection.

Possible effects include misleading users, manipulating spreadsheet output, and exfiltrating data. OWASP also describes escalation through legacy spreadsheet features such as DDE that may reach command execution in some environments, typically depending on client configuration or user interaction. This is not an automatic or usual consequence of opening any CSV. MITRE CWE-1236 notes possible confidentiality and unauthorized code or command execution impacts, rates the likelihood of those mapped impacts low, and says current Excel versions warn users about untrusted content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why CSV quoting alone is not a reliable defense

CSV quoting is necessary for preserving field boundaries and correctly handling embedded quotes, but it does not establish that a spreadsheet will display a value as text. A spreadsheet may interpret a quoted field as a formula, and Excel may remove some quote or escape characters when a file is saved and reopened. OWASP’s guidance is explicit: “There is no universal CSV sanitization strategy safe for all spreadsheet applications and all downstream consumers.”

MITRE describes general metacharacter neutralization and a leading apostrophe as having moderate effectiveness, while warning that spreadsheet products differ. Treat any such transformation as a candidate defense to validate in the actual workflow, not as a universal guarantee.

How to test an export safely

  1. Map the workflow. Identify the CSV, TSV, or spreadsheet export; the untrusted fields it includes; who can trigger the export; and who is likely to open or share it.
  2. Use harmless, detectable strings. In an isolated test environment, try values such as =1+1, +1+1, -1+1, and @SUM(1,1). Add relevant control-character and full-width-prefix variants for the locales you support. Do not use test values designed to execute commands or make uncontrolled network requests.
  3. Test field breakout. Check whether quotes or separators in an input can move a formula-leading value into a new cell. Inspect the raw generated file in a text editor and examine the parsed cells rather than relying only on the original input.
  4. Open it in the target application. Record the spreadsheet product and version, how the CSV was opened, and relevant locale settings. Check whether the cell displays a computed result and whether the formula bar identifies a formula.
  5. Retest after save and reopen. If a defense is intended to prevent formula activation, save the CSV in Excel, close it, reopen it, and check again. OWASP’s testing guidance treats this regression check as important because saving can normalize or remove some escaping.
  6. Assess the consequences. Record whether recipients are internal or external, whether spreadsheet values affect decisions such as totals or status flags, and what formula behavior is possible in the client environment.

Mitigations depend on how the file will be used

Exports meant for people to view in spreadsheets

Use defense in depth: prevent formula-triggering prefixes and relevant control or Unicode variants from remaining at the beginning of cells; quote CSV fields correctly and double embedded double quotes; and validate the result in the spreadsheet applications and workflows recipients actually use. Include save-and-reopen checks where Excel is part of that workflow.

OWASP documents an observed Excel-resistant behavior: place a tab character (0x09) before a value beginning with =, +, -, or @, inside a quoted field. For example, the field can be represented as "t=1+1", with a literal tab before the equals sign. This behavior is not a guarantee for other spreadsheet applications. The tab remains in the underlying data and may affect downstream programmatic processing, so it is suited only to workflows where that trade-off is acceptable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Data intended for programmatic import

Keep machine-to-machine data clean rather than applying spreadsheet-viewing transformations indiscriminately. A tab or other protective character may alter the value consumed by software. If one export serves both spreadsheet users and programmatic importers, define and test those use cases separately; there is no single transformation established as safe for every architecture and consumer.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to choose and verify a defense

Evaluate a defense against the actual risks and consumers, not just whether it changes a sample string. Check formula suppression across target spreadsheet products and versions, behavior after Excel save and reopen, handling of separators, embedded quotes, control characters and locale-sensitive Unicode, and whether values remain intact for programmatic consumers. Also consider who opens and shares the file and what could happen if a value is evaluated.

MITRE CWE-1236 lists CVE-2019-12134, CVE-2019-4521, and CVE-2019-17661 as examples mapped to this weakness; those examples do not indicate how prevalent the issue is. The practical test is whether your own export can turn untrusted data into an evaluated cell in the spreadsheet workflows that matter to you.

Sources

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.