返回提示词目录第 1367 页

后端接口限流与滥用防护审计

审查后端接口限流策略、分布式计数和成本控制,定位可验证的绕过、容量及用户公平性问题。

完整提示词

# RATE LIMITING AND ABUSE PROTECTION AUDIT

I want you to perform an ultra-deep, systematic, evidence-first, and production-oriented analysis of the complete rate limiting and abuse protection system across the backend/API application.

Main goal:

> Determine whether the system genuinely restricts abuse, protects expensive or sensitive endpoints, prevents trivial bypasses, functions correctly across multiple backend instances, and does not penalize legitimate users more than it protects infrastructure.

This is not:

- generic advice to add a Redis rate limiter
- a single global "100 req/min" limit for the whole system
- an infrastructure-wide DDoS audit
- a WAF marketing checklist
- automatic IP-based blocking
- an automatic CAPTCHA solution
- a replacement for authorization
- a replacement for fraud detection
- an attempt to aggressively throttle every endpoint

Focus is on the actual abuse and capacity model:

```text
request
↓
identity extraction
↓
rate-limit key
↓
policy selection
↓
counter/token state
↓
allow / delay / reject
↓
headers / retry guidance
↓
monitoring
```

Priority:

**critical abuse prevention > bypass resistance > distributed correctness > account fairness > capacity protection > false-positive reduction > operational visibility**

It is better to find 6 real abuse bypasses or limiter failures than to write 100 generic security recommendations.

---

# 1. DETERMINE RATE LIMIT STACK

Before findings, establish:

- reverse proxy
- CDN
- WAF
- API gateway
- application limiter
- Redis/cache
- database counters
- in-memory counters
- serverless platform protections
- cloud provider quotas
- queue admission control
- login protection
- CAPTCHA/challenge where present

---

# 2. MAP ALL LAYERS

Map:

```text
Internet
↓
CDN/WAF
↓
Load balancer
↓
Gateway
↓
Backend limiter
↓
Business quota
```

Distinguish:

- infrastructure rate limits
- API abuse limits
- authentication brute-force protections
- business quotas
- billing quotas

---

# 3. DO NOT CONFUSE BUSINESS QUOTAS WITH ABUSE LIMITS

Example:

```text
5 exports/month
```

is a product/business entitlement rule.

```text
10 export requests/min
```

is an abuse and capacity protection mechanism.

Both can legitimately coexist.

---

# 4. CREATE ENDPOINT ABUSE INVENTORY

For each critical endpoint record:

```text
Method:
Route:
Public/authenticated:
Cost:
Side effect:
Sensitive:
Brute-force surface:
Enumeration surface:
Current limit:
Limiter key:
```

---

# 5. RISK CLASSIFICATION

Classify endpoints as:

```text
LOW COST
EXPENSIVE
AUTH SENSITIVE
WRITE SENSITIVE
ENUMERATION SENSITIVE
EXTERNAL-COST
BULK
FILE
ASYNC JOB
```

---

# 6. GLOBAL LIMIT IS NOT ENOUGH

A single user can exhaust a global request budget across inexpensive reads or concentrate traffic on catastrophic expensive writes.

Verify route-specific policies.

---

# 7. CHEAP VS EXPENSIVE REQUEST

Example:

```text
GET /health
```

does not carry the same cost as:

```text
POST /reports/generate
```

---

# 8. LIMITER IDENTITY

Establish what drives the rate-limit key:

- IP address
- user ID
- API key
- tenant ID
- session ID
- device token
- route
- composite combination

---

# 9. IP-ONLY LIMIT

IP is a weak identity signal.

Complications:

- corporate NAT
- office proxies
- carrier-grade NAT (mobile)
- VPNs
- IPv6 rotation
- proxy networks

Do not dismiss IP limiting entirely, but audit the specific operational context.

---

# 10. SHARED NAT

Scenario:

```text
100 legitimate users
↓
same public IP
```

A single aggressive user can throttle all 99 colleagues.

---

# 11. ACCOUNT LIMIT

Authenticated abuse is generally far better governed through principal, user, or account identities.

---

# 12. IP + ACCOUNT

A hybrid composite model is often effective for login and write abuse defense.

Do not mandate universally.

---

# 13. TENANT LIMIT

Multi-tenant systems typically require:

- per-user
- per-tenant
- global

layered tiers.

---

# 14. NOISY TENANT

A single high-volume tenant must not starve shared multi-tenant resources when fairness is expected.

---

# 15. API KEY LIMIT

Where external integrations use API keys:

verify key-scoped quotas and bucket isolation.

---

# 16. PUBLIC ENDPOINT

When unauthenticated:

network and IP-derived signals may be the only available data.

Document the inherent limitations.

---

# 17. TRUSTED PROXY

If limiters evaluate client IP behind a reverse proxy:

verify `trust proxy` or equivalent gateway configuration.

---

# 18. SPOOFED FORWARDED HEADER

Critical bypass:

```text
client sends X-Forwarded-For
↓
backend blindly trusts it
↓
attacker rotates header value
↓
new limiter bucket every request
```

---

# 19. PROXY CHAIN

Determine which hop in the proxy chain is genuinely trusted.

---

# 20. `X-REAL-IP`

Same evaluation applies.

---

# 21. CDN IP HEADER

If a CDN injects verified client IP headers:

ensure the origin backend cannot be reached directly via bypass routes allowing header spoofing.

---

# 22. IPV6

Attackers possess vast IPv6 address blocks (/64 subnets).

Rate limiting by full 128-bit IPv6 address is easily evaded via rapid address rotation.

---

# 23. IPV6 PREFIX

Some systems aggregate limits across IPv6 /64 or /48 subnets.

Do not recommend specific prefix lengths without network context.

---

# 24. MULTI-INSTANCE

The primary architectural question:

> Is the limit enforced globally or strictly per process instance?

---

# 25. IN-MEMORY LIMITER

Scenario:

```text
limit = 100/min
backend replicas = 10
```

If each replica maintains local counters:

