Account enumeration
| Class | Authentication, Reconnaissance |
|---|---|
| Also known as | User enumeration, email enumeration, username enumeration |
| Weakness | CWE-204: Observable Response Discrepancy |
| OWASP Top 10 | A07:2025 Authentication Failures |
| Typical severity | Low to Medium |
| Affects | Sign-in, sign-up and password reset forms and the APIs behind them |
A sign-in form that answers "The password is not correct" for one email address and "User not recognized" for another has told the visitor that the first address belongs to an account.1 Account enumeration is the use of such differences to build a list of valid usernames or email addresses. The form never has to accept a password: the attacker types candidate addresses, reads each reply, and keeps the ones that came back with the "registered" answer. The weakness underneath is a server that gives different responses depending on internal state that the person asking should not learn.2
Where the difference shows
The error text is the obvious channel. Any part of the response that changes with the account's existence carries the same information. The HTTP status code can be 200 for one case and 403 for the other while the page shows the same words.3 A redirect can put the reason in the URL, as in err.jsp?User=baduser&Error=0 compared with Error=2. Page titles, response length, and per-user paths that return 403 for an existing name and 404 for a missing one all leak the answer.1
Sign-in is one of three places to look. A sign-up form that refuses an address as taken, or a reset form that says the address is not in the database, leaks the same fact.3
| Form | Reveals the account | Same for every address |
|---|---|---|
| Sign-in | "Login failed, invalid user ID." | "Login failed; Invalid user ID or password." |
| Password reset | "We just sent you a password reset link." | "If that email address is in our database, we will send you an email to reset your password." |
| Sign-up | "This user ID is already in use." | "A link to activate your account has been emailed to the address provided." |
Some systems need no form at all. Where user IDs follow a pattern, such as CN000100, CN000101, or a name rule that turns a known staff name into a login, the list can be generated and then confirmed.1
Timing
Identical words do not help if one case takes longer. A common login routine looks the user up first and returns at once when there is no match, so the slow password hash runs only for real accounts:3
// Leaks through the message and through the response time
const user = await db.findUserByEmail(email);
if (!user) return res.status(401).json({ error: "No account with that email." });
if (!(await verifyPassword(user.passwordHash, password)))
return res.status(401).json({ error: "Wrong password." });The fix runs the same work on both paths. Django's built-in login backend does this: when the username is not found it sets the user to none and still passes it to check_password_with_timing_attack_mitigation, so a missing account goes through the same password step as a real one.4 The same idea in a Node.js route, where hashPassword and verifyPassword stand for the app's own password hashing functions:
const DUMMY_HASH = await hashPassword("placeholder, never matches");
const user = await db.findUserByEmail(email);
const ok = await verifyPassword(user ? user.passwordHash : DUMMY_HASH, password);
if (!user || !ok) {
return res.status(401).json({ error: "Wrong email or password." });
}Reset forms have a larger gap. Sending a reset email through an outside mail service can add several hundred milliseconds to the reply, and only real accounts get one.1 Queuing the email as a background job and replying straight away removes that delay from the response.
Uses of the list
Brute-force and default password attempts can skip names that do not exist.1 Credential stuffing can be pointed at addresses known to be registered.5 The list also exposes private facts about a service's users and lets Phishing be aimed at people known to hold an account.5
Twitter, 2021 to 2022
A code change Twitter shipped in June 2021 made its login flow answer, for any submitted email address or phone number, which account it belonged to. A bug bounty report in January 2022 led to a fix. In July 2022 a press report showed the data for sale, and Twitter confirmed that someone had used the flaw before it was closed; no passwords were exposed.6 The seller had built about 5.4 million profiles in December 2021 by taking the account ID each lookup returned and scraping the public profile behind it, and asked $30,000 for the set.7 Twitter's notice singled out owners of pseudonymous accounts, who can be targeted by state or other actors, and advised them not to add a publicly known phone number or email address.6
Closing the gap
Every failed sign-in, reset or recovery attempt gets one generic reply, whether the account is missing, the password is wrong, or the account is locked or disabled, with the same status code and body.3 For password reset, the reply is the same and the email goes out only when the account exists. On sign-up, a reply such as "A link to activate your account has been emailed to the address provided" reads the same for a new address and a taken one, and only the owner of the inbox learns which case applied.3
Generic messages can confuse real users, so how strict to be depends on how critical the app and its data are.3 Where a form cannot stay silent, Rate limiting and a CAPTCHA keep the enumeration slow enough that a large list is impractical.3
Hosted sign-in services
Firebase Authentication (see Firebase security): without protection, signing in with an unknown address returns EMAIL_NOT_FOUND. Email enumeration protection replaces it with INVALID_LOGIN_CREDENTIALS, stops returning the list of sign-in methods for an address, and makes reset requests return no error either way. It is on by default only for projects created on or after 15 September 2023. The switch is under Authentication, Settings, User account management, User actions, Email enumeration protection (recommended), then Save. Sign-up still returns EMAIL_EXISTS, which can be guarded with App Check or reCAPTCHA.5
Amazon Cognito: the app client setting PreventUserExistenceErrors set to ENABLED turns UserNotFoundException into NotAuthorizedException with "Incorrect username or password". An app client created through the API starts at LEGACY, which leaks; the console selects Prevent user existence errors by default.8
Supabase Auth: resetPasswordForEmail() returns without error whether or not the address has an account.9 In the v1 client reference, signUp() for an existing confirmed user returns a fake user object when email confirmations are on, and the error "User already registered" when they are off.10
Prompt for a coding agent
Check every sign-in, sign-up, password reset and account recovery route in this project, including API routes the frontend calls. For each one, make the reply identical whether or not the account exists: the same message, the same HTTP status code and the same response body. On sign-in, run the password hash even when no user is found, using a fixed dummy hash, so both paths take about the same time. On reset, send the email from a background job and reply at once. On sign-up, send a confirmation email and show the same "check your email" reply for new and existing addresses. If the app uses Firebase Authentication, Amazon Cognito or Supabase Auth, list the provider setting that controls this and its current value. List every file you changed.
In SecFlash
SecFlash reports a Firebase project with email enumeration protection turned off as SF-CLD-054 on the Cloud page, since its sign-in answers tell whether an address has an account.
See also
- Authentication
- Brute-force attack
- Credential stuffing
- Password spraying
- Account lockout
- Account recovery
- Error handling and stack traces
- Securing a Firebase application
- Category: Reconnaissance
References
- a b c d e OWASP. "Testing for Account Enumeration and Guessable User Account (WSTG-IDNT-04)". Web Security Testing Guide v4.2.
- back MITRE. "CWE-204: Observable Response Discrepancy". CWE 5.0.
- a b c d e f g "Authentication Cheat Sheet". OWASP Cheat Sheet Series.
- back Django Software Foundation. "django/contrib/auth/backends.py". Django source on GitHub.
- a b c Google (n.d.). "Enable or disable email enumeration protection". Identity Platform documentation.
- a b Twitter (5 August 2022). "An incident impacting some accounts and private information on Twitter". Twitter Privacy Center.
- back Abrams, Lawrence (5 August 2022). "Twitter confirms zero-day used to expose data of 5.4 million accounts". BleepingComputer.
- back Amazon Web Services. "Managing user existence error responses". Amazon Cognito Developer Guide.
- back Supabase. "Password-based Auth". Supabase Docs.
- back Supabase. "auth signup". Supabase JavaScript reference, v1.
External links
- Authentication Cheat Sheet, OWASP Cheat Sheet Series