Skip to main content
Challenges are the core mechanism Anubis uses to distinguish humans from bots. When a request triggers a CHALLENGE action, Anubis issues a computational puzzle that is trivial for browsers but expensive for scrapers at scale.

Challenge Metadata

Every challenge issued by Anubis contains structured metadata:
string
required
UUID v7 identifier for the challenge. Used for lookups and validation.
string
required
Challenge algorithm: fast or slow (deprecated).
string
required
64 bytes of random data (hex-encoded) that the client must process.
int
default:"0"
Number of leading zero bits required in the proof-of-work hash (0-64).
string
Hash of the bot rule that issued this challenge. Used to invalidate tokens when policy changes.
bool
default:"false"
Whether this challenge has been solved. Prevents double-spend attacks.

Challenge Types

Anubis supports multiple challenge algorithms, registered in the challenge registry:
The proof-of-work challenge requires clients to find a nonce such that:
Where N is the configured difficulty.
The slow algorithm is deprecated. Use fast for all new deployments. The algorithms are functionally identical; the naming was legacy.

Meta Refresh

The metarefresh challenge uses HTTP meta refresh tags to redirect browsers. This is a passive challenge that doesn’t require JavaScript or computation.
Registered as metarefresh in the challenge registry. Useful for detecting scrapers that don’t process HTML meta tags.

Preact (Interactive)

The preact challenge renders an interactive UI component using Preact. This challenge type verifies JavaScript execution and DOM manipulation capabilities.

Proof-of-Work Mechanism

Validation Algorithm

When a client submits a solution, Anubis validates it in constant time:
1

Extract Parameters

The client submits nonce, elapsedTime, and response (the computed hash).
2

Recompute Hash

Server independently computes SHA256(randomData + nonce).
3

Constant-Time Comparison

Uses crypto/subtle.ConstantTimeCompare to prevent timing side-channels.
4

Verify Difficulty

Ensures the hash has the required number of leading zero hex characters.

Client-Side Solving

The challenge page includes JavaScript that brute-forces the nonce:

Difficulty Settings

Difficulty determines how many leading zero hex characters (4 bits each) are required:
int
default:"0"
Valid range: 0-64
  • 0: No proof-of-work required (instant pass)
  • 1-3: Light verification (milliseconds)
  • 4-6: Moderate difficulty (seconds)
  • 7-10: Heavy computation (tens of seconds)
  • 11+: Extreme difficulty (minutes to hours)

Difficulty Performance Table

These times are approximate and vary based on client hardware and JavaScript engine performance.

Configuring Difficulty

Challenge Lifecycle

Double-Spend Protection: Each challenge can only be solved once. The Spent flag prevents replay attacks where an attacker tries to reuse a valid solution.

Storage Requirements

Challenges are stored with a 30-minute TTL:
Storage backends must support:
  • JSON serialization: Challenges are stored as store.JSON[challenge.Challenge]
  • TTL/Expiration: Automatic cleanup after 30 minutes
  • Atomic updates: For marking challenges as spent
For high-traffic deployments, use Valkey/Redis or another distributed store to share challenge state across multiple Anubis instances.

Challenge Metrics

Anubis exposes Prometheus metrics for monitoring:

Error Handling

Challenge validation can fail with specific errors:
The client didn’t submit required parameters (nonce, elapsedTime, or response).HTTP Status: 400 Bad Request
Parameters have wrong type (e.g., non-numeric nonce).HTTP Status: 400 Bad Request
The solution is incorrect or doesn’t meet difficulty requirements.HTTP Status: 403 Forbidden

Best Practices

Start Low

Begin with difficulty 2-3 and increase only if you observe scraper persistence.

Monitor Solve Times

Use anubis_challenge_time_taken_seconds to ensure challenges aren’t frustrating legitimate users.

Different Difficulty by Context

Use lower difficulty for public pages, higher for sensitive endpoints.

Test Cookie Support

Anubis automatically checks cookie support. Failed cookie tests appear in logs.

Custom Challenge Implementation

You can implement custom challenges by satisfying the challenge.Impl interface:
Register your implementation:

Next Steps

Policies

Learn how to configure bot detection rules that trigger challenges

How It Works

Understand the complete request flow and JWT validation