effective limit scales to ~1,000 requests/min across distributed traffic.

---

# 26. LOAD BALANCER

Sticky sessions alter distribution, but must not be assumed without explicit verification.

---

# 27. SERVERLESS

Every serverless function instance maintains isolated memory.

In-memory limiters provide zero global guarantees in serverless environments.

---

# 28. DISTRIBUTED STORE

If limiters use Redis or databases:

audit state mutation atomicity.

---

# 29. READ THEN WRITE RACE

Pattern:

```text
count = GET
if count < limit
  SET count+1
```

is completely non-atomic under concurrent load.

---

# 30. ATOMIC INCREMENT

Verify limiters use atomic operations, Lua scripts, or database transactions.

---

# 31. TTL

Counter keys must enforce deterministic expiration.

---

# 32. FIRST REQUEST TTL

Classic bug:

```text
INCR key
↓
process crashes before EXPIRE
```

Keys can persist indefinitely if initialization is not atomic or self-healing.

---

# 33. FIXED WINDOW

When using:

```text
100 requests / minute
```

with a fixed window model:

boundary burst permits:

```text
100 at 12:00:59
+
100 at 12:01:00
```

delivering 200 requests in 2 seconds.

---

# 34. SLIDING WINDOW

Where smooth traffic shaping is required, evaluate sliding window logs or sliding window counters.

Do not mandate for every endpoint.

---

# 35. TOKEN BUCKET

If implemented:

map:

- bucket capacity
- refill rate
- cost per operation

---

# 36. LEAKY BUCKET

Map processing rates and queue depths according to actual algorithms.

---

# 37. ALGORITHM IS SECONDARY

Do not fault a limiter purely because it uses fixed windows.

Ask whether the behavior meets the threat and capacity model.

---

# 38. BURST

Legitimate client workflows require burst capacity.

Example:

```text
mobile app startup
↓
20 parallel requests
```

Overly rigid limiters shatter legitimate user experience.

---

# 39. PARALLEL CLIENT REQUESTS

Modern single-page and mobile apps fire multiple concurrent startup requests.

Test realistic initial dashboard hydration flows.

---

# 40. WEIGHTED LIMITS

Expensive endpoints should consume higher bucket points than cheap reads where supported.

P4 or P2 depending on operational need.

---

# 41. COST MODEL

Example:

```text
GET /profile = 1
POST /ai/generate = 20
POST /export = 50
```

Do not assign arbitrary weights without workload evidence.

---

# 42. EXTERNAL COST

Endpoints that trigger:

- SMS gateways
- outbound transactional emails
- commercial AI APIs
- geospatial/mapping APIs
- payment network verification

carry direct financial liability.

---

# 43. SMS ABUSE

Scenario:

```text
POST /send-otp
```

without adequate rate limiting creates:

- telecommunications costs (SMS pumping)
- spam campaigns
- user harassment

---

# 44. EMAIL ABUSE

Password reset, invitation, and verification endpoints can be abused as email spam cannons.

---

# 45. EMAIL EXISTENCE

Abuse limiters must not leak user registration status via divergent rate-limit errors or timing when auth models explicitly prevent enumeration.

---

# 46. LOGIN

Analyze specifically:

```text
POST /login
```

---

# 47. GLOBAL LOGIN IP LIMIT

Protects infrastructure, but can block entire corporate offices on shared NATs.

---

# 48. PER-ACCOUNT LOGIN LIMIT

Prevents focused credential brute forcing against a single account.

However, attackers can intentionally trigger limits to lock out legitimate victims.

---

# 49. LOCKOUT

Permanent or prolonged account lockouts after few attempts provide a potent Denial-of-Service vector.

---

# 50. EXPONENTIAL DELAY

Progressive backoff delays offer an alternative to blunt account lockout.

Evaluate UX and security tradeoffs.

---

# 51. CREDENTIAL STUFFING

Attack pattern:

```text
one password attempt
x
100k accounts
```

Per-account limits do not stop horizontal credential stuffing.

---

# 52. DISTRIBUTED BRUTE FORCE

Attackers distribute attempts across botnets and residential proxies.

IP-only limiting provides insufficient defense for critical authentication flows.

---

# 53. CAPTCHA

Do not mandate CAPTCHAs automatically.

They can be triggered conditionally on:

- risk score elevation
- suspicious velocity

accounting for accessibility and user friction costs.

---

# 54. MFA / OTP SEND

Separate rate limiting models must govern:

- sending codes
- verifying codes

---

# 55. OTP SEND VS OTP VERIFY

These represent fundamentally different abuse surfaces.

---

# 56. OTP GUESSING

Verification endpoints must strictly bound total guess attempts per issued OTP challenge.

---

# 57. NEW OTP RESET COUNTER

Critical bypass:

```text
wrong OTP attempts reach limit
↓
request new OTP
↓
attempt counter resets
↓
repeat endlessly
```

Verify actual implementation design.

---

# 58. PASSWORD RESET

Map:

- reset request dispatch
- token verification
- password mutation

---

# 59. RESET REQUEST SPAM

Attackers can flood targeted mailboxes with password reset notifications.

---

# 60. RESEND

`resend verification` endpoints are primary abuse targets.

---

# 61. REGISTRATION

Audit:

- IP, subnet, and device limits
- automated fake account creation
- resource allocation during onboarding

---

# 62. FREE TIER ABUSE

When new accounts receive:

- free credits
- trial periods
- cloud storage
- AI generations

per-account limits are trivially bypassed via automated account spinning.

---

# 63. DEVICE FINGERPRINT

Do not mandate intrusive client fingerprinting automatically.

Privacy and regulatory tradeoffs must be justified.

---

# 64. REFERRAL ABUSE

When referral systems pay rewards:

rate limiting alone is inadequate.

Flag the necessity of holistic fraud detection where applicable.

---

# 65. SEARCH

Complex search endpoints represent prime denial-of-service targets.

---

# 66. REGEX SEARCH

User-supplied regex or wildcards against unindexed fields create severe CPU exhaustion.

