CCyberwiki

CAPTCHA and bot protection

CAPTCHA and bot protection
TypeDefensive control
Full nameCompletely Automated Public Turing test to tell Computers and Humans Apart
OWASP Top 10A07:2025 Authentication Failures
Common servicesCloudflare Turnstile, Google reCAPTCHA, hCaptcha
Placed onSign-up, sign-in, password reset, payment forms

A CAPTCHA is a test put in front of a form or an action that a person is expected to pass and a program is expected to fail. The first versions, developed at Carnegie Mellon University, showed letters distorted inside an image and asked the visitor to type them.1 The word is also used for checks that run in the background with no task at all.1 Sites place them on sign-up, sign-in and password reset forms,2 and on the other forms that scripts repeat in Credential stuffing, password guessing, SMS pumping and Card testing.

From puzzles to scores

Text recognition software kept improving until automated tools read distorted text with more than 99% accuracy by 2014.3 Each round of extra distortion made the letters harder for people too, which left character-based challenges impractical.1 The challenges deployed in 2023 asked visitors to pick the image tiles that contain an object, to slide a block into a gap, or to type distorted text, and some judged the visitor's behaviour instead of setting a task.3

Newer services avoid the task when they can. Cloudflare Turnstile has three widget modes: Managed shows a checkbox only to visitors whose browser signals look risky, Non-Interactive shows a spinner while checks run in the browser, and Invisible shows nothing.4 reCAPTCHA v3 never interrupts the visitor. It gives each request a score from 0.0, very likely a bot, to 1.0, very likely a person, and leaves the decision to the site, with 0.5 as the starting threshold.5 For a sign-in with a low score, the documented response is to ask for a second factor or an email check.5

The token and the server check

Whatever the visitor sees, the widget's output is a token, a string the browser sends along with the form. On its own it proves nothing. Anyone can post an arbitrary string to the form's address without loading the widget, so the protection exists only when the site's server sends the token to the provider and acts on the answer.6 The server call carries the secret key, which never goes to the browser:

// Node.js: verify a Turnstile token before creating the account
const r = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    secret: process.env.TURNSTILE_SECRET_KEY,
    response: token,      // the string the widget produced
    remoteip: clientIp,   // optional
  }),
});
const result = await r.json();
if (!result.success) throw new Error("captcha: " + result["error-codes"]);

Tokens are short-lived and meant for one use, so a solved challenge cannot be saved and replayed for many requests. A Turnstile token expires 300 seconds after it is issued, and a second redemption fails with the code timeout-or-duplicate.6 The duplicate check spreads across Cloudflare's network with a delay: the target is to reject at least 99% of repeats that arrive five seconds or more after the first, and two checks sent close together can both pass.6 A reCAPTCHA token lasts two minutes and can be verified once, which is why the token is requested when the visitor acts, not when the page loads.75 A reCAPTCHA v3 response also names the action the token was issued for, and the server should compare it with the action it expected.5

Table 1. Token rules of two common services
Cloudflare TurnstileGoogle reCAPTCHA
Lifetime300 seconds2 minutes
UsesOne, checked with a short delay across the networkOne
Verify endpointchallenges.cloudflare.com/turnstile/v0/siteverifywww.google.com/recaptcha/api/siteverify
Fields to checksuccess, error-codessuccess, and in v3 score and action

How challenges are beaten

Software solves many of them. A University of Maryland study solved Google's audio reCAPTCHA 90% of the time with Google's own speech recognition service.1 A 2023 study in which 1,400 participants solved 14,000 deployed CAPTCHAs set their times and accuracy beside results other researchers had published for automated solvers, and by that comparison bots can beat people on both for every type compared.3

Where software fails, people step in. CAPTCHA farms pay workers to solve challenges that bots forward to them,3 and tools and services exist that break CAPTCHAs on sign-in forms with a reasonably high success rate.8

The cheapest route is a site that skips its own check. A backend that never calls the verify endpoint, or calls it and ignores success, accepts any string as a token, or none.6

Cost to people

In Cloudflare's data, a person needs 32 seconds on average to complete a CAPTCHA.1 Reading distorted text is the task blind, visually impaired and dyslexic visitors are least able to do, and audio versions fail deaf and hard-of-hearing visitors.1 The Web Content Accessibility Guidelines allow a CAPTCHA only with a text alternative that says what it is and a second version for another sense.1 In the 2023 study, solving time rose by 0.09 seconds for each year of the participant's age.3

Some background checks remove the task at the price of exposing much data about the visitor to the provider.1 A site that uses Turnstile's Invisible mode has to reference Cloudflare's Turnstile Privacy Addendum in its own privacy policy.4

Use with other controls

A CAPTCHA on each sign-in attempt may slow Password spraying and credential stuffing.8 Toolkits for credential stuffing such as Sentry MBA route requests through proxy networks so that each IP address sends few of them, which defeats IP block lists and Rate limiting counted per address.8 To spare real users, the challenge can be shown only to requests that look risky, for example every sign-in from a hosting provider's address range. A solve rate far above normal points to an automated solver.8 Two-step or multi-device verification (Multi-factor authentication) is preferred to image challenges for accessibility as well as security.1

In Supabase, CAPTCHA protection for sign-up, sign-in and password reset is switched on under Settings > Authentication > Bot and Abuse Protection > Enable CAPTCHA protection, with hCaptcha or Cloudflare Turnstile as the provider and its secret key entered there. The client passes the token with each call and resets the widget afterwards:2

await supabase.auth.signUp({ email, password, options: { captchaToken } });
captcha.current.resetCaptcha();

Prompt for a coding agent

Find every form and API route in this project that creates an account, signs in, resets a password, sends an email or text message, or takes a payment. For each one, check whether it requires a CAPTCHA token (Cloudflare Turnstile, reCAPTCHA or hCaptcha) and whether the server verifies that token with the provider's siteverify endpoint before doing the work. Where the token is only checked in the browser or not checked at all, add the server call, read the secret key from an environment variable, reject the request when success is false, and for reCAPTCHA v3 also check the action and score. Request the token when the user submits, not on page load, and reset the widget after each submit. List each route you changed and any you were unsure about.

In SecFlash

On the Cloud page, SecFlash reports SF-CLD-533 when Supabase sign-up and login have no CAPTCHA, SF-CLD-308 when Cloudflare Bot Fight Mode is off for a zone, and SF-CLD-407 when the Vercel firewall is off for a project, so its bot protection does not run.

See also

References

  1. a b c d e f g h i W3C Accessible Platform Architectures Working Group. "Inaccessibility of CAPTCHA: Alternatives to Visual Turing Tests on the Web". W3C Group Note.
  2. a b "Enable CAPTCHA Protection". Supabase Docs. Supabase.
  3. a b c d e Searles, A.; Nakatsuka, Y.; Ozturk, E.; Paverd, A.; Tsudik, G.; Enkoji, A. (August 2023). "An Empirical Study & Evaluation of Modern CAPTCHAs". 32nd USENIX Security Symposium.
  4. a b Cloudflare (n.d., read 22 November 2026). "Widget configurations". Cloudflare Turnstile docs.
  5. a b c d Google (last updated 10 July 2024). "reCAPTCHA v3". Google for Developers.
  6. a b c d Cloudflare (n.d.). "Validate the token". Cloudflare Turnstile docs.
  7. back Google (last updated 14 October 2024). "Verifying the user's response". Google for Developers.
  8. a b c d "Credential Stuffing Prevention Cheat Sheet". OWASP Cheat Sheet Series.