Why I Replaced Cloudflare Turnstile With My Own Proof-of-Work

Turnstile worked fine on my forms. I removed it anyway, because on a site that advertises CryptNote it didn’t fit. In its place there’s now a small proof-of-work widget of my own. This post explains how it works and where its limits are.

The privacy mismatch

Turnstile is Cloudflare’s answer to reCAPTCHA. It bothers visitors less than Google’s version and works well, which is why I had added it.

But this site sells CryptNote, a service for encrypted, self-destructing messages that is meant to involve as few third parties as possible. Turnstile does the opposite: it sets a cookie from a domain I don’t own, loads an external script I don’t audit, and connects every visitor who opens a form to an outside vendor.

It’s a small contradiction, but anyone who looks at the site’s network requests sees it right away.

What PoW can and can’t do

A proof-of-work captcha is a cheap spam filter. It makes automated form submission unattractive for naive bots. A few hundred milliseconds of compute per request doesn’t matter to a human, but at a million spam posts an hour it adds up fast.

What it is not:

  • Protection against motivated attackers. Someone serious has GPUs or pays for a solver farm.
  • A replacement for rate limiting. That still happens at the edge via the Cloudflare Rate Limiter.
  • DDoS mitigation. Verification costs my CPU too.

It’s meant for the most common nuisance on a contact form: cheap scripts that submit it automatically.

How the widget works

The flow is the classic one. It lives in a single Rust crate that both the browser (compiled to WASM) and the worker import, so client and server check the rules with the same code.

  1. The server issues a challenge: a random nonce, a difficulty, issue and expiry timestamps, and an HMAC-SHA256 signature over all of it. The difficulty is the number of leading zero bits a valid hash needs.
  2. The browser brute-forces a number whose SHA-256 hash, combined with the nonce, has enough leading zero bits. This runs locally in WASM with no network round trip.
  3. The server checks that the signature is intact, the challenge hasn’t expired and the hash condition holds. If so, the submission goes through.

No third party is involved in any of these steps. Because the challenge is signed, the client can’t lower the difficulty or extend the expiry without the server secret.

The same widget also runs on CryptNote, before a message is created or read.

The widget before anyone clicks it.
Click to verify. The proof-of-work is solved locally in WASM, then accepted.

From spinner to checkbox

The first version was a silent spinner with “Solving challenge…”. It worked, but the UX was bad. An unexplained spinner makes people suspicious, especially right before they submit a form that creates an encrypted message.

The second version is a checkbox. You click it, the widget starts solving in the background, and once the solution is in, the checkbox turns active. Unlike the spinner, a checkbox needs no explanation.

Bots click checkboxes too, so the widget looks at the click itself. A click from a naive bot often fails simple checks: the event isn’t marked isTrusted, it arrives within a few hundred milliseconds of the widget appearing, or it reports a pointer type but sits at coordinates (0, 0). If a click looks off, the widget rejects it and shakes briefly. A person who clicks too early sees that the click didn’t count and can click again. None of this needs a round trip to the server.

The second video shows both: a human click activates the checkbox, a synthetic one triggers the shake.

What changed

The site no longer sets a cookie from someone else’s domain or loads a script I haven’t reviewed. The anti-bot code is part of my own repository, its dependencies are pinned in the lockfile, and I review it along with the rest of the code.