Skip to content

Cloudflare Security Level and Under Attack Mode: what they actually change

Security Level tunes how suspicious an IP must look before it gets challenged; Under Attack Mode challenges everyone. What each setting really does, when to reach for it, and how to keep APIs alive while it is on.

Security Level is a dial, Under Attack Mode is a tourniquet. The dial (Essentially Off through High) decides how bad an IP’s reputation must be before Cloudflare serves it a Managed Challenge; most zones live on Medium and never think about it. Under Attack Mode is the top of that dial: an interstitial JavaScript check for every visitor, no reputation consulted. It is the right move during an active application-layer flood and the wrong steady state, because everything that is not a browser — APIs, webhooks, mobile apps, uptime checks — fails the check by design.

What’s happening

Both settings live in Security > Settings (with an Under Attack quick toggle on the zone Overview) and are available on every plan, Free included. In the edge’s order of evaluation — DDoS mitigation, IP Access rules, WAF custom rules, rate limiting, managed rulesets, with bot products (Bot Fight Mode on Free, Super Bot Fight Mode on Pro and Business) judging alongside — Security Level acts as its own reputation gate: Cloudflare scores the source IP from network-wide abuse data, and the level sets the score threshold above which a visitor must pass a Managed Challenge before anything else proceeds. Essentially Off challenges only the most flagrant sources; High challenges anything with a blemish. A solved challenge sets a cf_clearance cookie honoured for the Challenge Passage duration (default 30 minutes), so returning visitors are not re-tested each click.

Under Attack Mode replaces the reputation test with an unconditional one: every new visitor gets the “Checking your browser” interstitial (served as a 503 with cf-mitigated: challenge), waits a few seconds while JavaScript proves a real browser, then proceeds with a clearance cookie. Side effects follow directly: any client that cannot run JavaScript and store cookies — curl, SDK HTTP clients, payment webhooks, RSS readers, cron jobs, most crawlers — receives challenge HTML instead of your response. Your uptime monitoring will page you about the “outage” it causes unless it, too, is exempted.

What to check first

  • What the current level is and who set it. Zones inherit years-old decisions; a site stuck on High quietly challenges every VPN and CGNAT user it has.
  • What non-browser traffic the zone serves. List API routes, webhook receivers, feed URLs, and monitoring endpoints before an incident, because these are the paths you will exempt at 2 a.m.
  • Whether the pain is actually reputation-based. If specific users report challenge walls, check Security > Events for Security Level entries versus WAF or bot services — the fix differs per service.
  • Challenge Passage duration. Thirty minutes is fine for most; very short values multiply challenges and complaints.

How to verify

Reproduce what a machine client experiences while Under Attack Mode is on:

# An HTML page: expect 503 + cf-mitigated: challenge + "Just a moment..." body
curl -s -D - -o /tmp/uam.html "https://www.example.com/"
grep -oE "Cloudflare Ray ID: [a-f0-9]+" /tmp/uam.html

# An API route you exempted: expect your normal JSON, not challenge HTML
curl -s -D - "https://www.example.com/api/health"

Read the verdicts the setting is producing:

Security > Events
  Filter: Service equals Security Level
  Read:   Action taken (Managed Challenge / Challenge Solved),
          ASN and Country of who is being challenged

Then test from a clean residential IP: if you are challenged on Medium from a normal home connection, something else (a custom rule, a bot product) is the real actor — check the Service column before touching the dial.

The fix

  1. Set the dial for the site’s audience, once. Medium for most sites; Low or Essentially Off for API-heavy zones where reputation challenges cause more harm than the noise they stop; High only while investigating credential-stuffing waves. This is a posture decision, not an incident response.
  2. Exempt machine paths structurally, not during the fire. Either a Configuration Rule (Rules > Configuration Rules) that sets Security Level to Essentially Off for /api/* and webhook paths, or a WAF custom rule with action Skip that skips Security Level for those paths plus known source IPs. Skip mechanics are in WAF custom rules: block, challenge, log, skip.
  3. During a flood: flip Under Attack Mode on, then start reading. UAM buys origin headroom while you look at Security > Events and analytics for the pattern — paths, ASNs, user agents, JA-style fingerprints on paid tiers.
  4. Convert findings into targeted rules. A custom rule blocking the attack signature or a rate limiting rule on the hammered path outlasts UAM and stops punishing everyone. The DDoS layer’s own knobs are covered in DDoS protection: automatic vs tuned.
  5. Flip UAM off when the targeted rules hold. Watch origin load and event volume; UAM lingering for weeks means challenges for customers, failed integrations, and crawl friction for search engines.
  6. Scope UAM if the attack is narrow. A Configuration Rule can apply Under Attack security level to just /wp-login.php or one hostname, leaving the storefront and API untouched.

When this fix is wrong

If the flood is volumetric at layers 3 and 4, Under Attack Mode is irrelevant — that traffic never reaches the HTTP challenge; Cloudflare’s always-on DDoS mitigation handles it. If specific legitimate users are stuck in challenge loops, the dial is rarely the cure and often the cause — lower it or exempt, do not raise it. And if bots are scraping without an origin-load problem, bot products are the right tool, not a zone-wide challenge wall.

Common mistakes

  • Leaving Under Attack Mode on for a month as “extra security” — it is a challenge wall, not a WAF.
  • Exempting API paths by IP only, then breaking when the SaaS partner rotates egress ranges.
  • Reading UAM’s 503s in monitoring as origin downtime and restarting healthy servers.
  • Raising Security Level to High to fight a targeted attack from clean IPs — reputation gates do not see clean IPs.
  • Forgetting that challenge pages are uncacheable interstitials: under UAM your cache hit ratio drops and origin sees more misses when it can least afford them.

Prevention

Document the zone’s normal posture (level, exemptions, Challenge Passage) and rehearse the UAM flip: who may enable it, what gets exempted, and what “calm enough to disable” looks like in Security > Events. Keep the machine-path exemption rules deployed year-round so an incident toggle never takes your integrations down with the attackers. Reference for the setting and challenge behaviour is under developers.cloudflare.com/fundamentals/.

Tuning edge security so it blocks attacks without blocking customers is ongoing work — Stack Harbor watches those events around the clock under 24/7 Monitoring & Response; book a monitoring and response review.