Formula Injection Exploiting Csv Functionality
Web applications that export user-supplied data to CSV or spreadsheet files without sanitising cells starting with formula characters allow an attacker to inject formulas. When a victim opens the exported file in a spreadsheet program, the formula can execute commands or exfiltrate data.
Published on infosecwriteups.com
Many modern web applications and frameworks offer spreadsheet export functionality, allowing users to download data in a .csv or .xls file suitable for handling in spreadsheet applications like Microsoft Excel and OpenOffice Calc. The resulting spreadsheet’s cells often contain input from untrusted sources such as…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application fails to neutralise cells beginning with formula characters before including user input in exported spreadsheets.
Impact
If the user clicks through security warnings, the injected formula can execute commands on the victim's computer, potentially leading to remote code execution, or exfiltrate spreadsheet contents via hyperlinks.
What the attacker needed
Victim opens exported file in spreadsheet software; victim clicks through security warnings; attacker can supply input that is exported
The fix
Prefix cells that start with '=', '+', or '-' with an apostrophe to prevent them from being interpreted as formulas.
How it was found
- Enter a formula payload as the first name or address line in an eCommerce application.
- Complete the checkout procedure.
- As the victim, use the application's file-export functionality to export the data.
- Open the exported file in Microsoft Excel and click through the security warnings.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a website lets you download data as a spreadsheet, it often puts text you typed into cells. If that text starts with an equals sign, spreadsheet software like Excel treats it as a formula and runs it. An attacker can type a malicious formula into a form, and when someone later opens the exported file, the formula can run commands or steal data.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.