---

# 67. FILTER EXPLOSION

Complex combinations of query filters force unindexed, expensive database execution plans.

---

# 68. REPORTS

Reporting and export endpoints require dedicated strict rate limits.

---

# 69. ASYNC JOB CREATION

Even when work offloads to background queues:

unbounded enqueueing drowns the processing cluster.

---

# 70. QUEUE ABUSE

Scenario:

```text
attacker creates 1M jobs
↓
API quickly returns 202
↓
queue backlog explodes
↓
legitimate jobs delayed
```

---

# 71. JOB LIMIT

Audit:

- requests per minute
- active concurrent jobs
- pending queued jobs
- scoped per user or tenant

---

# 72. ACTIVE JOB CAP

Bounding active concurrent jobs per user is often more effective than raw HTTP request limits.

---

# 73. DUPLICATE JOB REQUEST

Deduplicate identical in-flight expensive export generation requests where semantics allow.

---

# 74. FILE UPLOAD

Abuse is not solely measured in request counts.

---

# 75. BYTE RATE

Ten 10 GB uploads are not equivalent to ten tiny JSON payloads.

---

# 76. UPLOAD SIZE

Audit:

- per-file upload caps
- total batch sizes
- concurrent upload threads
- account-level storage quotas

---

# 77. SLOW UPLOAD

Slow clients can tie up sockets and worker threads indefinitely.

Reverse proxy body timeouts and minimum transfer rate limits must be evaluated.

---

# 78. DOWNLOAD ABUSE

Large file downloads trigger:

- egress bandwidth expenses
- network interface saturation

---

# 79. SIGNED URL

Serving files directly via presigned cloud storage URLs offloads bandwidth from backend instances.

Authorization and billing boundaries must remain secure.

---

# 80. RANGE ABUSE

Flooding servers with randomized HTTP Range header requests stresses origin storage.

Report only where demonstrably relevant.

---

# 81. AI / LLM ENDPOINT

Where generative AI endpoints exist:

map:

- token generation costs
- model inference expenses
- context window memory
- concurrent generation requests
- processing timeouts

---

# 82. REQUEST COUNT IS NOT ENOUGH FOR AI

A single 100,000-token prompt costs far more than one hundred 50-token requests.

---

# 83. TOKEN QUOTA

Where commercial AI providers bill by tokens:

rate and abuse models should track token budgets.

---

# 84. CONCURRENT AI REQUESTS

Per-user concurrency caps are often more critical than requests-per-minute limits.

---

# 85. CANCELLATION

If clients disconnect mid-generation:

verify whether expensive upstream inference is aborted or continues to run and incur costs.

---

# 86. WEBHOOK ENDPOINT

Incoming webhooks must not be throttled such that valid provider retry bursts are permanently discarded.

---

# 87. WEBHOOK AUTHENTICATION BEFORE LIMIT

Question:

> Can unauthorized attackers exhaust the shared webhook rate limiter bucket?

Evaluating cryptographic signatures prior to incrementing counters prevents bucket exhaustion, but consumes CPU.

Analyze the operational tradeoff.

---

# 88. PROVIDER IP ALLOWLIST

Effective only if upstream providers publish stable, verifiable IP ranges.

Do not recommend without contract documentation.

---

# 89. ADMIN ENDPOINT

Admin portals are not immune to accidental client loops or compromised credentials.

Expensive admin bulk mutations warrant capacity guards.

---

# 90. INTERNAL SERVICE

Service-to-service communication requires:

- per-service quotas
- circuit breaking
- admission control

Never assume trusted callers never generate abusive load.

---

# 91. HEALTH ENDPOINT

Do not attach aggressive rate limiters if monitoring probes poll frequently.

---

# 92. METRICS ENDPOINT

Public exposure is a security and information disclosure defect, but rate limiting is not the primary control.

---

# 93. RATE LIMIT RESPONSE

Verify proper status codes:

```text
429 Too Many Requests
```

where appropriate.

---

# 94. RETRY-AFTER

When clients can legitimately retry:

verify presence and format of `Retry-After` headers.

---

# 95. RATE LIMIT HEADERS

Where APIs emit:

- limit
- remaining
- reset

verify numbers match actual algorithm calculations.

---

# 96. FALSE REMAINING

Race conditions can report `remaining=5` right before immediately rejecting the next request.

Minor race conditions may be acceptable, but contracts should remain coherent.

---

# 97. CLOCK

Limiters relying on multi-node system clocks suffer anomalies when clocks drift.

Critical for custom distributed window implementations.

---

# 98. REDIS TIME

Using centralized Redis `TIME` stabilizes distributed clock evaluations.

Do not mandate without necessity.

---

# 99. FAIL-OPEN VS FAIL-CLOSED

The most critical decision when the limiter backing store fails.

---

# 100. REDIS DOWN

What happens when Redis drops?

```text
allow all
```

or:

```text
reject all
```

---

# 101. FAIL-OPEN

Appropriate for low-risk endpoints to ensure limiter outages do not take down the entire application.

---

# 102. FAIL-CLOSED

Essential for:

- expensive paid external APIs
- OTP verification flows
- sensitive security actions

Even though it risks total endpoint downtime.

---

# 103. HYBRID FALLBACK

Falling back to a local in-memory emergency limiter provides partial protection.

Evaluate complexity tradeoffs.

---

# 104. LIMITER LATENCY

Querying remote limiter stores on every request adds network round-trip latency.

Measure overhead on critical hot paths.

---

# 105. LIMITER STORE BOTTLENECK

The rate limiter database or Redis cluster can itself become the primary scaling bottleneck.

---

# 106. ONE KEY HOTSPOT

A single global counter key tracking all incoming traffic creates severe Redis core contention.

---

# 107. HIGH CARDINALITY KEYS

Tracking millions of distinct keys expands memory footprints rapidly.

---

# 108. KEY CLEANUP

Verify TTL expiration is set on every allocated limiter key.

---

# 109. MEMORY DOS

