Add IP-based rate limiting on failed login attempts#598
Open
flightlesstux wants to merge 1 commit intopassbolt:masterfrom
Open
Add IP-based rate limiting on failed login attempts#598flightlesstux wants to merge 1 commit intopassbolt:masterfrom
flightlesstux wants to merge 1 commit intopassbolt:masterfrom
Conversation
The /auth/login endpoint had no throttling mechanism. An attacker could issue unlimited authentication requests against any account with no server-side consequence, enabling brute-force enumeration of fingerprints and replay attacks. Implementation: - Track failed attempts per client IP in CakePHP's default cache - Cache key: sha1(clientIp) prefixed with 'auth_fail_' to prevent key injection and normalise IPv6 addresses - Window: 300 seconds (5 minutes) sliding per-IP counter - Threshold: 10 failures before a 429 is returned - Successful authentication clears the counter for that IP Only FAILURE_IDENTITY_NOT_FOUND and FAILURE_CREDENTIALS_INVALID increment the counter. FAILURE_CREDENTIALS_MISSING (the first GPG handshake stage) does not, as it is a normal part of the two-step protocol and not an authentication failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
/auth/loginendpoint had no throttling mechanism. An attacker could issue unlimited POST requests against the GPG authentication endpoint with no server-side consequence, enabling:FAILURE_IDENTITY_NOT_FOUNDreveals existence)Implementation
Uses CakePHP's built-in
Cacheto track failed attempts per client IP with a sliding window:Flow:
POST /auth/login, read the attempt counter for the client IP from cache>= 10, return HTTP 429 immediately before any auth processingFAILURE_IDENTITY_NOT_FOUNDorFAILURE_CREDENTIALS_INVALID, increment the counter (TTL = 300s)Cache key:
auth_fail_+sha1(clientIp)— normalises IPv6 addresses and prevents cache key injection via crafted IP strings.What does NOT increment the counter
FAILURE_CREDENTIALS_MISSING(HTTP 200) is the first stage of the GPG two-step handshake and is a normal protocol step, not a failed authentication. It is intentionally excluded from the counter.Impact