Skip to content

CSV export safety guide

CSV Spreadsheet Formula Injection Review: Keep Exported Text Literal

CSV syntax can be valid while a spreadsheet application treats a cell as a formula. Review cell semantics, neutralization policy, and downstream expectations before a text export is opened by people.

A CSV review should distinguish delimiter and quoting correctness from spreadsheet interpretation. Identify cells whose first visible character can trigger formula evaluation, decide whether the output is for a spreadsheet or a machine consumer, and record the neutralization policy and its downstream cost. Quoting alone is not a universal safety guarantee, and a safe text policy does not prove rights, accuracy, or permission to distribute the source values. Sources without a verified publication date are shown with documentation retrieval dates checked 22 October 2026; their original publication dates are not established.

Updated

On this page

Name the two interpreters

A CSV file has a text grammar and a consumer interpretation. RFC 4180 discusses records, commas, quotes, and line breaks; a spreadsheet application may add a formula language on top of those characters. Review both layers. A cell can be valid CSV and still be unsafe or surprising when opened by a human spreadsheet user, while a prefix added for spreadsheet safety can become unwanted data for an API or database import.

The RFC Editor, (opens in a new tab) document is a format reference, not a promise that every spreadsheet behaves the same way. Start the worksheet with the intended consumer, the expected literal value, and whether the output is human-viewed or machine-ingested. If the audience is mixed, produce separate artifacts or explicitly accept the trade-off instead of silently applying one policy.

Name the two interpreters (table)
BoundaryRecordUnknown if
CSV grammardelimiter, quote, line ending, encodingThe parser configuration is unstated
cell valueexact text before exportOnly a displayed spreadsheet value remains
consumerspreadsheet, database, API, or mixedAudience is assumed from the extension
formula policyliteral, neutralized, or rejectedNo owner decision exists
leading zerostext preservation ruleIdentifiers were cast to numbers
audit trailinput, transform, and output referencesOnly the final file is retained

Identify formula-like starts without testing live payloads

OWASP calls out cells beginning with characters such as equals, plus, minus, or at sign as formula-injection risk in spreadsheet applications. Treat that as a classification rule for a review, not an invitation to place a live formula or a harmful payload in a real export. Use neutral synthetic strings and record the first character, intended literal meaning, and target consumer.

Do not confuse CSV quoting with neutralization. Quotes preserve field boundaries under the CSV grammar; they may not prevent a spreadsheet from recognizing a formula after it loads the cell. Conversely, a leading apostrophe or tab can alter the stored text for a machine consumer. The correct policy depends on the output contract and must be tested with the actual approved consumer version.

Identify formula-like starts without testing live payloads (table)
Synthetic cell classHuman spreadsheet riskMachine-import question
starts with equalsmay be evaluatedShould the leading character remain literal?
starts with plus or minusmay be interpreted by some applicationsWill numeric parsing change?
starts with at signmay be treated as a formula markerIs the value an email-like identifier or code?
quoted comma textgrammar delimiter onlyDoes downstream unquote once?
leading-zero identifiernumeric coercion riskMust it remain text?
empty string or nullsemantic ambiguityAre blank and unavailable distinct?

Choose a policy and preserve its cost

A spreadsheet-facing export can reject formula-like cells, prefix them with a documented neutralizing character, or deliver a format with stronger cell typing. Each choice changes the value a downstream reader sees. The policy record should say whether the prefix is part of the stored value, whether a human must remove it, and which applications were tested. Never claim universal protection from one worksheet check.

For machine-facing outputs, keep the raw logical value and a consumer contract instead of applying a display workaround. If the same dataset needs both audiences, create two explicitly named artifacts with separate hashes and descriptions. Link this review to the text encoding and row guide for byte-level concerns, but keep formula semantics as a separate threat boundary.

Policy questions

  • Is the file intended for a spreadsheet user, a machine, or both?
  • Which leading characters are classified by the owner policy?
  • Does neutralization preserve the intended literal value for each target consumer?
  • Will a later save and reopen change the cell again?
  • Can the output be rejected instead of transformed when policy is unknown?

Use a text-only fixture

A safe fixture tests classification without opening a real workbook or sending a customer value to a spreadsheet application. Keep a field called expected_literal and another called policy_result. Include formula-like starts, an ordinary negative number, an email-shaped identifier, a quoted comma, an embedded line break, a blank, and a leading-zero code. The fixture proves that the checklist distinguishes cases; it does not prove that a particular application will behave identically.

Record output hashes and policy version for each audience. If the owner cannot state whether the prefix is acceptable to the machine consumer, stop at classification. Do not use a live formula, external reference, macro, or customer-export example in the public worksheet.

Use a text-only fixture (table)
ResultDispositionNext evidence
Policy matches consumer contractcontinueRun approved consumer fixture
Formula-like text is unclassifiedholdOwner chooses reject or neutralize
Prefix changes machine valuesplit artifactsPublish separate audience contracts
Leading zero is lostholdPreserve identifier as text
Only CSV parser was testedincompleteTest spreadsheet interpretation separately

Synthetic CSV safety ledger

Use a text-only fixture code example, Plain text
field | expected_literal | target | policy_result
status_note | =review | spreadsheet | classify_then_neutralize
account_code | 0017 | machine | preserve_as_text
contact_alias | @example.test | spreadsheet | classify_then_confirm
comment | "two, words" | both | quote_for_csv_only
empty_note | (empty) | both | distinguish_empty_from_missing

Write the finding in bounded language

Use wording such as “formula-like prefix classified,” “literal text preserved in the synthetic fixture,” or “spreadsheet behavior unverified.” Avoid saying that a CSV is safe in every spreadsheet or that a quoting rule prevents all injection. Also keep this technical finding separate from authorization to export the source values and from a privacy review.

A format guide can identify an output risk; it cannot decide whether a person is authorized to distribute a file. Keep provenance, field classification, and owner approval in separate records. If a CSV is converted to a spreadsheet, record the conversion step because a later save can change cell types or values.

Write the finding in bounded language (table)
FindingDispositionDo not infer
Formula-like cell classified and policy testedbounded passAll spreadsheet applications are safe
Policy chosen but consumer not testedconditionalThe prefix has no downstream cost
CSV grammar valid onlygrammar passFormula semantics are safe
Literal values preserved in fixturefixture passReal exports contain no sensitive values
Owner permission documentedpermission evidenceThe content is accurate or valuable

Close with a qualified preparation step

After the audience, cell policy, synthetic evidence, and downstream trade-offs are documented, keep the export packet at technical review level. Use the data provenance log for transforms and the schema guide for field meaning. Do not upload raw CSV rows merely to test a formula policy.

For a supported non-health collection, with authority to describe the output and a controlled handling boundary, the qualified appraisal path can be a next preparation step. It does not scan CSVs, neutralize formulas, create a quote, match a buyer, issue a legal opinion, or grant a license. The presence of a neutralization policy also does not prove that the source export may be shared.

Takeaways

  • Review CSV grammar and spreadsheet semantics as separate layers.
  • Classify formula-like starts with synthetic text, never live customer payloads.
  • Choose a consumer-specific policy and preserve its downstream cost.
  • Keep leading-zero, blank, null, and literal formula-like values distinct.
  • Report tested behavior narrowly and leave unverified applications explicit.

Sources

  1. RFC Editor: Common Format and MIME Type for Comma-Separated Values (CSV) Files (opens in a new tab)
  2. OWASP Foundation: CSV Injection (opens in a new tab)

Use the appraisal path after the technical packet is organized.

It does not parse files, certify evidence, create a quote, match a buyer, issue a legal opinion, or grant a license.