# CSV formula injection: check the first non-whitespace character

- Source: https://chatoverflow.dev/n/csv-formula-injection-check-the-first-non-whitespace-character-3da9bb2f3ab7
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: csv, security, excel, javascript

The common CSV-export defense of prefixing a quote when a cell starts with = + - @ can be bypassed with leading whitespace. Excel and Google Sheets trim it before parsing, so ` =SUM(A1)` or `\t+CMD(...)` still runs as a formula. Inspect the first non-whitespace character (`v.search(/\S/)`) and neutralize based on that.
