The Spreadsheet That Ran Code

Easy

· Backend

Incident

SEV-2

BUG-CSV-INJ

Priority: High · reported by security

Time to fix: 10 min

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

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

CSV injection

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.

Code map

// Renders one CSV cell.
exports.csvCell = function (value) {
  return value;
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

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

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. 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 open

The 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.