Skip to main content
Skip to content
AI

CSV Formula Injection in 2027: Preserve Text Before Spreadsheet Import

Valid CSV can change meaning at the spreadsheet boundary. DN’s benign fixture preserves literal formulas, plus-prefixed references, quoted commas and line breaks, with exact saved-cell checks.

An emerald grid passes through a transparent blue inspection gate while a blank amber tag is preserved in a separate pocket.
Reading options: audio, text size & sections

DECENTRALISED NEWS · IMPORT CONTROLS · 2027 GUIDE

A trading export can be valid CSV and still change meaning when a spreadsheet opens it. An order reference such as 000123 may need every leading zero. A description containing =1+1 may be four literal characters. A recorded amount of -12.50 may be an ordinary expense. The import process has to preserve those different meanings.

Review field boundaries and column types before handing an export to a spreadsheet or an AI assistant. A list of suspicious prefixes is useful for triage, but the practical objective is more precise: untrusted text should remain the same text, and numeric amounts should be converted only under an explicit schema.

Evidence checked: 29 November 2026. This 2027 guide includes an original six-record CSV, a local parser, a typed workbook fixture and an independent inspection of the saved cells. Every example is fictional. The only evaluated expression in the final workbook is the deliberately authored arithmetic control =1+1. No external commands, network requests or exfiltration examples are used.

Where the interpretation changes

CSV describes a sequence of fields and records. It does not carry the same explicit cell-type information as the workbook we build below. A receiving application makes additional decisions about dates, numbers and formula expressions. Those decisions can alter an identifier or turn text into something evaluated.

OWASP’s CSV injection guidance identifies formula-initiating prefixes and warns that protections can behave differently across applications or after saving and reopening. Its list includes equals, plus, minus and at signs, leading control characters, and some fullwidth variants. The relevant lesson for this workflow is to inspect the actual import boundary and later transformations; there is no universal CSV sanitization rule that preserves every consumer’s behavior.

Our local check therefore reports “needs prefix review,” rather than deciding that a person or file is malicious. It does not delete characters. Removing a plus sign from +00123, converting the result to a number and returning 123 would conceal the very loss we are trying to prevent. Keep the original bytes and the parsed strings as evidence.

A small fixture with awkward, legitimate data

The source has three columns: reference, description and amount_usd. The first two are declared literal text. The third is decimal text awaiting a separate USD amount validation step. The table shows the important cases; JSON notation exposes spaces and line breaks without changing the stored value.

RecordLiteral value or structureWhy it matters
1reference: "000123"; description: "=1+1"Preserve the identifier and treat the description as data.
2reference: "+00123"; description contains a commaA plus-prefixed identifier is meaningful; a quoted comma stays inside its field.
3description: "@desk"A review flag can describe a legitimate label.
4description: "Two \"quotes\""Doubled CSV quotes decode into actual quotation marks.
5description: " =1+1"Two leading spaces remain part of the original string.
6description: "first line\nsecond line"A quoted line break belongs to one field and one data record.

The first record’s -12.50 amount is outside the selected text-column scan. It is not counted as an attack. A full importer would validate that column as a permitted signed decimal, record its currency and scale, and preserve the raw spelling beside the normalized amount. This distinction prevents a security check from silently damaging the accounting data.

A review sequence that preserves evidence

  1. Keep the original export. Record its source, retrieval time, encoding and a checksum. Work from a copy. A later mismatch is easier to investigate when the exact original file still exists.
  2. Parse the file before classifying its contents. A comma inside a quoted description is not a column break. A quoted line break is not a new transaction. Reject inconsistent row widths and unclosed quotes instead of repairing them by guesswork.
  3. Declare which columns are text. References, wallet labels, customer notes and transaction descriptions need literal preservation. Dates and amounts require separate conversion rules; an importer should not infer those rules from a few convenient rows.
  4. Review the output in the application that will consume it. Compare exact values and cell types, not just what the grid looks like. Save, reopen and recheck the specific path used by your team. A later CSV export creates a fresh interpretation boundary.

