# Username Enumeration

## Introduction

**User enumeration** is when a malicious actor can use brute-force techniques to either guess or confirm valid users in a system. User enumeration is often a web application vulnerability, though it can also be found in any system that requires user authentication. Two of the most common areas where user enumeration occurs are in a site's ‘login page’ and its ‘Forgot Password' functionality.

## How to Test

The malicious actor is looking for differences in the server's response based on the validity of submitted credentials. When the user enters an invalid username and password, the server returns a response saying that user ‘rapid7' does not exist. A malicious actor would know that the problem is not with the password, but that this username does not exist in the system.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M-rvVh8Pjn6-Q58Ocpi%2F-M-rzALYSrWPIZz_QVJ1%2Fimage.png?alt=media\&token=bcc59146-5523-4824-818d-a6b0c730ee3d)

On the other hand, if the user enters a valid username with an invalid password, and the server returns a different response that indicates that the password is incorrect, the malicious actor can then infer that the username is valid.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M-rvVh8Pjn6-Q58Ocpi%2F-M-rzCl1WXCIWsVq54Ds%2Fimage.png?alt=media\&token=ace78822-d8da-4145-bcc8-b6ac2ca74323)

At this point, the malicious actor knows how the server will respond to ‘known good' and ‘known bad' input. So, the malicious actor can then perform a brute-force attack with common usernames and passwords until access is finally gained.

## Solution

An effective remediation would be to have the server respond with a generic message that does not indicate which field is incorrect. When the response does not indicate whether the username or the password is incorrect, the malicious actor cannot infer whether usernames are valid.

![](https://2740220163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lv9UpLMmmAAyhFf0hfM%2F-M-rvVh8Pjn6-Q58Ocpi%2F-M-rzcuIsATNMT6cl29u%2Fimage.png?alt=media\&token=6aff68c7-cbc5-4137-adc5-65b1d24fc1c2)

## References

1. <https://www.hacksplaining.com/prevention/user-enumeration>
2. <https://portswigger.net/blog/preventing-username-enumeration>
3. <https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2015/june/username-enumeration-techniques-and-their-value/>
