LOGBOOK

HELP

Quiz Entry - updated: 2026.07.05

What was the Apple "goto fail" bug and what coding practice would have prevented it?

A duplicated, unconditional goto fail; skipped Apple's SSL/TLS certificate check (2014) — always using braces on if-statements would have prevented it.

It was a duplicated goto statement that bypassed SSL/TLS certificate validation (2014).

if ((err = SSLHashSHA1.update(...)) != 0)
    goto fail;
    // Always executes!
    goto fail;
// Never reached
if ((err = SSLHashSHA1.final(...)) != 0)
    goto fail;

The second goto fail was unconditional, so the final verification step was never executed — allowing man-in-the-middle attacks.

Prevention:

  • Always use braces for if statements, even single-line bodies
  • Static analysis tools would flag unreachable code
  • Code review should catch duplicate lines
  • Test coverage would show the final check was never executed

Tip: This is why many coding standards mandate braces for all control structures — even one-liners.

Go deeper:

From Quiz: SPRG / Secure Programming Introduction | Updated: Jul 05, 2026