For an AI workflow, give the assistant a typed table and the schema alongside it. Ask it to report unresolved fields and transformation rules. Do not ask a language model to “clean up” all unusual punctuation and then treat the resulting table as a faithful record. A neat-looking identifier can still be a different identifier.

Try the local review worksheet

This local worksheet parses up to 50 data records and 12 columns. Select text columns explicitly. It displays the parsed strings and marks listed leading prefixes for review without executing them or rewriting the file.

4 of 12 selected literal-text cells need prefix review across 6 data records. The parsed field strings remain unchanged; no formula was evaluated.

Data records
6
CSV columns
3
Selected text cells
12
Prefix review flags
4
Other cells outside prefix review
6
Data recordText columnPreserved value (JSON notation)Review status
1reference"000123"No listed prefix; retain as text
1description"=1+1"Review: formula-like prefix
2reference"+00123"Review: formula-like prefix
2description"Routine, monthly"No listed prefix; retain as text
3reference"A-003"No listed prefix; retain as text
3description"@desk"Review: formula-like prefix
4reference"A-004"No listed prefix; retain as text
4description"Two \"quotes\""No listed prefix; retain as text
5reference"A-005"No listed prefix; retain as text
5description" =1+1"Review: prefix after leading spaces
6reference"A-006"No listed prefix; retain as text
6description"first line\nsecond line"No listed prefix; retain as text
  • This bounded comma-separated CSV parser supports quoted commas, doubled quotes and quoted line breaks. A single leading UTF-8 BOM is removed from the file header only. Other delimiters and encodings need their own import configuration.
  • JSON quotation marks and backslash escapes make spaces, quotes and line breaks visible; they are display notation, not changes to the field. Prefix review does not certify a file safe or identify malicious intent.
  • Only explicitly selected text columns receive prefix review. A legitimate negative number in another column is not classified as an attack; its schema, scale and numeric validity require a separate check.
  • No formula is executed and no neutralized CSV is produced. Import untrusted text through a documented text-preserving path, then inspect the saved workbook and any later export in the intended application.

How to read the default result

The sample contains six data records and twelve selected text cells. Four need prefix review: the first description, the second reference, the third description and the fifth description after its leading spaces. The other six cells belong to amount_usd and are explicitly outside this prefix review. Zero flags would mean only that this particular list found no listed prefix in the selected cells.

The parser accepts comma delimiters, quoted commas, doubled quotation marks, and quoted line breaks. It handles LF or CRLF record endings and removes one file-opening byte-order mark from the header. It rejects malformed quoting, duplicate or blank headers, ragged records and oversized inputs. These are deliberate bounds for a teaching tool, not an assertion that every export format follows this dialect.

Try changing textColumns to reference: the description cells then leave the scope. That is an explicit scope change, not an improvement in file quality. Restore the original selection before comparing results. If an export uses semicolons, a different character encoding or a header containing commas, configure a suitable parser rather than forcing it through this small worksheet.

Documented import settings to inspect

Microsoft’s Text/CSV connector documentation describes a deliberate import route through Get Data and Text/CSV, with a transformation preview. It lets users specify the delimiter and disable automatic type detection so columns initially remain text. Confirm the file origin and the intended character set, then inspect any type-conversion steps before loading. These are documented options, not a claim that DN ran a native Excel import.

If an earlier conversion has already collapsed 000123 into 123, changing the display format cannot reconstruct the missing characters from that number alone. Return to the preserved source and redo the conversion with the right rule. Recheck identifiers at their original length, including any leading plus sign, spaces or punctuation that the schema permits.

LibreOffice’s Text Import help documents an option controlling whether equals-prefixed expressions are evaluated and a Text column type. Inspect both the formula setting and the selected column types. Its delimiter-merging and whitespace-trimming options alter fields, so leave them off when exact blanks and spaces matter. Turning off special-number detection alone does not establish that every identifier remains text. The guide’s Calc settings are documentation-based; native Calc import was not run.

What the downloadable workbook actually proves

DN authored a workbook from the same six records. Its Literal fields sheet contains eighteen source cells. Its separate control sheet contains one literal =1+1 string and one trusted formula using the same characters. The formula control returns 2; the literal cell retains the expression as text.

