Rate limiting enforced per authenticated user
Why it matters
Without per-user rate limiting, a single authenticated account can exhaust compute, database connections, and third-party API quotas for all users. OWASP API Security Top 10 2023 API4 (Unrestricted Resource Consumption) identifies per-user rate limiting as the primary control against API abuse. CWE-770 (Allocation of Resources Without Limits) covers the structural gap. Beyond resource exhaustion, unthrottled authenticated endpoints expose LLM token costs, external API call charges, and email sending quotas to abuse by any valid user. Competitors, scrapers, and compromised accounts can all trigger cost events at scale without rate limiting.
Severity rationale
Medium because unlimited authenticated requests enable resource exhaustion and cost amplification attacks that degrade service for all users without requiring new credentials.
Remediation
Key your rate limiter on user.id, not IP address, so that authenticated users can't bypass limits by rotating IPs. Return a Retry-After header so well-behaved clients back off correctly.
// src/lib/rate-limit.ts
import { Ratelimit } from '@upstash/ratelimit'
import { Redis } from '@upstash/redis'
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(),
limiter: Ratelimit.slidingWindow(100, '1m'), // 100 req/min per user
})
export async function checkRateLimit(userId: string) {
const { success, reset } = await ratelimit.limit(`user:${userId}`)
if (!success) {
throw Object.assign(new Error('Rate limit exceeded'), {
status: 429,
retryAfter: Math.ceil((reset - Date.now()) / 1000)
})
}
}
Call checkRateLimit(user.id) at the top of any route handler before executing business logic.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the API Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-770 — Allocation of Resources Without Limits or Throttling
- owasp:2021 · A05 — Security Misconfiguration
- owasp:2023 · API4 — Unrestricted Resource Consumption
- soc2:2017 · A1.1 — Processing capacity monitoring and management
- soc2:2017 · CC6.6 — Protection against threats from outside system boundaries
Taxons
History
- 2026-04-18·v1.0.0·Initial import from api-security·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (A1.1, CC6.6) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2