Software DisastersEpisode 05 · Cloudflare WAF rule · 2 July 2019

One Regex Took Down 82% of Cloudflare's Traffic

A firewall rule in simulate mode, reviewed and tested, reached Cloudflare’s servers worldwide in seconds. Its regular expression pinned every CPU core serving web traffic, and switching it off took 25 minutes.

Get the Claude skill

· Watch on YouTube

Free Claude skill · read-only

Runaway regex check

Claude reads your code, validation and firewall rules and deploy config, and tells you where one slow pattern could reach every server and pin its CPUs, with file and line evidence and the first fix to make.

  • No pattern can run away Nested or stacked quantifiers never meet untrusted input.
  • The engine has a ceiling Linear-time matching, or a match limit and timeout.
  • One request has a budget Length caps and timeouts before the regex runs.
  • Tests measure cost Nasty inputs with a time budget, or a ReDoS check in CI.
  • Log-only is live code Simulate and shadow modes get the same gates.
  • Rules roll out in stages A canary first and a health gate, not every server at once.
  • The off switch is reachable A break-glass path that doesn’t need the failing system.
  • Rollback is fast Early alerts, and no full rebuild to undo a rule.

You’ll get a download link by email. Using it confirms your address and subscribes you to new Software Disasters episodes. Unsubscribe anytime. About your email

Install: unzip into ~/.claude/skills/ for Claude Code, or upload the zip under Skills in Claude’s settings. Then ask: “Run the runaway regex check on this repo.”

What happened

A rule that blocked nothing.

At 13:42 UTC on Tuesday 2 July 2019, Cloudflare deployed a new rule to its web application firewall to catch more cross-site scripting attacks. It went out automatically and reached servers around the world within seconds. Three minutes later the first alert fired. Every CPU core that handled web traffic went to nearly 100%, visitors to Cloudflare sites got 502 Bad Gateway errors, and at its worst Cloudflare’s traffic dropped by 82%.

The rule had been reviewed, it passed the tests, and it was in simulate mode, so it blocked nothing. But to measure false positives it had to run on live traffic. Its regular expression ended in .*(?:.*=.*), two greedy “anything” matches side by side. On a backtracking engine like PCRE, rejecting a long string with no equals sign means trying every way to split it between them, again at every starting position.

A CPU protection that would have helped had been removed by mistake in a refactor weeks earlier. WAF rules skipped Cloudflare’s staged rollout by design. A global off switch existed, but the team’s own login service was down, so reaching it took until 14:07, and traffic recovered at 14:09. Cloudflare called it its first global outage in six years: “We’re ashamed it happened.”

The safety net

Five safeguards. The cost got past all of them.

  1. Review and testsApproved and green at 13:37. The suite checked what was blocked, not how much CPU it took.
  2. Simulate modeChanged what happened after a match. The matching still ran on every request.
  3. CPU protectionRemoved by mistake in a refactor of the WAF a few weeks earlier.
  4. Staged rolloutSoftware went through DOG, PIG and canaries. WAF rules skipped it by design.
  5. Global terminateIt worked in two minutes, once the team got past its own downed login service.

What to take away

If it runs on every request, it’s code.

  • Put a ceiling on the cost of a single match.
  • Use an engine that can’t blow up on untrusted input.
  • Test for cost, not just correctness.
  • Treat log-only mode as live code.
  • Stage rule pushes, and keep the global path for real emergencies.
  • Make sure you can reach the off switch during the outage.

What can reach every server in your system in seconds, and what would measure its cost before it got there?

Check your own repository with the skill