The Spreadsheet That Ran Code — JavaScript Bug Hunt
Inspired by CSV-injection advisories against every export button on the internet: a user names themselves =HYPERLINK(...) and whoever opens the exported…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Injection, CSV
- Modelled on: CSV injection
- Visible tests: formula starters are neutralised; plain values pass through; commas and quotes are escaped
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High)
- Ticket: BUG-CSV-INJ
- Reported by: security
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- formula starters are neutralised — expected "'=SUM(A1:A9)" but got "=SUM(A1:A9)"
- commas and quotes are escaped — expected "\"Doe, John \"\"JD\"\"\"" but got "Doe, John \"JD\""
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Inspired by CSV-injection advisories against every export button on the internet: a user names themselves =HYPERLINK(...) and whoever opens the exported spreadsheet executes it. Cells starting with =, +, - or @ must be neutralised with a leading apostrophe.
csvExport.js writes cells raw.
Bug report
BUG-CSV-INJ · Priority: High · Reported by: security
csvCell(value):
- if the value starts with =, +, - or @, prefix a single quote (')
- double every embedded double-quote and wrap in double-quotes if the value contains a comma, quote or newline
Observed: exported member lists execute formulas in Excel.
Logs
[export] cell: =HYPERLINK("http://evil","click") -> executed on openThe code as shipped
src/export/csvExport.js (editable)
// Renders one CSV cell.
exports.csvCell = function (value) {
return value;
};
Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.