Attackers can intentionally generate boundless keys:

```text
random username
random path
random token
```

If each allocates a limiter entry:

the state store risks memory exhaustion.

---

# 110. UNTRUSTED KEY MATERIAL

Never inject arbitrary, unbounded user-supplied strings directly into Redis keys without sanitization and length bounds.

---

# 111. KEY COLLISION

Composite keys must avoid delimiter collision and ambiguity.

Example:

```text
user + ":" + route
```

is generally sound if delimiter characters are strictly escaped or separated.

---

# 112. NORMALIZATION

Email and username keys can be bypassed via variations in:

- casing
- whitespace
- Unicode normalization

if the application treats them as identical identities.

---

# 113. PATH NORMALIZATION

Path-based limiters can be bypassed via URL variations (trailing slashes, URL encoding) if routing resolves them to the same handler.

---

# 114. QUERY STRING

If limiter keys include raw query strings:

attackers can append random irrelevant query parameters to generate fresh buckets on every call.

---

# 115. ROUTE TEMPLATE

Prefer limiting by normalized logical route patterns:

```text
/users/:id
```

rather than raw concrete URLs, depending on policy design.

---

# 116. RESOURCE-SCOPED LIMIT

Certain flows specifically require the resource ID in the key (e.g., OTP challenges).

---

# 117. HTTP METHOD

`GET` and `POST` on the same path often carry radically different cost and risk profiles.

---

# 118. STATUS-BASED COUNTING

Determine whether failed requests count against the limiter quota.

---

# 119. LOGIN FAILURE COUNT

For brute-force protection, failed attempts are the primary signal to track.

---

# 120. VALIDATION SPAM

Malformed requests still consume CPU and parsing resources.

Limiting before executing complex validation protects capacity.

---

# 121. SUCCESS-ONLY LIMIT

Dangerous for abuse protection: attackers can craft requests that perform heavy work and fail deliberately at the end without exhausting buckets.

---

# 122. COST OCCURS BEFORE FAILURE

Map where rate limit validation executes relative to:

- body parsing
- authentication
- database queries
- downstream API invocations

---

# 123. LIMITER TOO LATE

Scenario:

```text
parse huge body
↓
DB query
↓
expensive provider call
↓
rate limit check
```

The limiter is virtually useless for capacity protection.

---

# 124. LIMITER TOO EARLY

Checking before authentication groups all users behind a shared NAT into a single shared bucket.

Deliberate policy balancing is required.

---

# 125. MULTI-STAGE LIMITING

Tiered architecture:

```text
cheap IP edge limit
↓
auth
↓
user-specific application limit
```

Do not introduce without clear multi-tier requirements.

---

# 126. ERROR CODE BYPASS

Attackers can alter inputs to divert requests into unthrottled error pathways.

---

# 127. ALIAS ENDPOINT

If multiple aliases expose the same handler:

```text
/login
/auth/login
/v1/login
```

verify that protections cover all entry routes.

---

# 128. OLD API VERSION

Legacy API endpoints frequently lack modern rate limiters.

---

# 129. GRAPHQL

A single HTTP POST endpoint renders simple request-count limiting ineffective.

---

# 130. GRAPHQL COMPLEXITY

For GraphQL APIs audit:

- query depth calculation
- field complexity weights
- field cost limits
- query aliases
- batched queries

---

# 131. ONE GRAPHQL REQUEST

A single HTTP call can execute hundreds of expensive nested resolver functions.

---

# 132. ALIAS ABUSE

Repeatedly querying the same expensive field via GraphQL aliases.

---

# 133. BATCHED GRAPHQL

Sending arrays of operations in a single HTTP payload.

---

# 134. REST BULK

A single REST request containing 10,000 array items bypasses naive request-count limiters.

---

# 135. BULK ITEM LIMIT

Verify strict upper limits on array payload items.

---

# 136. WEBSOCKET

Where WebSockets are used:

HTTP handshake limiting alone is insufficient.

---

# 137. CONNECTION LIMIT

Audit per-user and per-IP:

- concurrent active sockets
- reconnection velocities

---

# 138. MESSAGE RATE

Connected clients can flood servers with inbound messages if message-level throttles are absent.

---

# 139. SUBSCRIPTION LIMIT

A single socket subscribing to thousands of real-time topics exhausts memory.

---

# 140. SSE

Long-lived Server-Sent Events hold connection pool capacity.

Audit concurrency limits.

---

# 141. RECONNECT STORM

Server restarts trigger thousands of concurrent client reconnection attempts.

---

# 142. CLIENT BACKOFF

Verify client libraries implement randomized exponential backoff on disconnect.

---

# 143. CACHE ABUSE

Attackers intentionally craft unique requests to force origin cache misses.

---

# 144. CACHE BUSTER

Adding random query parameters to bypass CDN caching and hit origin databases.

---

# 145. CDN CONFIG

If CDNs include arbitrary query parameters in cache keys, the origin abuse surface expands.

---

# 146. EXPENSIVE CACHE MISS

Pay special attention to publicly accessible endpoints with costly cache misses.

---

# 147. DB CONNECTION ABUSE

Flooding slow, unindexed queries can saturate connection pools before CPU reaches full capacity.

---

# 148. SLOWLORIS-LIKE APPLICATION EFFECT

Audit HTTP server request header and body read timeouts when services face the public internet directly.

---

# 149. SERVER TIMEOUTS

Bound the duration slow or stalled requests can tie up server resources.

---

# 150. REQUEST BODY LIMIT

The first barrier against payload-based denial of service.

---

# 151. HEADER SIZE

Enforce maximum limits on incoming header dimensions at proxy and gateway boundaries.

---

# 152. PARSER ABUSE

Deeply nested JSON structures can trigger stack overflows or CPU exhaustion in certain parsers.

---

# 153. ARRAY SIZE

Validate:

```text
items: max N
```

where domain rules apply.

---

# 154. STRING SIZE

Set strict upper bounds on search terms, filter strings, and freeform text fields.

---

# 155. REGEX DOS

