Goto Fail, Goto Fail

Easy

· Backend

Incident

SEV-1

BUG-GOTOFAIL

Priority: Critical (auth bypass) · reported by security audit

Time to fix: 10 min

Failing checks on the shipped build

  • a forged signature is rejected

    the signature check must gate the result: expected false but got true

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

Apple · CVE-2014-1266

Modelled on Apple's goto fail bug (CVE-2014-1266, February 2014): a duplicated goto fail; line in the TLS handshake meant the final signature check was never executed. Every certificate that got that far was accepted, so anyone on the network could impersonate a secure site.

verify.js runs three checks in sequence and returns whether the certificate is trustworthy — except one of them can never fail the request.

Fix verifyCertificate so all three checks actually gate the result.

Code map

// Returns true only if every check passes.
exports.verifyCertificate = function (cert) {
  var ok = true;

  if (!cert.chainValid) {
    ok = false;
    return ok;
  }

  if (!cert.notExpired) {
    ok = false;
    return ok;
  }
    return ok;

  if (!cert.signatureValid) {
    ok = false;
    return ok;
  }

  return ok;
};

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.

Goto Fail, Goto Fail — JavaScript Bug Hunt

Modelled on Apple's goto fail bug (CVE-2014-1266, February 2014): a duplicated goto fail; line in the TLS handshake meant the final signature check was…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Security, Control Flow
  • Modelled on: Apple · CVE-2014-1266
  • Visible tests: a fully valid certificate is accepted; a forged signature is rejected
  • Reward: 50 XP for a complete fix

Incident

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

Failing checks on the shipped build

  • a forged signature is rejected — the signature check must gate the result: expected false but got true

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

Modelled on Apple's goto fail bug (CVE-2014-1266, February 2014): a duplicated goto fail; line in the TLS handshake meant the final signature check was never executed. Every certificate that got that far was accepted, so anyone on the network could impersonate a secure site.

verify.js runs three checks in sequence and returns whether the certificate is trustworthy — except one of them can never fail the request.

Fix verifyCertificate so all three checks actually gate the result.

Bug report

BUG-GOTOFAIL · Priority: Critical (auth bypass) · Reported by: security audit

verifyCertificate(cert) must return true only when ALL of these hold:

  • cert.chainValid is true
  • cert.notExpired is true
  • cert.signatureValid is true

Observed: a certificate with signatureValid=false is still accepted, as long as the first two checks pass.

Logs

[tls] accepted cert issuer="Totally Legit CA" signatureValid=false
[tls] MITM proxy interception went undetected in staging

The code as shipped

src/tls/verify.js (editable)

// Returns true only if every check passes.
exports.verifyCertificate = function (cert) {
  var ok = true;

  if (!cert.chainValid) {
    ok = false;
    return ok;
  }

  if (!cert.notExpired) {
    ok = false;
    return ok;
  }
    return ok;

  if (!cert.signatureValid) {
    ok = false;
    return ok;
  }

  return ok;
};

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.