Skip to content

Abuse and rate limiting

Witness accepts hashes without accounts. That makes admission simple but lets a spam client submit many cheap requests unless an operator adds an admission boundary. Rate limits are defense in depth, not a complete abuse-control system.

Current built-in limits

  • Gateway attestation creation is limited to 30 requests per IP per minute, plus a global limit (WITNESS_GLOBAL_RATE_LIMIT_PER_MINUTE, default 600).
  • Gateway read endpoints are limited per client IP by two token-bucket classes (see below).
  • A signing server applies separate limits of 60 requests per peer IP per minute to receipt signing, checkpoint signing, and checkpoint reads.

Read-endpoint limits (GET /v1/*)

The gateway meters unauthenticated GET /v1/* reads with per-client-IP token buckets. Two classes are used because clients poll attestation status much more aggressively than they read config, proofs, or the log:

Environment variable Default Scope
WITNESS_RATE_LIMIT_ATTESTATION_POLL_RPS 20 sustained requests/second for GET /v1/attestations/{hash}
WITNESS_RATE_LIMIT_ATTESTATION_POLL_BURST 40 burst capacity for GET /v1/attestations/{hash}
WITNESS_RATE_LIMIT_READ_RPS 5 sustained requests/second for other gateway /v1 GET routes (config, network, key history, bundles, and log endpoints)
WITNESS_RATE_LIMIT_READ_BURST 10 burst capacity for those other /v1 GET routes

Setting a class's RPS to 0 disables limiting for that class (its burst value is then ignored). A non-zero RPS requires a non-zero burst; startup rejects the configuration otherwise.

Exempt from the read buckets: /health, /metrics, /admin/*, all POST routes (including POST /v1/attestations and POST /v1/verify), and /ws/events. Rejections return HTTP 429 Too Many Requests with a Retry-After header in seconds.

The client IP comes from real_ip, which honors only the same trusted-proxy configuration used by attestation admission. The gateway uses a direct connection IP unless the immediate peer matches a CIDR in WITNESS_TRUSTED_PROXIES (or --trusted-proxy). Behind a proxy, trust X-Forwarded-For only from explicitly configured proxy CIDRs. A spoofable forwarded header can defeat per-IP controls and corrupt operational observations.

These limits do not provide identity, anonymity, or internet-scale resistance to distributed abuse. Restrict witness signing routes to trusted gateways.

Deployment-level admission

The built-in per-IP and global limits are defense in depth. Public operators should add an authenticated edge, network allowlist, or another reviewed abuse control appropriate to their deployment. Set WITNESS_MAX_ACTIVE_JOBS and WITNESS_ATTESTATION_WORKERS to bound database backlog and witness work.