Where user-supplied strings are evaluated against risky regular expressions:

address both code-level regex patterns and input length limits.

---

# 156. DATABASE ABUSE

Arbitrary combinations of unindexed filters and sorts force expensive sequential scans.

---

# 157. SORT WHITELIST

Enforce strict whitelisting for sortable columns.

---

# 158. DATE RANGE

Reporting queries spanning:

```text
from=1900
to=2100
```

can scan enormous historical tables.

---

# 159. MAX RANGE

Enforce bounded date range maximums.

---

# 160. EXPORT FREQUENCY

Large data exports require:

- per-user frequency limits
- concurrent export caps

---

# 161. ASYNC DOES NOT ELIMINATE ABUSE

Pushing work to queues merely relocates the resource bottleneck.

---

# 162. EMAIL VERIFICATION

Protect verification flows with distinct limits for:

- code resend requests
- verification attempt submissions

---

# 163. INVITE SPAM

Users with invitation privileges can dispatch thousands of unsolicited emails.

---

# 164. COMMENT / MESSAGE SPAM

For user-generated content:

rate limiting forms only one component of a wider anti-spam posture.

---

# 165. DELETE ABUSE

High-frequency deletions trigger heavy cascading operations, audit logging, and storage cleanup.

---

# 166. CREATE/DELETE LOOP

Rapidly creating and destroying resources exhausts sequence numbers, logs, and worker queues.

---

# 167. EXPENSIVE FAILURE PATH

Attackers deliberately supply inputs that execute the most expensive code paths before failing validation at the very end.

---

# 168. AUTHORIZED ABUSE

Legitimate paying users can still overwhelm system capacity.

Authorization does not replace abuse protection.

---

# 169. PREMIUM USER

Higher quotas do not equal infinite capacity.

---

# 170. ADMIN

The same principle applies to administrative accounts.

---

# 171. INTERNAL BUG LOOP

Rate limiters protect infrastructure from self-inflicted damage caused by client-side retry bugs.

---

# 172. MOBILE RETRY LOOP

Scenario:

```text
API returns error
↓
client retries instantly forever
```

Backend limiters absorb the load, but the client defect must be diagnosed.

---

# 173. WEB POLLING

Web frontends polling at 100 ms intervals generate abuse-like traffic volume.

---

# 174. RETRY-AFTER CLIENT COMPLIANCE

When returning 429s:

verify that first-party client applications respect backoff headers.

---

# 175. 429 RETRY STORM

If thousands of throttled clients retry at the exact same second of bucket reset:

a synchronized traffic spike ensues.

---

# 176. JITTER ON CLIENT

Clients should introduce randomized backoff jitter.

---

# 177. RATE LIMIT MONITORING

Track at minimum:

- allowed requests
- rejected requests
- key category
- route
- tenant/user tier

---

# 178. DO NOT LOG RAW KEY

Rate limit keys often embed sensitive data:

- email addresses
- client IPs
- API keys

Mask or hash keys in logs.

---

# 179. TOP THROTTLED ROUTES

Provides essential operational visibility.

---

# 180. FALSE POSITIVE RATE

If legitimate users routinely encounter 429 errors:

thresholds and burst tolerances are misconfigured.

---

# 181. BYPASS DETECTION

If request volume surges while the limiter rarely rejects calls:

the key is likely trivial to rotate or evade.

---

# 182. DISTRIBUTION

Monitor the count of unique active limiter keys.

Sudden explosions indicate distributed attacks or key space attacks.

---

# 183. LIMITER STORE METRICS

For Redis:

- latency
- errors
- memory consumption
- key eviction rates

---

# 184. EVICTION

If limiter keys are evicted under memory pressure:

attackers automatically regain fresh rate budgets.

---

# 185. SHARED REDIS

If application caches and rate limiters share the same Redis instance:

cache memory spikes compromise abuse defenses.

---

# 186. DB-BASED LIMITER

Executing database transactions on every HTTP request to update rate counters creates a self-inflicted performance bottleneck under load.

---

# 187. WRITE AMPLIFICATION

Updating database rows on every inbound call severely degrades throughput.

---

# 188. EDGE LIMITER

WAF and CDN edge limiters absorb volumetric floods before hitting origin infrastructure.

Application-level identity and quota controls remain necessary.

---

# 189. WAF IS NOT A BUSINESS LIMITER

WAFs lack tenant, business rule, and user-tier context.

---

# 190. APPLICATION LIMITER IS NOT DDOS MITIGATION

If a 10 Gbps flood reaches application servers, application code will be overwhelmed before executing limiter logic.

Keep scopes distinct.

---

# 191. UPSTREAM INFRA LIMITS

Document existing:

- connection limits
- edge rate policies
- serverless concurrency caps

---

# 192. CONCURRENCY CAP

Serverless reserved concurrency limits protect downstream databases, but can trigger unexpected client rejections.

---

# 193. LOAD SHEDDING

When backends are critically overloaded:

shedding load via controlled 503 or 429 responses is preferable to catastrophic timeout cascades.

---

# 194. 429 VS 503

429 indicates client quota or velocity violations.

503 indicates server capacity exhaustion.

Do not conflate semantics arbitrarily.

---

# 195. RETRY SIGNAL

Client behavior diverges based on status code semantics.

---

# 196. PRIORITY

Critical internal requests should draw from dedicated capacity reserves distinct from low-priority background reporting.

---

# 197. FAIRNESS

A single user should not consume all available worker slots in multi-user systems.

---

# 198. PER-USER CONCURRENCY

For resource-heavy tasks, bounding concurrent operations per user is often more vital than rate-per-minute limits.

---

# 199. SEMAPHORE

Local process semaphores do not enforce per-user concurrency across multi-instance clusters.

---

# 200. DISTRIBUTED CONCURRENCY

Where required, implement distributed coordination or partitioned queue concurrency.

Avoid jumping straight to heavy distributed locks.

---

# 201. RACE IN LIMITER

Load test exact boundary conditions:

