Skip to main content
Create your own
Lesson illustration

Username Enumeration via Error Messages and Timing

Hello! In our last lesson, we dug into analyzing authentication flows, identifying weaknesses like insecure credential handling and the absence of rate limiting. We saw how manipulating parameters or finding a lack of request throttling could open the door to serious attacks.

Today, we'll build directly on that foundation. This lesson addresses the learning outcome: Perform username enumeration by analyzing application error messages and response timing. Username enumeration is the process of discovering valid usernames on a system. Why is this so important? If an attacker can build a list of valid usernames, they can then focus their efforts on cracking the passwords for those specific accounts, making attacks like password spraying and brute-forcing far more efficient.

We will explore the two primary methods for this:

  1. Response Discrepancy Analysis: Analyzing differences in error messages or status codes.
  2. Timing Attacks: Exploiting subtle differences in how long the server takes to respond.

By the end of this lesson, you'll be able to systematically probe a login form to leak information that the application developers never intended to reveal.

1. The Theory of Username Enumeration

An ideal, secure login page should behave identically whether you enter a valid username with a wrong password, an invalid username, or both. It should give a generic error like "Invalid username or password" and take the same amount of time to respond in all cases. However, this is often not the case. Attackers can exploit these small inconsistencies.

Let's start with a foundational reading from PortSwigger's Web Security Academy that breaks down the different types of information leakage.

Vulnerabilities in password-based login | Web Security ...

The article 'Vulnerabilities in password-based login' clearly explains the core concepts of username enumeration. We will focus on the sections detailing how error messages and response times can be exploited.

Read the introductory section on 'Username enumeration', followed by the subsections 'Error messages' and 'Response times'. As you read, focus on the distinction between the two techniques. Note the key tip in the 'Response times' section about using an excessively long password to amplify the delay.

As the reading explains, there are two main tells:

  • Verbose Error Messages: The application explicitly tells you what part of your input was wrong. For example:

    • Invalid Username: "Username not found."
    • Valid Username, Invalid Password: "The password you entered is incorrect."
      This is a direct information leak that makes building a list of valid users trivial.
  • Response Timing Discrepancies: This is a more subtle, "side-channel" attack. The server might take longer to process a login attempt for a valid username because it performs additional steps, like hashing the provided password to compare it against the stored hash. For an invalid username, it might reject the request instantly.

This timing difference can be very small, but as noted in the reading, we can often amplify it.

Username Enumeration via Timing Attack
This image demonstrates a timing attack. Although the login form shows a generic 'Invalid username or password' error, the browser's developer tools reveal that the server took nearly a full second (908.72 ms) to respond. This significant delay, compared to the faster response for a known-invalid username, strongly suggests that the username 'test' is valid and the server spent extra time processing the password.

2. Practical Exploitation with Burp Suite

Now let's see how this works in practice. We'll use Burp Suite to identify and exploit a timing-based username enumeration vulnerability. The following video provides a complete walkthrough of a PortSwigger lab, from manual discovery to automated exploitation.

A key point to watch for is how the presenter deals with IP-based rate limiting, a topic we covered in the last lesson. This is a great example of how different security controls (or lack thereof) interact.

Authentication Vulnerabilities - Lab #5 Username enumeration via response timing | Long Version

Rana Khalil's walkthrough of the 'Username enumeration via response timing' lab is an excellent practical demonstration. It shows the entire process of identifying the vulnerability and then using Burp Intruder to exploit it.

Watch from 02:29 to 09:20. Pay close attention to these key steps: Bypassing the IP-based rate limiting using the X-Forwarded-For header (a great practical application of concepts from our last lesson). Using a long password to amplify the time difference between a valid and invalid username. Configuring Burp Intruder's 'Pitchfork' attack type to test a list of usernames while simultaneously changing the X-Forwarded-For header value for each request.

To complement the video, here is the official written solution for that same lab. You can use it as a step-by-step reference guide to reinforce the concepts shown in the video.

Lab: Username enumeration via response timing

This is the official step-by-step guide for the lab you just saw demonstrated. It's a useful resource to review the process at your own pace.

Quickly review the 'Solution' section. This text-based guide will help solidify your understanding of how to configure Burp Repeater and Intruder for this attack.

3. Automating with Python

While Burp Suite is fantastic for semi-automated testing, your background in computer science and Python opens up a more powerful and flexible approach: custom scripting. Writing your own tools helps you understand the vulnerability at a deeper level and allows you to adapt to non-standard situations where off-the-shelf tools might fail.

The following video walks through building a Python script using the requests library to perform this exact timing attack. This is a perfect example of applying your programming skills to offensive security.

Exploiting HTTP Timing Attack - Timing [HackTheBox]

The video 'Exploiting HTTP Timing Attack' by 0xdf provides a great walkthrough of scripting this vulnerability in Python. This will connect directly with your existing programming knowledge.

Watch the video from the beginning until 11:51. Focus on: How the requests library is used to make POST requests. How the response time is measured using response.elapsed.total_seconds(). The logic for comparing the response time against a threshold to determine if a username is valid. The presenter's process of refining the script for better, cleaner output—a valuable software engineering practice.

Test your understanding!

You are testing a login page. You have a list of potential usernames.

  1. When you test the username alice with a random password, you get the error message: "Incorrect password." When you test the username invaliduser with the same password, you get: "User does not exist." What vulnerability is present, and what is your next step?

  2. You move to another login page. This one always returns "Invalid credentials" no matter what you enter. However, you notice that attempts with the username bob take ~500ms to respond, while attempts with invaliduser take only ~150ms.

    • What vulnerability does this suggest?
    • What technique could you use to confirm your hypothesis and make the time difference even more obvious?
Show answer
  1. This is username enumeration via verbose error messages. The application is explicitly confirming that the username alice is valid. Your next step is to use a tool like Burp Intruder to iterate through your entire list of potential usernames, looking for any that trigger the "Incorrect password." response. This will give you a confirmed list of valid users.

    • This suggests username enumeration via response timing. The server is likely taking longer to process the request for bob because it's a valid user, and it's proceeding to check the password.
    • To confirm this, you should send the request for bob to Burp Repeater and try submitting a very long password (e.g., 1000 characters). If the time delay increases significantly (e.g., to 1500ms), while the delay for invaliduser stays the same, you have confirmed the timing attack vulnerability. The long password amplifies the time the server spends on the password-checking function.

Conclusion

In this lesson, you learned how to turn an application's own responses against it. Seemingly innocent error messages and subtle processing delays are not just bugs; they are valuable information leaks that an attacker can exploit to gain a foothold.

Key Takeaways:

  • Username Enumeration is the process of identifying valid usernames, significantly reducing the search space for password-based attacks.
  • Verbose Error Messages are the most direct form of this vulnerability, where the application explicitly states whether a username is valid or not.
  • Timing Attacks are a more subtle side-channel method where you measure differences in server response times to infer the validity of a username. This effect can often be amplified by sending long passwords.
  • Tooling is Key: You can exploit these vulnerabilities using GUI tools like Burp Suite Intruder or by writing flexible Python scripts, leveraging your development skills for offensive tasks.

Next Lesson Preview:
Now that you know how to build a list of valid usernames, what's next? In our next lesson, Execute credential-based attacks (brute-force, password spraying, credential stuffing) using Burp Suite Intruder, we will take our list of enumerated users and launch automated attacks to discover their passwords.

Can't find a good explanation? Sign up and we'll make it for you

Sign up