Attack Mode
Attack Mode is Temps's built-in proof-of-work challenge for bot traffic and application-layer (L7) request floods. When enabled, every visitor completes a browser-solved challenge before reaching your app — no third-party CAPTCHA services, no external dependencies, everything runs on your infrastructure. It does not absorb volumetric network DDoS — put a CDN or your provider's DDoS protection in front for that.
The other protections the Temps proxy applies, security headers, the IP access list and vulnerability scanning, are on Security Settings. For the full security overview, see Security. Guide: Replace reCAPTCHA with a proof-of-work CAPTCHA explains the technique behind the challenge.
From v0.1.0-beta.58, Attack Mode is one of the four modes of Shield: off, log, selective and attack. Choosing Attack in the Shield card of the project's security settings is what the older Attack Mode toggle did. This page describes v0.1.0-beta.62. Shield also challenges and blocks only the bad traffic, with the selective mode, without making every visitor solve a challenge.
Overview
Attack Mode is Temps's self-hosted alternative to Cloudflare's "Under Attack Mode." While an environment is in attack mode, every visitor must complete a proof-of-work (PoW) challenge before reaching your application. The challenge is solved automatically in the visitor's browser, with no CAPTCHA images and no third-party service.
Key Features:
- Zero dependencies -- no third-party CAPTCHA services or API keys
- Automatic solving -- visitors see a brief checkpoint page while their browser solves the challenge (a few seconds)
- Signed, stateless challenges -- the server signs each challenge and a solution earns a signed cookie, so nothing is stored per visitor in the database
- 24-hour clearance -- once verified, a visitor can browse freely for 24 hours
- WASM-powered -- Rust compiled to WebAssembly for 30-50x faster solving than JavaScript
- Per-project and per-environment control -- set from the dashboard or API, or project-wide from the CLI
When to use Attack Mode:
- Your application is getting an application-layer request flood
- You're seeing suspicious bot traffic patterns
- You want to protect a public-facing app during a critical event
- You need immediate protection without external service setup
When not to use it:
- For API endpoints consumed by other services. They cannot solve a challenge and get a
429. Exempt their paths or give them a bypass token. - Permanently on production -- it adds latency for first-time visitors. Try
selectivemode first. - For applications whose crawlers are not search engines. Googlebot, Bingbot and a few others pass once their address is verified, and other crawlers are challenged.
How it works
When a visitor requests a page on an environment in attack mode, the Temps proxy runs this flow after the project's edge rules, IP access list and rate limits (see Request flow for where it sits):
Challenge Flow
- Request arrives at the Pingora-based reverse proxy.
- Bypass, exempt path and clearance checks. A valid bypass token, a path on the environment's exempt list, a valid clearance cookie, or a verified search-engine crawler lets the request through.
- Otherwise the challenge depends on the request. A page load (a
GETorHEADthat acceptstext/html) gets a403with the challenge page. Any other request, such as an API call or aPOST, gets a429with aRetry-Afterheader. - The browser solves the challenge. The embedded WASM solver finds a nonce such that
SHA-256(challenge + nonce)has enough leading zero bits. That is about a million attempts at 20 bits. - Solution submitted. The browser posts the solution to
/api/_temps/captcha/verifyon your own host. - Server verifies. The proxy checks the signature on the challenge, that it is not expired (5 minutes) and not used twice, and the solution.
- Clearance issued. The proxy sets the cookie
__Host-temps_clr_<environment id>:Secure,HttpOnly, valid for 24 hours, and bound to that environment and visitor. - Page loads. The browser goes back to the original URL.
A page load over plain HTTP gets 426 Upgrade Required, because the clearance cookie is Secure and cannot be set over HTTP.
Proof-of-Work Details
- Name
Algorithm- Type
- SHA-256
- Description
The solver hashes the signed challenge together with a nonce and increments the nonce until the hash has the required number of leading zero bits.
- Name
Difficulty- Type
- 20 bits in attack mode
- Description
20 leading zero bits is about 1M attempts on average, a few seconds on modern hardware. A visitor who fails three times in an hour gets 22 bits. During a spike in the environment's traffic or errors, up to 4 bits are added, and the difficulty never goes past 24. A challenge that a reputation list or signature asked for, rather than attack mode, starts at 18.
- Name
Visitor identity- Type
- IP prefix + User-Agent + JA4
- Description
A challenge and its clearance are bound to the first part of the visitor's address (the /24 of an IPv4 address or the /64 of an IPv6 one), the User-Agent and the JA4 TLS fingerprint, all read from the connection and never from the request body. Moving between addresses inside one network keeps the clearance.
- Name
Clearance- Type
- 24 hours
- Description
The cookie is valid for 24 hours and for up to 3000 requests an hour on each ingress. Turning attack mode off does not revoke clearances: a visitor who already passed is not challenged again if you turn it back on within that window.
- Name
WASM Solver- Type
- Rust → WebAssembly
- Description
The solver is written in Rust and compiled to WebAssembly via
wasm-bindgen. It uses the optimizedsha2crate and is 30-50x faster than the JavaScript fallback. Progress callbacks update the UI every 10,000 iterations.
- Name
JavaScript Fallback- Description
If the WASM module fails to load (older browsers, disabled WebAssembly), the challenge page falls back to a pure JavaScript solver. It's slower but functional.
Enabling attack mode
Enable Attack Mode (project level)
- 1
Go to Projects and select your project.
- 2
Open Settings then Security.
- 3
In the Shield card, choose Attack.
- 4
Save the settings.
Checkpoint: Confirm the orange "Attack Mode is enabled for this service" banner appears on the project detail page.
Enable Attack Mode (environment level)
- 1
Go to Projects and select your project.
- 2
Open Settings then Environments.
- 3
Select the environment (for example production).
- 4
In its Security section, set Shield mode to Attack.
- 5
Save.
Checkpoint: Open the environment's Shield tab and confirm it shows the attack mode and that it is set on this environment.
Attack Mode can be set from the dashboard or API at both the project and environment level. Via CLI, only project-wide Attack Mode is available (projects settings -p my-app --attack-mode). There is no per-environment CLI subcommand.
Via Dashboard
- Go to Projects and select your project
- Open Settings → Security
- In the Shield card, choose Attack and save
While the project is in attack mode, an orange banner appears on the project detail page:
Attack Mode is enabled for this service -- with a quick-access Disable button.
Disable does not turn Shield off. It sets the project back to log mode.
Via CLI
CLI Commands
# Set the project's Shield mode to attack (environments that follow the project inherit it)
bunx @temps-sdk/cli projects settings -p my-app --attack-mode
The environments CLI command group has no settings subcommand and no
--attack-mode flag, so per-environment Attack Mode can only be set from the
dashboard or the API. The CLI has no command for the other Shield modes
either. To choose selective or off, use the dashboard or the API.
To inspect an environment's mode, open its Shield tab in the dashboard.
Via API
API Examples
# Set the project's Shield mode to attack
curl -X POST "https://your-temps-instance.com/api/projects/{project_id}/settings" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"shield_mode": "attack"}'
# Set it back to log
curl -X POST "https://your-temps-instance.com/api/projects/{project_id}/settings" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"shield_mode": "log"}'
The older {"attack_mode": true} and {"attack_mode": false} still work: true sets attack, and false sets log. If a request sends both fields, shield_mode wins. See Shield for the full API, including null to follow the project.
Per-Environment Override
A common use case is keeping attack mode on for production while off for staging: your public traffic gets the PoW challenge, but internal CI runners and QA engineers are not blocked by it. See Environments for how environments are set up.
- Go to Project Settings → Environments
- Select the environment (production, staging, preview)
- In its Security section, set Shield mode to the mode for that environment, or Inherit to follow the project
An environment's own mode overrides the project's -- it is not additive.
If the project is in attack mode and staging is set to log, staging
traffic is not challenged at all. If the project is in log mode and
production is set to attack, only production visitors must solve the
challenge.
Configuration inheritance
Shield's mode is read at two levels, project and environment. An environment-level mode always wins over the project-level one (not additive); an environment with no mode of its own follows the project. Security headers and the IP access list resolve differently; see Security Settings.