```text
limit = 10
20 simultaneous requests
```

Determine how many calls actually slip through.

---

# 202. OFF-BY-ONE

Frequent bug:

```text
if count > limit
```

versus:

```text
if count >= limit
```

Verify exact algorithm semantics.

---

# 203. RESET

At window expiration verify:

- exact transition timing
- old key cleanup
- new key initialization
- response header alignment

---

# 204. TIMEZONE

Rate limiter windows must rely on stable server UTC time.

Never tie limiter windows to user timezones unless enforcing calendar billing quotas.

---

# 205. DISTRIBUTED CLOCK SKEW

Custom multi-node window algorithms are susceptible to server clock drift.

---

# 206. TESTS

Audit:

- unit tests for limiter logic
- integration tests
- concurrency tests
- multi-instance tests
- proxy/IP header tests
- load tests

---

# 207. HAPPY PATH IS NOT ENOUGH

Sending:

```text
1 request
```

proves nothing about limiter efficacy.

---

# 208. BOUNDARY TEST

Test:

```text
limit - 1
limit
limit + 1
```

---

# 209. CONCURRENT BOUNDARY TEST

Send all requests simultaneously to verify race resilience.

---

# 210. WINDOW BOUNDARY TEST

Fire bursts immediately before and after window reset thresholds.

---

# 211. MULTI-INSTANCE TEST

Distribute requests across multiple backend replicas to verify shared bucket enforcement.

---

# 212. PROCESS RESTART

Verify whether in-memory state loss on restart creates an exploitable bypass.

---

# 213. REDIS OUTAGE TEST

Test fail-open and fail-closed behaviors under simulated Redis unavailability.

---

# 214. SPOOFED IP TEST

Send forged forwarding headers through the real proxy path to verify trust boundary enforcement.

---

# 215. NAT TEST

Simulate multiple authenticated users originating from the same public IP.

---

# 216. MULTI-IP TEST

Simulate a single account operating across multiple IP addresses.

---

# 217. QUERY VARIATION TEST

Append arbitrary query parameters to verify key stability.

---

# 218. ROUTE PARAM TEST

```text
/users/1
/users/2
/users/3
```

Verify whether route-level limits can be evaded by mutating resource identifiers.

---

# 219. LOGIN ATTACK TEST

Simulate in test environments:

- same account, many IPs
- many accounts, same IP
- many accounts, many IPs

---

# 220. OTP TEST

Test:

- sending floods
- code guessing attempts
- resend counter reset bypasses

---

# 221. EXPENSIVE ENDPOINT LOAD TEST

Verify rate limiters trigger before downstream databases or services saturate.

---

# 222. QUEUE ADMISSION TEST

Attempt rapid bulk job creation to verify queue admission throttling.

---

# 223. FILE TEST

Send requests containing maximum permissible payload bodies.

---

# 224. COST TEST

Where endpoints trigger paid external APIs:

calculate worst-case permitted expenditure per user, hour, and day using known pricing models.

---

# 225. FINDING FORMAT

Every serious finding must include:

```text
ID:
Severity:
Category:
Confidence:
Status:

Endpoint/Operation:
Limiter layer:
Current policy:
Limiter key:
Algorithm:
Store:
Deployment topology:

Problem:

Evidence:

Abuse Timeline:

T0:
T1:
T2:
T3:

Expected limit:

Effective limit:

Bypass method:

Affected scope:

Infrastructure impact:

Financial impact:

Security impact:

Legitimate-user impact:

Fail-open/fail-closed behavior:

Root cause:

Recommended remediation:

Regression/load test:

Production verification:

Complexity:
XS / S / M / L / XL
```

If a value cannot be verified:

**NOT VERIFIED**

---

# 226. SEVERITY

Use:

## P0 - CRITICAL

Reserved for abuse/rate-limit flaws enabling:

- catastrophic financial drain
- critical authentication or security compromise
- complete systemic outages via minimal attacker effort
- critical cross-tenant resource starvation with severe consequences

## P1 - HIGH

- critical authentication endpoints have effectively zero abuse protection
- rate limiters can be trivially bypassed
- expensive endpoints can easily exhaust production capacity or paid provider budgets
- multi-instance flaws multiply stated limits by orders of magnitude
- queue, file, or job abuse triggers severe outages or runaway costs

## P2 - MEDIUM

- significant limiter weaknesses
- multi-tenant fairness violations
- rate policies that do not match actual endpoint costs
- substantial false-positive risks or non-trivial bypasses

## P3 - LOW

- limited edge-case abuse risks
- minor header or reset timing inconsistencies

## P4 - IMPROVEMENT

- observability enhancements, tuning suggestions, or fairness refinements without active abuse risk

---

# 227. CONFIDENCE

Use:

```text
HIGH
MEDIUM
LOW
```

HIGH:

code/config inspection and concurrency or load tests directly demonstrate the behavior.

MEDIUM:

strong code-level evidence, but production proxy or network topology is not fully verified.

LOW:

depends on unverified CDN, WAF, or third-party provider behavior.

---

# 228. STATUS

Use:

```text
CONFIRMED
LIKELY
THEORETICAL
NOT VERIFIED
```

---

# 229. ABUSE CATEGORY

Classify each finding as:

```text
BRUTE FORCE
CREDENTIAL STUFFING
SPAM
ENUMERATION
CAPACITY EXHAUSTION
QUEUE FLOOD
FILE/BANDWIDTH
EXTERNAL-COST
FAIRNESS
LIMITER BYPASS
DISTRIBUTED CORRECTNESS
```

---

# 230. PROTECTION LAYER

Indicate:

```text
EDGE
GATEWAY
APPLICATION
BUSINESS QUOTA
QUEUE
PROVIDER
MULTI-LAYER
```

---

# 231. FALSE-POSITIVE PREVENTION

Before any P0/P1/P2 finding verify:

1. proxy and CDN configurations
2. route middleware chains
3. limiter key construction logic
4. store atomicity
5. production instance counts
6. actual endpoint computational costs
7. business quotas
8. official client behavior
9. test suite coverage
10. monitoring telemetry

