Aller au contenu
uencoder

Implement rate limiting en prevent brute-force attacks

Rate limiting caps le nombre de requests per time window, preventing brute-force, credential stuffing, et DoS attacks. Apprendre jeton bucket et sliding window algorithmes.

  1. 1

    Rate limiting restricts how many requests a client can make in a time window. Common algorithms: (1) Fixed window — simple but allows bursts at window boundaries; (2) Sliding window — smoother, tracks requests in a rolling window; (3) Token bucket — allows bursts up to a capacity, refills at a steady rate.

  2. 2
    Calculatrice de hash →

    Hash the client identifier (IP, user ID, API key) to use as a rate limit key. Use SHA-256 to avoid storing raw IPs. The hash maps to a counter in a fast store (Redis, in-memory map).

  3. 3
    Générateur HMAC →

    Sign the rate limit state (count, window start) with an HMAC to prevent tampering. If using client-side rate limiting (e.g., JWT-based), the signed token prevents the client from resetting their own counter.

  4. 4

    For brute-force protection on login: limit to 5 attempts per 15 minutes per account, and 10 per IP. Use exponential backoff — each failed attempt increases the wait time. After 5 failures, lock the account and require email verification. For API rate limiting: 100 requests/minute for free tier, 1000 for paid. Return 429 Too Many Requests with a Retry-After header.

Questions fréquentes

Token bucket vs sliding window?
Token bucket allows controlled bursts (up to bucket capacity) then steady-state rate — good for APIs where occasional bursts are acceptable. Sliding window enforces a strict limit in any window — better for security-critical endpoints like login. Choose based on whether bursts are acceptable.
How do I handle distributed rate limiting?
Use a shared store (Redis, Memcached) so all servers see the same counters. For high throughput, use a sliding window with Lua scripting in Redis (atomic check-and-increment). For global rate limiting at the edge, use CDN features (Cloudflare, AWS WAF).

Workflows résolvant cette tâche

Hacher le contenu et coder en Base64
Calculer un hachage de l'entrée et coder le condensat en Base64 pour un transport compact.
PIPELINE
Hacher le texte et vérifier l'intégrité
Calculer un hachage du texte d'entrée et le comparer à un hachage attendu pour vérifier l'intégrité.
PIPELINE
Hacher le texte et vérifier avec somme CRC32
Calculer à la fois un hachage cryptographique SHA-256 et une somme de contrôle CRC32 pour la vérification d'intégrité des données.
PIPELINE
Signer HMAC puis coder en Base64
Générer une signature HMAC puis coder en Base64 pour les en-têtes d'authentification API.
PIPELINE
Signer HMAC et vérifier
Générer une signature HMAC pour un message et la vérifier contre une signature attendue.
PIPELINE
Signer HMAC une chaîne de requête API
Générer une signature HMAC-SHA256 pour une charge utile de requête pour authentifier les appels API.
PIPELINE
Hacher MD5 puis coder en Base58
Calculer le hash MD5 puis coder en Base58 pour une représentation compacte.
PIPELINE
Comparaison de vitesse multi-hash
Hacher l'entrée et benchmarker plusieurs algorithmes de hachage pour comparer leur vitesse et sortie.
PIPELINE
Générer un mot de passe et hacher
Générer un mot de passe aléatoire puis le hacher pour un stockage sécurisé.
PIPELINE
Hash SHA3-256 avec somme CRC32
Calculer le hash SHA3-256 puis la somme CRC32 pour une double vérification d'intégrité.
PIPELINE
Hacher SHA-512 puis Hex
Calculer le hash SHA-512 puis coder en Hex pour lisibilité.
PIPELINE
Inverser le texte et hacher
Inverser le texte puis calculer le hachage SHA-256 du résultat inversé.
PIPELINE
Brouiller le texte et hacher
Brouiller le texte puis hacher le résultat brouillé.
PIPELINE

Outils associés