Guide
CSV formula injection: detect formulas and import deliberately
A CSV contains text, but Excel or LibreOffice may evaluate cell values as formulas. Check unfamiliar CSVs for unexpected formula prefixes before importing, and explicitly treat sensitive columns as text.
Responsible operator: Tom Silas Helmke, operator of ScanBeforeOpen. Content revised: .
Why even =1+1 produces a finding
A formula prefix does not establish an attack. Harmless arithmetic such as =1+1 demonstrates how data can become an instruction to a spreadsheet on import. The scanner flags known prefixes such as =, +, - and @, selected control characters and Unicode variants.
Links and known function names can also trigger findings. Negative numbers and legitimate formulas therefore need informed review instead of blanket deletion.
The sequence in words
- A CSV consists only of text. It holds no formulas in the spreadsheet sense, only characters that may be interpreted that way later.
- On import the spreadsheet program looks at the start of the cell. If it begins with =, +, - or @, it may treat the cell as a formula.
- A formula can call functions such as HYPERLINK. How far this takes effect depends on program, version and settings.
- The scanner reads the file as text, recognizes formula prefixes even in variants such as fullwidth characters, and reports them without opening anything.
- The cleaned copy puts an apostrophe before the prefix. That does not protect in every program or after saving again.
- If quotes are malformed, the inspection keeps reading tolerantly and reports it. The export stays blocked so nothing is silently changed.
Separators, quotes and complete data
Inspection parses commas, semicolons or tabs, including quoted and multiline cells. Automatic separator selection remains heuristic. Check the displayed columns for unusual dialects.
Strict UTF-8 is supported within 4,000,000 input bytes and characters, and 500,000 cells. Preview is limited to 40 rows. An offered complete CSV export is independent of that preview and must not be a truncated partial copy.
What .clean.csv changes
Detected formula prefixes receive a leading apostrophe. All cells are quoted again, embedded quotes are doubled, and record and column counts are compared after reparsing. BOM, quoting and line endings can change.
If the fully quoted export becomes too large or parsing fails, the report remains available but CSV export is blocked. The original is not overwritten.
Excel and LibreOffice: import, save and reopen
Import the copy deliberately and set relevant columns to text. Check separators, rows, leading zeroes and marked formula cells. Do not double-click sensitive files solely because a report is green.
An apostrophe is not universal formula protection. Saving and reopening can make spreadsheet applications interpret quotes or prefixes differently. Automated readback in this app does not replace a roundtrip in the actual destination application.
Reproducible synthetic example
The cell =1+1 triggers csv.formula. It contains only harmless arithmetic, but it is still a formula prefix that a spreadsheet may interpret.
The findings come from an actual local scan of this test file. Download it and choose it in the scanner. No real personal data or malware.
Download test file: formula-demo.csvExample inspection coverage: complete.
Practical checklist
- Inspect the CSV locally before spreadsheet import
- Check the detected separator and column count
- Review legitimate formulas and negative numbers in context
- Distinguish complete export from the 40-row preview
- Check destination data after import and after saving and reopening
Clear limits
Inspection detects known cell patterns, not intent. Unsupported encodings, dialects and budgets can prevent export. Excel/LibreOffice save and reopen remains a required operator check.
FAQ
Does an apostrophe prevent every CSV injection?
No. Interpretation depends on the spreadsheet application, settings and subsequent saving. Universal neutralization is not promised here.
Does export contain every CSV row?
Only when complete export is offered and all parser and output budgets are satisfied. Errors do not produce a partial CSV export.
Does this checker support XLSX files?
XLSX receives a different, limited Office inspection. The CSV checker does not convert a workbook into a complete cleaned table; Office exports remain blocked.
Received a suspicious file?
Scan it locally before opening, extracting, forwarding, or feeding it to an AI system.
Open scanner