The independent read used openpyxl 3.1.5 to inspect the saved package. All nineteen intended literal cells matched their source strings exactly and had string cell types. The only formula cell was Benign formula control!B3. The plus-prefixed reference, leading zeros, two spaces, quoted text and embedded line break survived. The inspection JSON records each comparison and the workbook’s checksum.

That distinction required an explicit literal-input mechanism in the workbook authoring API. Assigning a text display format alone did not prevent a leading equals sign from being stored as a formula during development. We corrected the writing path and inspected the resulting package. The API’s leading-apostrophe input escape was consumed for the equals-prefixed literal; the saved value contains no additional apostrophe. This is evidence about this generated workbook, not a portable recipe for adding characters to arbitrary CSV files.

Do not save this workbook back to CSV and assume its cell types travel with it. A subsequent reader sees text fields again and chooses its own interpretation. OWASP also warns that saving and reopening can defeat commonly suggested escaping methods. A workflow therefore needs acceptance checks at the final consumer, even when an earlier step passed.

Define what a successful handoff means

A useful acceptance record names the file checksum, parser dialect, encoding, selected text columns, numeric conversion rules, application version and exact saved artifact. It also records the unresolved rows. “Opened successfully” is too weak: our test needs 000123 to remain that six-character reference and =1+1 to remain data in the intended cell.

For a trading export, link the imported rows back to transaction references and reconcile the appropriate totals after typed conversion. A preserved text value does not establish that the source trade was complete, that a fee was included or that a tax classification is correct. Those are separate checks. Likewise, a clean numeric total does not excuse a changed identifier that breaks a later join.

If the result leaves your team, document whether the recipient is receiving a viewing workbook, a machine-readable data table or a CSV for a particular import configuration. Provide the unmodified source through the agreed process and make any transformations explicit. Avoid calling an edited export “raw” when fields have been prefixed, trimmed or reformatted.

Download and reproduce the evidence

Download the CSV import evidence pack. It contains the benign source CSV, source-record JSON, saved workbook, literal-versus-formula preview, package inspection, parser source and known-answer cases. Read the CSV as text or through a deliberate import path; its only formula-like arithmetic sample is harmless.

The reproduction checks parse the source with Python’s CSV reader, compare every literal workbook cell against the source, enumerate formula cells and run the browser calculator’s fixtures locally. The authoring script is included for environments with the same workbook library; the independent inspection uses openpyxl. No paid API, connected account or subscription is needed to inspect the provided evidence.

For a real operational handoff, DN Research Desk can scope the source-to-import acceptance checks around your actual applications. The AI Operations Starter Kit is an optional DN-owned product for organizing broader workflows. The public fixture and local worksheet stand on their own.

Frequently asked questions

Is every negative value a CSV injection attempt?

No. A signed numeric amount can be legitimate. This worksheet reviews only the columns you explicitly declare to be literal text. A minus-prefixed identifier may deserve a text-preservation check, while an amount column needs its own numeric schema. The flag describes a parsing concern, not the sender’s intent.

Do double quotes around a CSV field force it to remain text?

Do not rely on that assumption. Quotes describe field boundaries, including embedded commas and line breaks. Spreadsheet interpretation also depends on the importer and its settings. Check the resulting cell type and exact value, then repeat the check after any save, reopen or export step used in your workflow.

Does this scanner make an arbitrary financial export safe to open?

No. It is a bounded parser and a review aid for selected text fields. It does not validate every encoding, application behavior, macro, link or downstream transformation, and it does not produce a universally sanitized file. Use the actual application’s documented import path and verify a benign sample before handling operational data.

Were the sample CSV files imported through desktop Excel or Calc?

No. DN parsed the source CSV, authored a workbook using an explicit literal-input mechanism and independently inspected its saved cell types and values. The separate hardcoded formula control evaluates only =1+1. Excel and Calc settings in this guide are based on their official documentation; native import behavior was not tested.

Download the dated worked example, checks and source record. The original local calculation code is available for reproduction.

Get the most talked about stories directly in your inbox

Join the Decentralised News briefing for independent crypto, DeFi and AI analysis. No spam, unsubscribe anytime.