Skip to content
PHP critical fixes (php2shell)PHP fixed two critical remote code execution flaws on 21 October 2026. Check whether your site discloses an affected PHP version.Check your site
Back to insights

Cloudflare Under Attack mode: when to turn it on, and what it breaks

Under Attack mode challenges every visitor to your site. It can buy time during an HTTP flood, but it breaks APIs, apps and webhooks. When to use it, how to scope it and what to do first.
Ilyas Esmail

Ilyas Esmail

Founder & CEO

Listen to this article

0:00 / –:––

Key takeaways

  • Under Attack mode shows a challenge page to every visitor. It only helps against HTTP (layer 7) floods; Cloudflare handles network-layer attacks automatically.
  • Cloudflare calls it a last resort. Targeted rules on the attacked path usually stop a flood with less damage.
  • Apps, APIs, webhooks and monitoring cannot pass a challenge, so scope the mode to browser paths or exempt the rest.
  • Plan the exit when you turn it on, and replace it with targeted rules once you understand the attack.

The site is slow, the origin is at 100% CPU, and someone in the incident channel says "turn on Under Attack mode". It is one switch in the Cloudflare dashboard, and it often does stop the flood. It also stops your mobile app, your payment provider's callbacks and your uptime monitoring, and nobody notices until the next morning.

This post covers what Under Attack mode actually does, when it is the right call, how to limit the damage, and how to stop a DDoS attack with more targeted tools.

What Under Attack mode does

I'm Under Attack mode adds extra checks to help mitigate layer 7 (HTTP) DDoS attacks1. With it on, visitors see an interstitial challenge page before your site loads. Today that page is a Cloudflare Managed Challenge, and the browser needs JavaScript to pass it.

A visitor who passes gets a cf_clearance cookie and is not challenged again until it expires. The default lifetime is 30 minutes, set under challenge passage in the security settings2.

What it does not do:

  • It does not touch network-layer attacks. Cloudflare mitigates layer 3 and 4 DDoS attacks automatically on every plan3. If your problem is a volumetric flood against an IP address, this switch is irrelevant.
  • It does not protect an exposed origin. If attackers already know your origin's IP address, they can bypass Cloudflare entirely.
  • It is not selective. Every request from every visitor on the affected hostnames is challenged, including your best customers.

The scale of both kinds of attack is large. In the first half of 2026 alone, Cloudflare reported mitigating4:

HTTP DDoS requests
29.64 trillion
The layer Under Attack mode helps with
Network-layer DDoS attacks
23.2 million
Mitigated automatically, with no switch to flip
Network-layer attacks over 1 Tbps
935
Cloudflare, H1 2026

Cloudflare's own documentation describes it as one of the last resorts when a zone is under attack, and warns that it pauses access to your site, affects analytics and may affect API traffic15.

What it breaks

Anything that is not a person in a browser cannot solve a challenge. Before you turn it on, list what talks to the zone:

ClientWhat happensWhat to do
Mobile app calling an APIGets a challenge page instead of JSON; the app shows an errorExempt the API hostname or path
Payment provider webhooksCallbacks fail; orders stay "pending"Exempt the callback path, then check orders after the incident
Partner and B2B integrationsRequests fail silently on their sideExempt by path, and tell the partner
Uptime monitoringReports the site as down, or as up because it sees a 403 pageExpect false alerts; check monitors after
Embedded widgets, iframes and single-page app fetchesPartial pages, broken formsTest the key journeys with the mode on
Search engine crawlersCloudflare's 2012 launch post said it was designed not to block them; current documentation doesn't restate thisDon't leave the mode on for days
With Under Attack mode on, a browser passes the challenge once. An app or webhook never does.

The mode also changes what your analytics see, so traffic charts from the incident window are not comparable with normal days.

When to turn it on

Under Attack mode is the right call when all of these are true:

  • The attack is HTTP traffic hitting your site through Cloudflare, not traffic to your origin's IP address.
  • The origin is failing or close to it, so you need relief in minutes.
  • You can't yet see a pattern (a path, country, ASN or user agent) to write a targeted rule against.
  • The site is mainly used in browsers, or you can exempt the API and integration paths.

If you can already see the pattern, a targeted rule is better. If the site is mostly an API, Under Attack mode will hurt you more than the attacker.

A quick decision during an HTTP flood

How to turn it on, and how to scope it

For the whole zone

In the Cloudflare dashboard, open the zone overview and use the Under Attack mode toggle in Quick Actions1. It takes effect within seconds.

Through the API, Under Attack mode is the under_attack value of the zone's security_level setting:

under-attack-on.shBash
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/settings/security_level" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"value":"under_attack"}'

Keep the command, and the one that sets it back, in your incident runbook, so turning it off is as easy as turning it on.

For one path, or with exceptions

You don't have to challenge the whole site. A configuration rule can turn Under Attack mode on for matching requests only, such as /login or /search, where the flood is landing1. The same kind of rule can turn it off for paths that must keep working, such as /api/ or your payment callback route.

