Web Bot Auth rules
Web Bot Auth lets an agent or a crawler sign each request with HTTP Message Signatures (RFC 9421). The Signature-Agent header names the agent's directory of public keys, at /.well-known/http-message-signatures-directory, and Signature-Input and Signature carry the signature. Unlike a User-Agent string or an IP range, a signature can't be copied to another host or replayed after it expires.
A Web Bot Auth rule verifies the signature and matches on the result.
What CasWAF checks
CasWAF looks at the signatures with tag="web-bot-auth" and verifies each until one passes:
- the signature has
created,expiresandkeyid, is not expired, and was not created in the future, allowing 60 seconds of clock difference - it covers
@authorityand theSignature-Agentheader, so it is only good for this host and this directory - the algorithm is Ed25519
- the directory named in
Signature-Agenthas a key whose JWK thumbprint is thekeyid, and the signature matches
The result is one of:
| Result | Meaning |
|---|---|
verified | A signature passed all the checks |
invalid | The request carries a Web Bot Auth signature, but it is malformed, expired, for another host, or doesn't match, or the directory can't be fetched |
unsigned | No Web Bot Auth signature |
Operators
| Operator | Value | Matches when |
|---|---|---|
is | verified, invalid or unsigned | the result is the value |
is not | verified, invalid or unsigned | the result is anything else |
is in | hosts, separated by commas | the result is verified, and the host of Signature-Agent is in the list |
is not in | hosts, separated by commas | the request isn't verified with a key from one of these hosts |
A host in the list is the host of the directory, such as id.casdoor.com, compared without case. *.example.com matches every subdomain of example.com. A rule matches when any of its expressions matches.
The directory
CasWAF fetches the directory over HTTPS or HTTP, follows at most 3 redirects, gives up after 5 seconds, and reads at most 1 MB. It keeps the Ed25519 keys of a directory for an hour, and remembers a failed fetch for 5 minutes. It doesn't send the fetch through a proxy.
CasWAF doesn't fetch directories on loopback, private or link-local addresses, so that a signed request can't make it call your internal services. To verify agents whose directory is on your own network, add to conf/app.conf:
webBotAuthAllowIntranet = trueExamples
Let verified agents through. Type Web Bot Auth, operator is in, value id.casdoor.com, action Allow. Put it before the User-Agent and rate limiting rules that block bots.
Block forged signatures. Type Web Bot Auth, operator is, value invalid, action Block.
Only signed agents on an API for agents. A compound rule of a URL Path rule for ^/agent-api/ and a Web Bot Auth rule is not verified, action Block, status code 401.
Casdoor keeps the keys of agents, publishes the directory and signs requests for them.
WAF rules
Write ModSecurity SecLang rules for CasWAF, run by the Coraza engine: what they can see, which actions count, and examples for SQL injection, XSS and scanners.
CAPTCHA
Send visitors that match a rule through a Casdoor CAPTCHA instead of blocking them, and let them in for 30 minutes once they pass.