Server-Side Spreadsheet Injection – Formula Injection to Remote Code Execution
The report describes two cases of formula injection in server-side spreadsheet processing. In the first, a Google Sheets-integrated application exported user data to a spreadsheet, and a malicious formula in a user's profile description caused exfiltration of all spreadsheet data to an attacker-controlled server. In the second, two web applications converted uploaded spreadsheets to images using Excel on a Windows host, and formula injection led to remote code execution via DDE, with one instance allowing cloud metadata access and the other using DNS-based exfiltration.
Published on bishopfox.com
Over the past year, I came across two server-side attack vectors based on CSV injection (explained well here). The first case shows an instance of data exfiltration via Google Sheets Injection, while the second case demonstrates a path from formula injection to remote code execution.
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 applications failed to sanitise user-controlled input before including it in generated spreadsheets, and the server-side spreadsheet processing (Google Sheets or Excel) evaluated formulas without restrictions.
Impact
An attacker could exfiltrate sensitive spreadsheet data (including passwords) and achieve remote code execution on the server, potentially leading to cloud environment compromise; in the second application, egress protections limited direct HTTP but DNS exfiltration was still possible.
What the attacker needed
Ability to inject into a field used in exported spreadsheet; application exports to Google Sheets or converts…; for RCE, server-side Excel processing with DDE enabled
How it was found
- Inject a formula payload into a user-controlled field (e.g., profile description) that is included in an exported spreadsheet.
- The application exports the spreadsheet to Google Sheets, where the formula executes and exfiltrates data to an attacker-controlled server.
- For the second case, upload a spreadsheet containing a DDE formula to an application that converts it to an image using Excel on a Windows host.
- The formula executes on the server, leading to remote code execution (e.g., via PowerShell).
- In the second application with egress restrictions, use DNS-based exfiltration through chained formula injection to obtain a shell.
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.
Spreadsheet software can run formulas that fetch data from the internet or run commands. If a website takes user input and puts it into a spreadsheet without sanitising it, an attacker can inject a formula that steals data or runs code when the spreadsheet is opened or processed on the server. This report shows two real examples: one where a formula leaked all spreadsheet contents, and another where a formula led to a full server compromise.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.