CWE-204: Account Enumeration
An application returns different responses for valid and invalid inputs, so an attacker can learn which accounts, emails, or records exist.
Also known as: Account enumeration, Username enumeration, User existence disclosure
Risk
Usually medium, rising to high when combined with weak passwords or missing rate limiting. Enumeration itself leaks no data, but it builds the valid-account list that makes credential stuffing and targeted phishing work.
Definition
What it is
CWE-204 is a weakness where an application's observable behavior differs depending on whether the input matches something real. A login that says password incorrect for a known account but no such user for an unknown one tells the attacker exactly which emails are registered. The same leak appears in signup, password reset, and timing differences where a real account takes longer to process. Once the valid list is known, every downstream attack becomes cheaper and more focused.
Use-cases
How it shows up in real code
Login error reveals users
The login form returns no account found for unknown emails and wrong password for real ones. An attacker scripts a list of emails and keeps only the ones that confirm an account exists.
Signup confirms membership
Registration rejects an email with that address is already taken. An attacker uses the signup form purely as an oracle to confirm which emails have accounts.
Password reset distinguishes accounts
The reset page says a link was sent only when the account exists and shows a different message otherwise. The difference turns the public reset form into an enumeration tool.
Timing side channel
A valid username triggers a real password hash check while an invalid one returns instantly. The measurable delay reveals which accounts are real even when the text is identical.
AI risk
Why AI-generated code has increased the exposure
- Assistants optimize for a helpful, specific error message, so they emit no account found with that email rather than a deliberately vague response that protects account existence.
- Training data is full of tutorial auth flows that print distinct messages for missing user versus wrong password, so the model reproduces the discrepancy by default.
- The model cannot see that the signup, login, and reset handlers it generates separately must all return the same neutral response to avoid leaking across endpoints.
- When scaffolding login, registration, and reset together, the assistant writes each with its own natural wording, creating several enumeration oracles at once.
- Generated code rarely equalizes response timing, so even when messages match, the model leaves a measurable delay between real and fake accounts.
Vibe coding
How vibe coding amplifies the risk
- Vibe coding ships the assistant's friendly error text unread, so the distinct messages that leak account existence go straight to production.
- The skipped review step is exactly where a reviewer would notice that valid and invalid inputs produce different responses.
- A prototype's chatty auth messages, meant to help during development, are promoted to the live site where they become an enumeration oracle.
- The flaw is invisible in local and demo testing because a developer checking one known account never compares the valid and invalid responses side by side.
- As a vibe-coded product grows, more public forms (login, reset, invite, newsletter) each add another discrepancy, and none gets a security pass.
Detection
How to find it
- Compare responses for a known-valid and a known-invalid identifier on login, signup, and password reset; the text, status code, and redirect should be identical.
- Measure response timing for valid versus invalid usernames to find a side channel even when messages match.
- Review every public form that touches the user store for wording that confirms or denies existence.
- Script a small enumeration run against a test account to see whether the app confirms which identifiers are real.
Remediation
How to fix it
- Return a single neutral message for authentication and reset failures, such as if that account exists we sent a link, regardless of whether it does.
- Make signup and reset behave the same for taken and free identifiers, confirming by email instead of in the immediate response.
- Equalize timing so a real and a fake account take the same measurable time, for example by always running a hash comparison.
- Add rate limiting and monitoring so bulk enumeration attempts are throttled and flagged.
- Keep response codes and redirects uniform across valid and invalid inputs so no side channel distinguishes them.
Frequently asked questions
- What is CWE-204 (observable response discrepancy)?
- CWE-204 is when an application responds differently to valid and invalid inputs, such as showing distinct login or reset messages, so an attacker can tell which accounts or records exist. That confirmed list of valid accounts feeds credential stuffing and targeted phishing.
- How have AI assistants and vibe coding increased the risk?
- Assistants optimize for specific, helpful error text and were trained on tutorials that print different messages for missing user and wrong password, so they leak account existence by default. Vibe coding ships that wording unread, and because each public form is generated separately, several enumeration oracles reach production unreviewed.
- How do I fix account enumeration?
- Return one neutral message for all authentication and reset outcomes, make signup and reset behave identically whether or not the identifier exists, equalize response timing, and add rate limiting so bulk probing is throttled and detected.
Related weaknesses
Catch CWE-204 before you ship
Tethlyn Audit scans your codebase and its git history for CWE-204 and the rest of the authentication & session security class, then ranks each finding by real exploitability and data sensitivity.