CSV injection in gratipay.com via payment history export feature.
A participant's name was written directly into an exported CSV file without neutralising formula characters, so a name beginning with a formula could run commands when the file was opened in a spreadsheet. An attacker could exfiltrate data or execute code on the victim's machine.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 7 months
- Disclosed after 7 months
I discovered this issues thanks to Matt who pointed out that the participant's name is directly placed into a CSV file: https://github.com/gratipay/gratipay.com/issues/4399#issuecomment-292250609
Summary
Gratipay allows users to export payment history as a .csv file. By injecting a payload into a participant's name an attacker could exfiltrate data or execute code on the target machine. For instance, with =cmd|' /C calc'!A0 I am able to open up calc.exe on Windows.
Steps to reproduce
- Create a user A called
=cmd|' /C calc'!A0; - User B donates a small sum to user A;
- Export payment history from B;
- Open the .csv file on a Windows machine.
Result: calc.exe pops up.
Fix
Prefix =, +, - and @ symbols with a ' in issues when exporting them to a .csv file.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the export wrote user-controlled names into CSV cells without escaping leading formula characters.
Impact
Opening the exported file could execute code on the victim's machine, and the report also states data could be exfiltrated.
What the attacker needed
An account; victim opens the exported CSV in a spreadsheet; Windows machine
The fix
The export should prefix formula-leading characters with an apostrophe so spreadsheet software treats them as text.
How it was found
- Create a user whose name is a spreadsheet formula.
- Have another user donate a small sum to that user.
- Export the payment history from the second user's account.
- Open the downloaded CSV file on a Windows machine.
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 report has not been written yet. The Original tab links to the source.
A CSV file is a simple spreadsheet format. Some spreadsheet programs treat any cell starting with an equals sign as a formula and run it. Because the site put a user's chosen name straight into the file, a malicious name could become a formula that runs a program when the file is opened.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.