Do not assume a limiter is absent simply because it is not declared directly in the controller handler.

---

# 232. DO NOT RECOMMEND THE SAME LIMIT TO ALL

Different endpoints, user tiers, tenants, and workloads require distinct rate limits.

---

# 233. DO NOT RECOMMEND IP-ONLY AUTOMATICALLY

Shared NATs and botnets diminish the effectiveness of pure IP-based limiting.

---

# 234. DO NOT RECOMMEND ACCOUNT LOCKOUT AUTOMATICALLY

Blunt account lockouts create trivial Denial-of-Service vectors against legitimate users.

---

# 235. DO NOT RECOMMEND CAPTCHA EVERYWHERE

CAPTCHAs impose severe user experience, accessibility, and privacy costs.

---

# 236. DO NOT RECOMMEND REDIS UNNECESSARILY

For single-instance internal tools, in-memory rate limiting is entirely sufficient.

---

# 237. DO NOT RECOMMEND WAF AS THE ONLY SOLUTION

WAFs cannot enforce user, tenant, or business-aware quotas.

---

# 238. DO NOT INCREASE LIMITS TO "FIX" FALSE POSITIVES

Understand legitimate burst traffic patterns first.

A different algorithm or key structure is often required rather than an arbitrary limit increase.

---

# 239. DO NOT REDUCE LIMITS WITHOUT A CAPACITY MODEL

Aggressive throttling is not inherently safer; it frequently harms legitimate users.

---

# 240. DO NOT MODIFY CODE

During audit:

- do not add rate limiters
- do not change thresholds
- do not introduce Redis
- do not alter login lockout policies
- do not add CAPTCHAs
- do not reconfigure proxies

Complete the audit first.

---

# 241. OUTPUT - RATE_LIMITING_ABUSE_PROTECTION_AUDIT.md

Structure the final report:

## 1. Executive Summary

- protection layers
- limiter architecture
- critical abuse surfaces
- primary bypass vectors
- capacity protection readiness

## 2. Infrastructure / Edge Protection Map

## 3. Application Limiter Architecture

## 4. Endpoint Abuse Inventory

## 5. Limiter Identity / Key Audit

## 6. Proxy / Client IP Audit

## 7. Multi-Instance / Distributed Correctness

## 8. Algorithm / Window Audit

## 9. Login / Credential Abuse Audit

## 10. OTP / Password Reset Audit

## 11. Registration / Trial Abuse Audit

## 12. Email / SMS Abuse Audit

## 13. Expensive API Audit

## 14. External-Cost API Audit

## 15. File / Bandwidth Abuse Audit

## 16. Search / Report / Export Audit

## 17. Queue / Background Job Admission Audit

## 18. WebSocket / SSE Audit

If relevant.

## 19. GraphQL / Bulk Cost Audit

If relevant.

## 20. Fail-Open / Fail-Closed Audit

## 21. Limiter Store Performance / Reliability

## 22. Fairness / Multi-Tenant Audit

## 23. Response Contract / Retry Guidance

## 24. Monitoring / Abuse Visibility

## 25. Test Coverage

## 26. Findings Summary

| ID | Severity | Endpoint | Abuse type | Bypass/Problem | Confidence | Status |
|---|---|---|---|---|---|---|

## 27. P0 Findings

## 28. P1 Findings

## 29. P2 Findings

## 30. P3 Findings

## 31. P4 Improvements

## 32. Things Done Well

## 33. Unknown / Not Verified

## 34. Protection Remediation Roadmap

---

# 242. ENDPOINT LIMIT MATRIX

| Endpoint | Identity | Limit | Window | Cost | Distributed |
|---|---|---:|---|---|---|

---

# 243. AUTH ABUSE MATRIX

| Flow | Per-IP | Per-account | Global | Lockout | Bypass risk |
|---|---|---|---|---|---|

---

# 244. DISTRIBUTED MATRIX

| Limiter | Store | Atomic | Shared across replicas | Restart-safe | Risk |
|---|---|---|---|---|---|

---

# 245. COST MATRIX

| Operation | Backend cost | External cost | Concurrency cap | Abuse protection |
|---|---|---|---|---|

---

# 246. FAILOVER MATRIX

| Limiter dependency failure | Current behavior | Fail-open | Fail-closed | Business risk |
|---|---|---|---|---|

---

# 247. SECOND PASS - LIMIT BYPASS ATTACK

For each rate limit key ask:

> What component can an attacker easily manipulate?

Examples:

- IP headers
- query parameters
- path identifiers
- user accounts
- session cookies
- API keys

---

# 248. SECOND PASS - MULTI-INSTANCE ATTACK

Assume 10 backend replicas.

Distribute requests evenly across instances.

Calculate the effective operational limit.

---

# 249. SECOND PASS - WINDOW EDGE

Calculate maximum burst volumes immediately spanning window reset boundaries.

---

# 250. SECOND PASS - NAT ATTACK

Simulate 100 legitimate users behind a single public IP.

Identify who gets throttled.

---

# 251. SECOND PASS - DISTRIBUTED ATTACK

Simulate one account operating across 100 IP addresses.

Verify whether account-level limits hold.

---

# 252. SECOND PASS - ACCOUNT ROTATION

One IP address generating numerous fresh accounts.

Evaluate impact on:

- free trials
- promotional credits
- free tier usage
- referral systems

---

# 253. SECOND PASS - UNIQUE KEY FLOOD

Dispatch high volumes of requests with randomized limiter identity values.

Measure state store memory growth.

---

# 254. SECOND PASS - REDIS OUTAGE

Simulate rate limiter store downtime in test environments.

Establish:

> Which endpoints fail-open, and which fail-closed?

---

# 255. SECOND PASS - EXPENSIVE FAILURE PATH

Craft requests that consume maximum server compute, but fail validation at the final step.

Verify whether limiters or admission controls protect resources prior to execution.

---

# 256. SECOND PASS - QUEUE FLOOD

