CWE-307: No Brute-Force Protection
An authentication endpoint accepts unlimited attempts, so an attacker can guess passwords or codes by trying as many as they like.
Also known as: Missing rate limiting, No brute-force protection, Unlimited login attempts
Risk
Typically high. With no limit on attempts, weak passwords and short one-time codes fall to automated guessing, and credential-stuffing lists can be replayed at full speed against the login.
Definition
What it is
CWE-307 is the failure to restrict how many times a client can try to authenticate. Without a cap, an attacker can run password guessing, credential stuffing, or one-time-code brute forcing against the endpoint at machine speed. A six-digit reset code has only a million values, which is trivial to exhaust when nothing slows the attempts. The protection must sit server-side, because client-side counters are simply bypassed by calling the API directly.
Use-cases
How it shows up in real code
Password spraying the login
An attacker tries one common password across thousands of known usernames. With no rate limit, the run completes in minutes and lands on every account that reused that password.
Brute-forcing a reset code
A password reset emails a six-digit code with no attempt cap. A script tries all million combinations and takes over the account before the code expires.
Credential stuffing
A breached username and password list is replayed against the login at full speed. Nothing throttles the attempts, so every reused credential succeeds.
OTP bypass at the API
A one-time code is validated only through the UI, which limits retries. The attacker calls the verification API directly, where no server-side limit exists, and guesses freely.
AI risk
Why AI-generated code has increased the exposure
- Assistants optimize for a login that authenticates correctly, and a working login does not need a counter, so rate limiting is simply absent from the generated handler.
- Rate limiting usually lives in middleware or infrastructure the model cannot see, so it assumes something upstream handles it and emits none itself.
- Training examples show the happy-path credential check without the attempt-tracking state, so the model reproduces an unprotected verifier.
- When scaffolding login, reset, and OTP verification, the assistant builds each verification step without the shared throttle that should guard all of them.
- Generated code validating a numeric code rarely bounds retries, leaving a small keyspace open to exhaustive guessing at scale.
Vibe coding
How vibe coding amplifies the risk
- Vibe coding ships an auth endpoint that works on the first correct try, and nobody notices there is no limit on the wrong ones.
- The review step that would ask where is the rate limit is exactly the one skipped when code is accepted unread.
- A prototype login with no throttle is promoted to production, where it immediately faces automated credential stuffing.
- The gap is invisible in local and demo testing because a developer logging in once never triggers the hundredth failed attempt.
- As a vibe-coded app gains users, it also gains attention from bots, and the missing limit that was harmless in private becomes a live brute-force target.
Detection
How to find it
- Script many failed logins against a test account and confirm the endpoint keeps responding instead of locking or throttling.
- Check whether reset codes and one-time codes bound the number of verification attempts before expiry.
- Call the authentication and verification APIs directly, bypassing the UI, to see whether any limit is enforced server-side.
- Review login, reset, and OTP handlers for attempt-tracking state or a shared rate-limiter; its absence is the finding.
Remediation
How to fix it
- Enforce server-side rate limiting on every authentication and verification endpoint, keyed by account and by source, not in the client.
- Add progressive delays or temporary lockout after repeated failures, with a safe unlock path that itself resists abuse.
- Cap one-time and reset codes to a few attempts and expire them quickly, and use codes long enough to resist guessing.
- Add CAPTCHA or step-up challenges after a threshold to break automated guessing without blocking real users.
- Log and alert on bursts of failed attempts so credential stuffing and spraying are detected and can be blocked.
Frequently asked questions
- What is CWE-307 (improper restriction of excessive authentication attempts)?
- CWE-307 is when a login or verification endpoint lets a client try as many times as it wants with no cap, so an attacker can guess passwords, replay stolen credentials, or brute-force a short code at machine speed. The protection must be enforced on the server, since client-side limits are bypassed by calling the API directly.
- How have AI assistants and vibe coding increased the risk?
- Assistants optimize for a login that works on the correct credentials, and a working login needs no attempt counter, so rate limiting is simply missing from the generated code. Vibe coding ships that endpoint unread, and because the gap never shows up in a single successful test login, the unprotected handler reaches production.
- How do I fix no brute-force protection?
- Add server-side rate limiting and lockout to every authentication and verification endpoint keyed by account and source, cap and expire one-time codes, add a challenge after a threshold, and alert on bursts of failed attempts.
Related weaknesses
Catch CWE-307 before you ship
Tethlyn Audit scans your codebase and its git history for CWE-307 and the rest of the authentication & session security class, then ranks each finding by real exploitability and data sensitivity.