Username Enumeration
The application responds differently to valid and invalid usernames, letting an attacker build a list of real accounts to target.
| Severity | Medium |
| CVSS 3.1 | 5.3 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 6.9 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-204: Observable Response Discrepancy |
| MITRE ATT&CK | T1589 Gather Victim Identity Information, T1110.003 Password Spraying |
| Category | Information Disclosure |
Description
The application reveals whether a username or email address belongs to an existing account through a difference in its behaviour. The difference may be explicit, such as a login error that says the user does not exist for one value and that the password is wrong for another, or a registration form that reports an address is already in use. It may also be subtle: a different HTTP status code, redirect, response length, page element or cookie, or a measurably longer response time for valid users, typically because the application only computes a password hash when the account exists.
An attacker can confirm which usernames or email addresses hold accounts, which turns password spraying, credential stuffing and targeted phishing from guesswork into focused attacks against real users. Where the accounts belong to members of the public, confirming that a person has an account may itself be a privacy concern, for example on a service whose membership is sensitive. The weakness does not grant access on its own, and it matters most where usernames are not already public, such as the email addresses of customers or staff. Its impact rises where no rate limiting stops large lists from being tested, where login rate limiting is weak and where multi-factor authentication is absent.
Login, registration, forgotten password, account recovery and invitation functions, and API endpoints that look up users, are all common sources. Enumeration is identified by submitting known valid and invalid usernames to each function and comparing the full responses, including headers and timing, for example with Burp Suite Intruder and Comparer.
Remediation
- Return the same response for valid and invalid usernames in every authentication-related function: the same message, status code, redirect, headers, cookies and page structure, for example "Invalid username or password" at login and "If an account exists for this address, an email has been sent" for password recovery.
- Make response times uniform, for example by verifying the submitted password against a dummy hash when the account does not exist, and by sending recovery emails asynchronously.
- At registration, send a message to the address instead of reporting on screen that it is already registered, where the user experience allows.
- Apply rate limiting, CAPTCHA or other anti-automation controls to login, registration, recovery and user lookup endpoints so that enumeration cannot be carried out at scale.
- Avoid user lookup functions in public APIs, and require authentication and authorisation for any that are needed.
Confirm the fix by repeating the comparison of responses and timings for valid and invalid usernames in each affected function.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.