Skip to content

Outage explained

The Cloudflare outage of July 2019, explained

A single new firewall rule contained a regular expression that backtracked badly. Deployed everywhere at once, it took every CPU in Cloudflare’s edge to 100%.

4 min read10 sectionsUpdated

On this page

Key points

  • When: 2 July 2019, about half an hour
  • Who: Cloudflare and the sites behind it
  • Impact: HTTP and HTTPS traffic through Cloudflare returning 502 errors worldwide

What happened

Cloudflare’s engineers deployed a new managed rule for its Web Application Firewall, meant to block a type of attack. The rule contained a regular expression that, on certain inputs, caused excessive backtracking. Rules for the WAF were deployed globally at the same time, so within moments every server handling HTTP traffic was spending its CPU evaluating that expression.

With no CPU left, Cloudflare’s proxies returned 502 Bad Gateway errors for traffic across the network. Engineers used a global kill switch to disable the WAF managed rules, traffic recovered, and the rule was fixed and redeployed later.

The root cause

A regular expression with catastrophic backtracking in a firewall rule, combined with a release process that pushed WAF rules to the whole network at once instead of in stages.

Why it was so big

The change bypassed the gradual rollout used for code, because firewall rules were treated as urgent configuration that needed to go out fast. That speed is usually a feature (blocking a new attack quickly) and here made the failure global instantly.

Lessons for every team

Stage configuration like code

Rules, feature flags and config are changes too. Canary them on a small part of traffic before going global.

Bound expensive operations

Use regular expression engines that guarantee linear time, or set CPU limits on rule evaluation.

Keep a kill switch, and know who can use it

Cloudflare recovered by disabling a whole feature globally. Every risky subsystem should have one.

Watch from outside

Internal dashboards share fate with the systems they watch. Checks from several outside regions keep working when your own network, DNS or monitoring stack does not.

What monitoring can and cannot do here

An outside check on your site would show the 502s at once, and the response headers would show they came from the CDN rather than your origin. See 502 Bad Gateway and the Cloudflare error guides for how to tell where an error comes from.

Source: Cloudflare’s blog post with the details of the July 2 outage. This summary is ours; read the original for the full detail.

Frequently asked questions

What caused the 2019 Cloudflare outage?

A WAF rule with a regular expression that backtracked heavily, deployed to all servers at once, exhausting CPU.

What is catastrophic backtracking?

When a regex engine tries an exponential number of ways to match an input, using huge amounts of CPU on a short string.

How long did it last?

About half an hour of major impact.

Check it now, free

Know about your own outages first

Uptime checks every minute, alerts with on-call escalation, incident timelines and a status page, with a free tier on every product.