The Invisible Tweet Button

Easy

· Frontend

Incident

SEV-1

BUG-TW-0212

Priority: Critical · reported by security

Time to fix: 10 min

Failing checks on the shipped build

  • the tweet page cannot be framed

    the tweet box must not render inside another site: expected "DENY" but got undefined

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 value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  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

Twitter · 2009

Modelled on the Twitter "Don't Click" clickjacking worm (February 2009): a page showed a single button labelled "Don't Click" over an invisible frame of Twitter's own page. Signed-in visitors who clicked it actually clicked Twitter's update button, posting the same link from their own account and spreading it to their followers. Twitter responded by stopping its pages from being framed by other sites.

This project is a reconstruction. headers.js builds response headers, but it only adds frame protection to a hand-picked list of "sensitive" routes — and the page that posts a tweet is not on it.

Fix buildHeaders so no HTML page can be framed by another site.

Code map

var routes = require("./routes");

var FRAME_SENSITIVE = ["/login", "/settings"];

exports.buildHeaders = function (path, contentType) {
  var h = { "Content-Type": contentType };
  var route = routes.ROUTES[path] || {};
  if (route.csp) h["Content-Security-Policy"] = route.csp;
  if (FRAME_SENSITIVE.indexOf(path) !== -1) h["X-Frame-Options"] = "DENY";
  return h;
};

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 Invisible Tweet Button — JavaScript Bug Hunt

Modelled on the Twitter "Don't Click" clickjacking worm (February 2009): a page showed a single button labelled "Don't Click" over an invisible frame of…

  • Language: JavaScript
  • Layer: Frontend
  • Difficulty: Easy
  • Concepts: Security, Config
  • Modelled on: Twitter · 2009
  • Visible tests: API responses are untouched and login stays protected; the tweet page cannot be framed
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-TW-0212
  • Reported by: security
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • the tweet page cannot be framed — the tweet box must not render inside another site: expected "DENY" but got undefined

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 value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  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

Modelled on the Twitter "Don't Click" clickjacking worm (February 2009): a page showed a single button labelled "Don't Click" over an invisible frame of Twitter's own page. Signed-in visitors who clicked it actually clicked Twitter's update button, posting the same link from their own account and spreading it to their followers. Twitter responded by stopping its pages from being framed by other sites.

This project is a reconstruction. headers.js builds response headers, but it only adds frame protection to a hand-picked list of "sensitive" routes — and the page that posts a tweet is not on it.

Fix buildHeaders so no HTML page can be framed by another site.

Bug report

BUG-TW-0212 · Priority: Critical · Reported by: security

buildHeaders(path, contentType) returns a header object that always has Content-Type = contentType. For EVERY HTML response (contentType starting with "text/html"), on any path, known or not:

  • X-Frame-Options: "DENY"
  • Content-Security-Policy: the route's own policy (routes.ROUTES[path].csp) followed by "; frame-ancestors 'none'", or just "frame-ancestors 'none'" when the route has none

Non-HTML responses keep the route's CSP if any and get no X-Frame-Options.

Observed: /home — the page with the tweet box — can be framed by any site.

Logs

[edge] GET /home referer=http://evil.example/dontclick.html sec-fetch-dest=iframe 200
[statuses] burst of identical "Don't Click" updates from unrelated accounts

The code as shipped

src/web/headers.js (editable)

var routes = require("./routes");

var FRAME_SENSITIVE = ["/login", "/settings"];

exports.buildHeaders = function (path, contentType) {
  var h = { "Content-Type": contentType };
  var route = routes.ROUTES[path] || {};
  if (route.csp) h["Content-Security-Policy"] = route.csp;
  if (FRAME_SENSITIVE.indexOf(path) !== -1) h["X-Frame-Options"] = "DENY";
  return h;
};

Read-only context: src/web/routes.js.

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.