<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chan Lebron</title>
    <description>The latest articles on DEV Community by Chan Lebron (@chan_lebron_61e9204b0aa43).</description>
    <link>https://dev.to/chan_lebron_61e9204b0aa43</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4149614%2Fca3c4b9d-a89d-4b70-a5f5-8a6358174537.png</url>
      <title>DEV Community: Chan Lebron</title>
      <link>https://dev.to/chan_lebron_61e9204b0aa43</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chan_lebron_61e9204b0aa43"/>
    <language>en</language>
    <item>
      <title>CSV Formula Injection: Why =, +, -, and @ Can Be Dangerous</title>
      <dc:creator>Chan Lebron</dc:creator>
      <pubDate>Tue, 29 Sep 2026 12:26:23 +0000</pubDate>
      <link>https://dev.to/chan_lebron_61e9204b0aa43/01-csv-formula-injectionmd-4npd</link>
      <guid>https://dev.to/chan_lebron_61e9204b0aa43/01-csv-formula-injectionmd-4npd</guid>
      <description>&lt;p&gt;CSV looks simple, but a file can be structurally valid and still contain values that behave unexpectedly when opened in spreadsheet software.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSV syntax is not the whole story
&lt;/h2&gt;

&lt;p&gt;CSV itself does not define formulas. A parser may see &lt;code&gt;=1+1&lt;/code&gt; as an ordinary string, while spreadsheet software may interpret the same value as a formula after import.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;id,value
1,=1+1
2,+10+20
3,@SUM(A1:A2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing in that example is necessarily malformed CSV. The risk appears later, when another application decides how to interpret the cell value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters
&lt;/h2&gt;

&lt;p&gt;Formula-like values matter most when CSV data contains user-controlled or externally supplied content. Typical sources include form submissions, CRM exports, support tickets, marketplace data, and administrative reports.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;username,comment
alice,Looks good
bob,"=HYPERLINK(""https://example.com"",""Click"")"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A parser can accept this file while a spreadsheet application may treat the second row differently from plain text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Characters worth checking
&lt;/h2&gt;

&lt;p&gt;Common spreadsheet formula-triggering prefixes include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=
+
-
@
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A match is not automatically malicious. &lt;code&gt;-12&lt;/code&gt; may be a negative number, and &lt;code&gt;+44&lt;/code&gt; may be part of a phone number.&lt;/p&gt;

&lt;p&gt;Spreadsheet behavior also varies by application and locale. Security guidance such as OWASP's CSV Injection material additionally calls out tab, carriage return, line feed, and some full-width variants as cases worth considering.&lt;/p&gt;

&lt;p&gt;That is why reporting the risk and testing against the target spreadsheet application is usually better than assuming one universal rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why automatic sanitization can be risky
&lt;/h2&gt;

&lt;p&gt;One defensive technique is to prefix a value with an apostrophe. That may force some spreadsheet applications to treat the value as text, but it also changes the original dataset.&lt;/p&gt;

&lt;p&gt;For exports, migrations, and audit data, silent rewriting may be undesirable. Some spreadsheet applications may also transform quoting or escaping when a CSV file is saved and reopened.&lt;/p&gt;

&lt;p&gt;A safer workflow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;parse the CSV;&lt;/li&gt;
&lt;li&gt;identify formula-like cells;&lt;/li&gt;
&lt;li&gt;show the row, column, and original value;&lt;/li&gt;
&lt;li&gt;let the user decide whether the value is intentional;&lt;/li&gt;
&lt;li&gt;apply a mitigation appropriate to the target spreadsheet application.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Formula risk is different from malformed CSV
&lt;/h2&gt;

&lt;p&gt;An unclosed quote is a structural CSV error. A quoted value such as &lt;code&gt;"=1+1"&lt;/code&gt; can still be structurally valid while remaining interesting from a spreadsheet-risk perspective.&lt;/p&gt;

&lt;p&gt;Successful parsing does not guarantee safe downstream interpretation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;A CSV file can be valid and still contain values that downstream software interprets in surprising ways.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://owasp.org/www-community/attacks/CSV_Injection" rel="noopener noreferrer"&gt;OWASP: CSV Injection&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Originally published on &lt;a href="https://datatoolforge.com/guides/csv-formula-injection" rel="noopener noreferrer"&gt;DataToolForge&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI-assisted disclosure: I used AI as a drafting/editing assistant and reviewed the technical content before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>csv</category>
      <category>security</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
