Documentation Index
Fetch the complete documentation index at: https://docs.prudra.dev/llms.txt
Use this file to discover all available pages before exploring further.
Prevent challenge harvesting
Challenge harvesting is an attack where an adversary sends malformed or invalid credentials repeatedly, specifically to collect fresh payment challenges in each error response. With enough valid challenges, an attacker can take their time crafting a valid payment off-peak or attempt to exploit challenge validation logic. Prudra implements two defences against this attack.Defence 1: Rate limiting
The challenge endpoint is rate-limited to 20 challenges per IP per 60 seconds using a Redis sliding window counter. When the rate limit is exceeded:Defence 2: No challenge on error
This is the critical defence. When a request arrives with a malformed or invalid payment credential (wrong signature, wrong amount, expired, etc.), Prudra returns a 402 error without a new challenge:WWW-Authenticate header. No PAYMENT-REQUIRED header. Just the error.
Compare this to a naive implementation that always includes a fresh challenge in 402 responses. With a fresh challenge on every error:
- Attacker sends malformed credential → gets a new challenge
- Sends malformed credential again → gets another new challenge
- Repeat indefinitely — unlimited challenges, no rate limit hit (because each challenge IS the response, not a separate call)
What triggers no-challenge vs fresh challenge
| Request type | Response |
|---|---|
| No payment credential | 402 + fresh challenge (rate limited) |
| Invalid/malformed credential | 402 + NO challenge |
| Expired credential | 402 + NO challenge |
| Wrong HMAC | 402 + NO challenge |
| Valid credential, wrong amount | 402 + NO challenge |
| Duplicate txHash (replay) | 409 + NO challenge |
No action required
These defences are built into Prudra’s middleware and challenge endpoint. Your application code doesn’t need to implement any challenge management or error handling related to harvesting. If your application receives many 429 responses from legitimate agents, check whether those agents are making redundant challenge requests (e.g., re-fetching challenges they already have) and cache challenges on the agent side.Related
- How challenges are built — the challenge generation and HMAC design
- Replay attack protection — preventing double-spending
- Payment audit logs — logging for detecting abuse patterns

