Skip to content

Cloudflare WAF and 5-second challenge solver

From captcha to zero.

Solve Cloudflare WAF and 5-second challenge pages to a cf_clearance cookie.

A cf_clearance for Cloudflare's managed, JavaScript and interactive challenge pages, through your proxy, charged only when solved.

Solve Cloudflare WAF and 5-second challenge pages too: a task returns the cf_clearance cookie with the user agent it was issued for.

  • $0.80per 1,000, through your proxy
  • $0when a task fails
  • HTTP or HTTPSone fixed address, no SOCKS yet

One challenge task, in and out

Example values

POST /createTask · what you send

type
CloudflareChallengeTaskCapSolver's AntiCloudflareTask works too
websiteURL
https://shop.example.com/the page behind the challenge
proxy
http://user:pass@proxy.example.net:8080the proxy you will browse with: sticky or static

POST /getTaskResult · what you get

solution.cookies.cf_clearance
Dyw1BhDnEAGRy5fh…lets your later requests through
solution.userAgent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) … Chrome/151.0.0.0 Safari/537.36send exactly this User-Agent with the cookie
cost
0.000800charged now, when the clearance is ready

Clearance readyUse the cookie, the user agent and your proxy together, or the site challenges you again.

What it solves

Cloudflare WAF, "Just a moment..." and the 5-second challenge

Three names people search for, and one page to solve: the interstitial challenge Cloudflare shows in front of a site. A CloudflareChallengeTask passes it, whatever it is called.

  • Cloudflare WAF challenge

    A site's Cloudflare WAF rules (custom rules, rate limiting rules and IP Access rules) can answer a request with a challenge instead of the page, when the rule's action is Managed Challenge, Non-Interactive Challenge or Interactive Challenge. Bot Fight Mode and Under Attack mode show the same page.

  • "Just a moment..." and "Checking your browser"

    The interstitial challenge page itself: a full-page screen, sent with HTTP 403 and the header cf-mitigated: challenge, that runs Cloudflare's checks before the visitor reaches the page. "Checking your browser before accessing..." is its older wording, which Cloudflare's reference still uses for Under Attack mode.

  • The 5-second challenge

    The old name for Cloudflare's JavaScript challenge, after the few seconds its page took. Today it is a Managed Challenge or a Non-Interactive Challenge (API value js_challenge), which Cloudflare says typically takes less than five seconds.

  • cf_clearance

    The cookie a browser earns by passing any of them. It lets that visitor through until the site's Challenge Passage time runs out, and it is what a challenge task returns.

A Cloudflare block, such as error 1020, is a refusal rather than a challenge: no task passes it. What error 1020 means

Your proxy

The proxy decides whether the clearance works

Cloudflare ties cf_clearance to the visitor that earned it: in practice its user agent and its address. So the task runs through your proxy, and you use the clearance through that same proxy.

  • HTTP or HTTPS, with its port. SOCKS is not supported yet.
  • One address across connections: a sticky session of a rotating provider, or a static ISP or datacenter proxy, that keeps its address for as long as you use the clearance.
  • A public host, on a port no other protocol reserves. A proxy that resolves to a private address fails with ERROR_PROXY_NOT_ALLOWED, and nothing is charged.
  • There is no proxyless challenge task. A CloudflareChallengeTaskProxyless is refused, and nothing is held.
  • Your proxy's password is never logged, and it is deleted when the task ends.

Sticky session or static proxyClearance accepted

  1. Our solver earns the clearance203.0.113.7
  2. Your next request203.0.113.7

Rotating proxyChallenged again

  1. Our solver earns the clearance203.0.113.7
  2. Your next request198.51.100.24

The task still counts as solved and is charged: we cannot tell that your next connection leaves from somewhere else.

Check yours: ask twice, on two separate connections. The ip= line must match.

TRACE=https://www.cloudflare.com/cdn-cgi/trace
curl -s -x "$PROXY_URL" $TRACE | grep ^ip=
curl -s -x "$PROXY_URL" $TRACE | grep ^ip=

Example addresses, from the documentation ranges.

The code

One request, one clearance

Create a CloudflareChallengeTask with the page's URL and your proxy, read it until it ends, then send the cf_clearance cookie with its user agent through the same proxy. The sample points at our own test page behind a managed challenge, so it runs as copied.

Cloudflare WAF and 5-second challenge, your proxy$0.80per 1,000CloudflareChallengeTask · $0.0008 a clearance · $0 when it fails

See every price

