Summary
The gateway has no general API rate limiting. 30+ rapid requests to any endpoint complete without a single 429 Too Many Requests response. Previously reported in #101 (closed Feb 27).
The x402 free tier does enforce a 3 req/60s limit (which triggers 429 with rate limit headers per #162), but this only applies to payment-gated endpoints in free mode. Health checks, stamp listing, wallet queries, and other read endpoints have no rate limiting at all.
Evidence
# 30 rapid GET / requests
for i in range(30):
resp = await client.get("/")
# All return 200 — no 429 ever
Additional tests confirm:
GET /api/v1/stamps/ — no rate limiting (100 rapid requests all succeed)
GET /api/v1/wallet — no rate limiting
POST /api/v1/stamps/ — returns 402 (x402) but no 429
POST /api/v1/data/ — returns 402 (x402) but no 429
Rate limiting tests in test_security.py are all skipped because the 429 response is never triggered.
Impact
- DoS vulnerability: Any client can exhaust gateway resources with rapid requests
- Bee node overload: Gateway proxies every request to the Bee node without throttling
- Cost amplification: Stamp purchases hit the blockchain — unthrottled purchases could drain the wallet
Suggested fix
Add rate limiting middleware (e.g., slowapi or custom):
from slowapi import Limiter
from slowapi.util import get_remote_address
limiter = Limiter(key_func=get_remote_address)
# Different limits per endpoint category:
# Read endpoints: 60/min
# Write endpoints: 10/min
# Stamp purchase: 3/min
Ensure rate limiting applies to all endpoints, not just x402 payment paths.
Related
Test references
gateway/test_security.py::TestRateLimiting (9 tests, all skip)
gateway/test_security.py::TestRateLimitBypass (4 tests, all skip)
regression/test_regressions.py::test_101_rate_limit_exists
Summary
The gateway has no general API rate limiting. 30+ rapid requests to any endpoint complete without a single
429 Too Many Requestsresponse. Previously reported in #101 (closed Feb 27).The x402 free tier does enforce a 3 req/60s limit (which triggers 429 with rate limit headers per #162), but this only applies to payment-gated endpoints in free mode. Health checks, stamp listing, wallet queries, and other read endpoints have no rate limiting at all.
Evidence
Additional tests confirm:
GET /api/v1/stamps/— no rate limiting (100 rapid requests all succeed)GET /api/v1/wallet— no rate limitingPOST /api/v1/stamps/— returns 402 (x402) but no 429POST /api/v1/data/— returns 402 (x402) but no 429Rate limiting tests in
test_security.pyare all skipped because the 429 response is never triggered.Impact
Suggested fix
Add rate limiting middleware (e.g.,
slowapior custom):Ensure rate limiting applies to all endpoints, not just x402 payment paths.
Related
Test references
gateway/test_security.py::TestRateLimiting(9 tests, all skip)gateway/test_security.py::TestRateLimitBypass(4 tests, all skip)regression/test_regressions.py::test_101_rate_limit_exists