A marketplace exports seller descriptions into a reconciliation spreadsheet. The export is structurally valid CSV, and the description appears to be ordinary text in the web application. When a staff member opens the file in spreadsheet software, a specially shaped value is interpreted as a formula. The risk emerged at the export boundary, where one system's text became another system's instruction.
CSV export security therefore needs more than correct delimiters and quotation marks. The application must consider the programs people use to open its files and the untrusted data those files contain. A report downloaded from an internal portal can feel trustworthy even when some cells originated with an external seller.
Identify which columns contain untrusted values
Consider a fictional marketplace preparing a monthly reconciliation export. Seller names, descriptions, reference notes and customer-entered identifiers may all be controlled by someone outside the finance team. The application should not treat a field as safe merely because it was stored successfully in the database.
Map the origin of each exported column and its intended type. A calculated numeric quantity differs from a seller-supplied description. Keep those differences explicit when choosing the output format and validation rules. Rendering a value safely as HTML in the browser does not establish how a spreadsheet will interpret it.
OWASP describes CSV injection, also called formula injection, as a risk when untrusted values enter spreadsheet-readable files. Relevant behavior can vary between spreadsheet programs and import settings. Use the current guidance to build a representative test set rather than assuming that a single leading character covers every case.
Separate CSV structure from cell interpretation
RFC 4180 documents common CSV formatting, including fields that need quotation and escaped quotation marks. Those rules address the file's structure. They do not guarantee that a spreadsheet will treat every correctly quoted cell as literal text.
That distinction matters for a common attempted fix: wrapping everything in quotation marks. A parser can remove those structural quotes before a spreadsheet interprets the cell. A file that round-trips through a CSV parser correctly can therefore still be unsuitable for a user's normal spreadsheet workflow.
Do not delete suspicious characters indiscriminately from the source record. They may be meaningful to the seller's description. Design a safe export representation without silently changing the authoritative business data.
Choose an output contract for the intended audience
If the primary audience works in spreadsheets, consider a format and library that let the application express text cell types explicitly, then test the resulting file in the supported applications. That choice still needs review; a different extension alone is not a guarantee.
If CSV is required for another system, document whether it is a machine import or a human spreadsheet export. The acceptable representation may differ, and a safety transformation intended for a person can be inappropriate for a downstream machine consumer. Separate these contracts instead of forcing one file to serve incompatible expectations.
For custom business software, make this decision alongside the export feature itself. It affects filenames, help text, downstream compatibility and the verification required before the file is shared.
Test the file after it leaves the application
Use harmless representative values in an isolated test environment. Open the exported file using the spreadsheet versions and import routes your organization supports. Inspect whether values remain text, whether column boundaries survive and whether saving and reopening changes the interpretation.
Keep a record of supported behavior and repeat the checks after exporter or spreadsheet changes. The completion criterion is practical: the recipient can inspect the intended data without untrusted content unexpectedly becoming an instruction. Passing a download test proves that bytes arrived; it does not prove that those bytes will be interpreted safely.