#!/usr/bin/env bash
# Pass this page's Cloudflare challenge through your proxy with createTask, then load the page
# with the clearance.
set -euo pipefail
API=${ZEROCAPTCHA_API:-https://api.zerocaptcha.io}
KEY=${ZEROCAPTCHA_KEY:?Set ZEROCAPTCHA_KEY to your API key, zc_live_..., from the dashboard.}
PROXY=${PROXY_URL:?Set PROXY_URL to your proxy, such as http://user:pass@proxy.example.net:8080}
PAGE=https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge

# 1. createTask for this page, through the proxy you will browse with: the clearance only works
#    from its address. CALLBACK_URL, when set, is called with the result when the task ends.
BODY=$(jq -n --arg key "$KEY" --arg proxy "$PROXY" --arg callback "${CALLBACK_URL:-}" '{
  clientKey: $key,
  task: {
    type: "CloudflareChallengeTask",
    websiteURL: "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge",
    proxy: $proxy
  },
  callbackUrl: (if $callback == "" then null else $callback end)
}')
CREATED=$(curl -sS --fail-with-body "$API/createTask" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d "$BODY")
# errorId 1 is a refusal: errorCode and errorDescription say why.
if [ "$(jq -r .errorId <<<"$CREATED")" != 0 ]; then echo "$CREATED" >&2; exit 1; fi
TASK_ID=$(jq -r .taskId <<<"$CREATED")

# 2. getTaskResult every 2 seconds until the task is ready; errorId 1 means it failed, unpaid.
while :; do
  sleep 2
  RESULT=$(curl -sS --fail-with-body "$API/getTaskResult" \
    -H "Content-Type: application/json" \
    -d "$(jq -n --arg key "$KEY" --arg id "$TASK_ID" '{clientKey: $key, taskId: $id}')")
  if [ "$(jq -r .errorId <<<"$RESULT")" != 0 ]; then echo "$RESULT" >&2; exit 1; fi
  if [ "$(jq -r .status <<<"$RESULT")" = ready ]; then break; fi
done
CLEARANCE=$(jq -r .solution.cookies.cf_clearance <<<"$RESULT")
USER_AGENT=$(jq -r .solution.userAgent <<<"$RESULT")

# 3. Come back as the browser that passed: the same proxy, user agent and cookie. A client whose
#    TLS does not look like that browser may be challenged again (use curl-impersonate).
curl -sS -o /dev/null -w "page: HTTP %{http_code}\n" \
  -x "$PROXY" -A "$USER_AGENT" -b "cf_clearance=$CLEARANCE" "$PAGE"
curl -sS -x "$PROXY" -A "$USER_AGENT" -b "cf_clearance=$CLEARANCE" \
  "https://zerocaptcha.io/api/v1/demo/clearance"
File
challenge.sh 47 lines
Needs
bash, curl, jq and uuidgen
Run
bash challenge.sh
Target
Our managed challenge test page. Set PROXY_URL to your proxy.

What getTaskResult returns

Example values
{
  "errorId": 0,
  "taskId": "0192a6c4-7f1e-7b2a-9d41-3c5e8a10f2b7",
  "status": "ready",
  "solution": {
    "token": "Dyw1BhDnEAGRy5fh…",
    "type": "cloudflare",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36",
    "cookies": {
      "cf_clearance": "Dyw1BhDnEAGRy5fh…"
    }
  },
  "cost": "0.000800",
  "createTime": 1791537240,
  "endTime": 1791537249,
  "solveCount": 1,
  "expiresAt": "2026-10-09T09:44:09Z"
}

expiresAt is when the API stops serving the clearance, 30 minutes after it was issued; read after it, the reply is ERROR_TOKEN_EXPIRED and the task stays charged. How long the site accepts the cookie is up to the site.

Reading the result

solution.cookies.cf_clearance
The cf_clearance cookie's value. solution.token holds the same value.
solution.userAgent
The User-Agent header to send with the cookie, exactly as given.
expiresAt
Until when the API serves the clearance: 30 minutes after it was issued. Read after that, the reply is ERROR_TOKEN_EXPIRED and the task stays charged. How long the site accepts the cookie is up to the site.
cost
What you paid, in US dollars: 0.000800 for a clearance, 0.000000 for a failed task.

In the REST API, GET /v1/tasks/{id} returns the same clearance as solution.cookie.value, with tokenExpiresAt. See the challenge pages docs.

Using the clearance

Come back as the browser that passed

  1. Clearance readycharged $0.0008
  2. Send it with every requestsame user agent, same proxy
  3. Challenged againcreate a new task
  • Send the cookie and the user agent with each request, through the proxy that earned them. Reuse them until the site challenges you again, then create a new task.
  • The site decides how long the cookie works, through its own Challenge Passage setting. Separately, the API serves the clearance for 30 minutes after it is issued, so read it within that time.
  • TLS counts too. A client whose handshake does not look like the browser the user agent names may be challenged again, whatever its cookie. For sites that check, use a client that impersonates the browser, such as curl-impersonate, or a real browser.
  • In a browser you drive, set the cookie for the site's domain and the browser's user agent before loading the page, and route the browser through the same proxy. Browser automation
curl "https://shop.example.com/" \
  --proxy "$PROXY_URL" \
  -H "User-Agent: $USER_AGENT" \
  -H "Cookie: cf_clearance=$CF_CLEARANCE"
File
4 lines
From
The challenge pages docs: Use the clearance

Which task?

Challenge page or Cloudflare Turnstile widget?

Both are tasks on the same API, with the same prepaid balance and the same rule: you pay only when a task succeeds. A page that shows "Just a moment..." before any content is a challenge page.

Challenge page and Cloudflare Turnstile widget compared
QuestionChallenge pageCloudflare Turnstile widget
Where it sitsIn front of a whole site, before any contentInside a page, usually a form
What you getThe cf_clearance cookie and the user agent it was issued forA single-use token for the form
How long it worksUntil the site challenges again, as its own Challenge Passage setting decidesOnce, within 300 seconds
ProxyAlways yours: HTTP or HTTPS, one fixed addressOptional: proxyless, or yours with TurnstileTask
Task and priceCloudflareChallengeTask, $0.80 per 1,000TurnstileTaskProxyless, $0.40 per 1,000; TurnstileTask, $0.40 per 1,000

For a Cloudflare Turnstile widget, see the Cloudflare Turnstile solver.

When it fails

When a challenge task fails, nothing is charged

A challenge task that fails, or is refused, costs nothing. The reply says why, in the API's own words.

How a challenge task can fail
Code and descriptionYou pay
ERROR_CAPTCHA_UNSOLVABLE"Every attempt to solve the challenge failed. Nothing was charged."Not charged
ERROR_TASK_TIMEOUT"The task was not solved before its deadline. Nothing was charged."Not charged
ERROR_PROXY_NOT_ALLOWED"The proxy points at a private or reserved address. Nothing was charged."Not charged
ERROR_INVALID_TASK_DATARefused at createTask when the task has no proxy: "CloudflareChallengeTask needs your proxy: Cloudflare binds a clearance to the IP address that earned it, so it must be earned through the proxy you will use it from." Nothing is held.Not charged
ERROR_DOMAIN_BLOCKEDRefused at createTask: "Tasks for this domain are not allowed by the Acceptable Use Policy." Nothing is held. For a task already created: "The domain was blocked before the task could run. Nothing was charged."Not charged
ERROR_TASK_NOT_SUPPORTEDAnswers a CloudflareChallengeTaskProxyless: a challenge task needs your proxy. Nothing is held.Not charged

A clearance read after its expiresAt answers ERROR_TOKEN_EXPIRED, and its task stays charged: it was solved. Every code is in the errors reference.

Learn and test

Try it on a live challenge page, then read on

Test it on a live Cloudflare WAF challenge page

A page behind each kind of Cloudflare challenge, and one with a pre-clearance widget, to point a challenge task at. Each shows whether your browser holds a cf_clearance cookie.

FAQ

Cloudflare WAF and 5-second challenge questions

Anything else: the challenge pages docs or contact us.

Are Cloudflare WAF and 5-second challenge pages supported today?

Yes. A challenge task passes the page a Cloudflare WAF rule shows through your proxy, and returns the cf_clearance cookie with the user agent it was issued for, charged only when it succeeds.

What is the Cloudflare 5-second challenge?

The old name for Cloudflare's JavaScript challenge page, after the few seconds it took. Today a WAF rule shows a Managed or Non-Interactive Challenge in its place, which Cloudflare says typically takes less than five seconds. A challenge task solves either, and returns the cf_clearance cookie.

Is "Just a moment..." a Cloudflare WAF challenge?

Usually. "Just a moment..." is the challenge page Cloudflare shows when a WAF rule, Bot Fight Mode or Under Attack mode challenges a request. It answers with HTTP 403 and the header cf-mitigated: challenge. A block, such as error 1020, is a refusal rather than a challenge, and no task can pass it.

How is a challenge page different from Cloudflare Turnstile?

A challenge page stands in front of a whole site and, once passed, sets the cf_clearance cookie. Turnstile is a widget inside a page that gives its form a single-use token. They need different tasks.

Why must I reuse the user agent and proxy?

Cloudflare ties cf_clearance to the visitor and device it was issued to: in practice, the browser's user agent and usually its address. Requests with another user agent or from another address are challenged again.

Will I pay for challenges that fail?

No. Every ZeroCaptcha task holds its price and charges it only when it succeeds; a task that fails, or expires before it is solved, costs nothing.

You build. We solve.

Get your first clearance

Create an account, add $10 and run your first task.