Scoping to the attacked path is usually the best compromise. Customers browsing the rest of the site see nothing, and the attacker's traffic to the expensive endpoint gets challenged.

How to stop a DDoS attack on Cloudflare, in order

Under Attack mode is one step in a sequence. When an HTTP flood starts, work through this list:

  1. Confirm the traffic comes through Cloudflare. If the origin's IP address is exposed, attackers can bypass the edge. Allow only Cloudflare's IP ranges at the origin firewall, and move the origin if its address is widely known.

  2. Look at Security Events and analytics. Find what the attack has in common: path, method, country, ASN, user agent, query string. Even a rough pattern is enough for a first rule.

  3. Write a targeted rule. A WAF custom rule with a managed challenge or block on that pattern, or a rate limiting rule on the attacked path. Our post on Cloudflare rate limiting rules covers thresholds.

  4. Check the HTTP DDoS managed ruleset. It is always on. You can change its sensitivity and action with an override, and Cloudflare recommends keeping the default high sensitivity6.

  5. Cache what you can. Requests served from cache never reach the origin. A flood against a cacheable page often ends with one cache rule.

  6. Use Under Attack mode if the origin is still failing, scoped as tightly as you can, while you keep looking for the pattern.

  7. Plan the exit. Once a targeted rule holds, turn Under Attack mode off, watch for ten minutes, and record what you changed and why.

Our Learn article on how to stop a DDoS attack covers the wider picture, including attacks that aren't on Cloudflare yet. For what Cloudflare's latest attack data means for your configuration, see what Cloudflare's H1 2026 DDoS report means for your edge.

After the incident

Under Attack mode left on is a common finding weeks after an incident. Close the loop:

  • Turn it off and confirm the security level is back to its usual value.
  • Check the integrations in the table above. Look for orders stuck in "pending", failed partner calls and app error reports during the incident window.
  • Keep the targeted rules that worked, with a review date, and remove the ones that didn't.
  • Write down the pattern and the rule that stopped it, so the next on-call engineer starts at step 3, not step 1.

Under attack and not on Cloudflare yet

If the site is not behind Cloudflare, none of the above applies until it is. Vigilbase runs emergency Cloudflare onboarding to move exposed web traffic onto Cloudflare and stabilise it. For a single domain that should have been protected before the attack, Vigilbase Shield puts it behind Cloudflare with managed WAF rules and DDoS protection on a monthly plan. How we operate Cloudflare DDoS protection day to day, including who leads an incident, is set by the Managed Cloudflare package and the SLA.

What does Cloudflare Under Attack mode do?

It shows a Managed Challenge page to every visitor before your site loads. Browsers that pass get a cookie that lasts 30 minutes by default. It only helps against HTTP floods; Cloudflare handles network-layer attacks automatically.

Should I leave Under Attack mode on all the time?

No. Cloudflare describes it as a last resort that pauses access to your site and affects analytics and API traffic. Use it during an attack, scope it as narrowly as you can, and replace it with targeted rules.

Does Under Attack mode affect my API?

Yes. API clients, mobile apps and webhooks cannot pass a challenge. Use a configuration rule to turn the mode off for API paths, or turn it on only for the browser paths under attack.

Does Under Attack mode hurt SEO?

Cloudflare designed it not to block search engine crawlers, but its current documentation doesn't restate that. A few hours during an attack is unlikely to matter; leaving it on for weeks is a risk you don't need.

Sources

  1. Cloudflare, Under Attack mode: what it does, Quick Actions and configuration rules.

    ↩
  2. Cloudflare, Challenge passage: cf_clearance lifetime.

    ↩
  3. Cloudflare, DDoS protection: automatic network-layer and HTTP DDoS mitigation on every plan.

    ↩
  4. ↩
  5. Cloudflare, Security Level: when to use Under Attack mode and the current Security Level behaviour.

    ↩
  6. Cloudflare, HTTP DDoS attack protection: sensitivity, actions and overrides.

    ↩

Share this article

Tags

CloudflareDDoSUnder Attack modeIncident response

Get a free Cloudflare Checkup

An A–F grade for your Cloudflare account in about 2 minutes. Read-only: sign in with Cloudflare, and access is revoked when the scan finishes. The grade and free findings cost nothing; the full report is an optional upgrade.

Run the free Checkup
Ilyas Esmail

Ilyas Esmail

Founder & CEO

Ilyas founded Vigilbase to simplify how businesses get their cybersecurity work done. On this blog, Ilyas writes about cybersecurity, Cloudflare and the work of keeping businesses secure.

About Vigilbase

Vigilbase is the cybersecurity operating system. Vigilbase OS connects the security tools an organisation already pays for, keeps their logs and events in one auditable place, and has the Vigil agent investigate, make authorised fixes and verify the result. As a Preferred Cloudflare Partner, Vigilbase also sells Cloudflare Enterprise and operates it as Managed Cloudflare. Vigilbase is ISO 27001 and SOC 2 Type 2 compliant.

Stay ahead of threats

Get the latest cybersecurity insights and best practices delivered to your inbox.