Enqueue heavy background jobs in bulk.

Monitor:

- API response times
- queue backlog depth
- oldest message age
- legitimate job latency

---

# 257. SECOND PASS - LOGIN MATRIX

Test:

```text
same account + same IP
same account + many IPs
many accounts + same IP
many accounts + many IPs
```

---

# 258. SECOND PASS - OTP

Test:

```text
send
verify
resend
new challenge
```

Search for attempt counter reset bypasses.

---

# 259. SECOND PASS - 429 CLIENT LOOP

Simulate client receipt of a 429 response.

Verify:

- immediate retry loops
- compliance with `Retry-After`
- backoff jitter application

---

# 260. SECOND PASS - PEAK LOAD

Ensure limiters throttle traffic before triggering:

- database connection pool exhaustion
- queue worker collapse
- external budget overruns

Compare thresholds against real capacity signals.

---

# 261. SECOND PASS - LEGITIMATE BURST

Simulate realistic application startup and dashboard loading flows.

Verify legitimate users are not throttled during standard parallel queries.

---

# 262. SECOND PASS - LARGE TENANT

Large corporate tenants generate heavy legitimate traffic that resembles abuse.

Verify whether policies accommodate higher product tiers.

---

# 263. SECOND PASS - COST AMPLIFICATION

A single incoming HTTP request can trigger:

```text
1 API request
↓
50 DB queries
↓
10 external API calls
↓
100 queued jobs
```

Request-count limits must be evaluated against actual downstream amplification.

---

# 264. FINAL QUALITY GATE

Before final response verify:

- infrastructure and application-level protections are not confused
- business quotas are decoupled from abuse limits
- critical endpoints are prioritized by actual cost and risk
- IP identity is analyzed across proxies, NATs, and IPv6
- `X-Forwarded-For` is not blindly trusted
- effective multi-instance limits are calculated where possible
- distributed counter increments are verified atomic
- fixed-window bursts are analyzed only where relevant
- authentication flows are evaluated against both focused and distributed brute force
- account lockouts are not recommended without DoS risk analysis
- OTP sending and verification use separate threat models
- resend actions do not reset verification attempt counters
- expensive endpoints feature admission control analysis
- asynchronous jobs are not treated as cost-free simply because they run in background queues
- file upload abuse incorporates byte volume and concurrency
- AI and paid external integrations evaluate unit pricing
- limiter checks execute before expensive operations commence
- fail-open and fail-closed behaviors are explicitly evaluated
- the limiter store does not create a memory DoS vulnerability or scaling bottleneck
- first-party clients handle 429 responses properly where verifiable
- legitimate burst and fairness scenarios are tested
- WAFs and CDNs are not presented as replacements for business-aware limiters
- P4 tuning suggestions are segregated from verified bypasses

---

# FINAL RULE

I do not want a report like:

> Add a Redis rate limiter, 100 requests per minute, and CAPTCHA on login.

That is not an abuse protection audit.

I am looking for problems like:

```text
backend behind reverse proxy
↓
rate limiter key = X-Forwarded-For
↓
proxy trust configuration accepts client header directly
↓
attacker sends a different fake IP each request
↓
every request gets a fresh bucket
↓
rate limit is effectively bypassed
```

or:

```text
limit = 100/min per process
↓
10 backend replicas
↓
load balancer distributes traffic
↓
attacker receives approximately 100 requests of budget on each replica
↓
documented 100/min protection is not globally enforced
```

or:

```text
POST /send-otp
↓
5 attempts allowed
↓
attacker reaches limit
↓
requests new OTP
↓
verification-attempt counter resets
↓
cycle repeats
↓
OTP guessing protection is bypassed
```

or:

```text
POST /reports/generate
↓
returns 202 quickly
↓
each request creates expensive queue job
↓
no per-user active/queued job cap
↓
attacker creates 100,000 jobs
↓
legitimate reports wait for hours
```

or:

```text
limiter checks rate only after:
body parsing
database queries
external AI request
↓
attacker exceeds limit
↓
429 returned
↓
but expensive work has already happened
```

or:

```text
rate limit key includes raw query string
↓
?search=x&a=1
?search=x&a=2
?search=x&a=3
↓
each variation creates a new bucket
↓
logical endpoint limit is bypassed
```

or:

```text
100 legitimate mobile users behind carrier NAT
↓
one shared public IP
↓
one user generates heavy traffic
↓
entire IP bucket is exhausted
↓
99 unrelated users receive 429
```

or:

```text
Redis limiter unavailable
↓
middleware catches Redis error
↓
allows every request
↓
expensive paid external API endpoint becomes unlimited
↓
provider cost spikes during limiter outage
```

These are the rate limiting and abuse protection problems you need to find.

Think through:

- attacker-controlled identity
- distributed deployment
- endpoint cost
- burst
- concurrency
- queue admission
- paid external resources
- fail-open/fail-closed
- fairness
- legitimate traffic patterns

For each serious finding you must be able to answer:

> Which endpoint is being abused?

> Which limiter is supposed to protect it?

> What exact key and policy are used?

> How can the key be rotated or evaded?

> Does the limit hold across all backend instances?

> What is the effective limit in the production topology?

> What does the attacker gain, and what does the system consume?

> What happens if the limiter infrastructure fails?

If protection cannot be verified:

**NOT VERIFIED.**

If production proxy or topology is unknown:

**PRODUCTION TOPOLOGY NOT VERIFIED.**

If merely a tuning suggestion without confirmed defect:

**P4 - IMPROVEMENT.**

It is better to find 6 real bypass, capacity, or fairness flaws than to write 100 generic limiter rules.

The goal is to produce a forensically precise abuse protection audit that can be directly converted into:

- limiter regression tests
- concurrency tests
- multi-instance tests
- proxy and IP hardening
- endpoint-specific policies
- queue admission controls
- financial cost protections
- production monitoring alerts

分类与标签

编程开发、API安全、后端限流、滥用防护、容量审计

前往 AI 图片创作