The usernames nobody leaked

Several teachers received a fake email asking them to confirm their school platform account. Each message included the recipient’s exact username.

Usernames were formed from a first initial, surname and two digits, for example “mgarcia07”. Teachers’ names and email addresses were public on the school website, but usernames were private.

No list had leaked, and nobody had accessed the server. The only unusual activity was thousands of failed sign-ins from one address the previous week.

How did the attacker obtain the real usernames?

How to solve the cases
A login window with an error message viewed through a magnifying glass

Hints

Reveal them one at a time, only when you need them.

Solution

The attacker learned the usernames from the login form. It answered “user does not exist” or “incorrect password” depending on the input, so failed attempts revealed whether a username was valid.

What happened?

The platform first looked up the username, then checked the password if the account existed. The error differed between stages. This flaw is known as username enumeration.

Given the public names and the naming pattern, the attacker could generate candidates. For María García, those ranged from mgarcia00 to mgarcia99.

  1. A programme submitted each candidate with an arbitrary password. Burp Intruder, part of Burp Suite, can automate requests and compare responses.
  2. “User does not exist” ruled out a candidate. “Incorrect password” confirmed a real username.
  3. With dozens of teachers and a hundred numbers per person, a few thousand attempts were enough, matching the failures in the logs.
  4. The attacker then made the phishing emails more convincing by including each teacher’s real username.

The difference can also be in the HTTP status or the response time. If the application checks the password only for existing users, those requests may take longer.

How could it be fixed and prevented?

To respond, warn the teachers, block the source of the attempts and identify anyone who entered their password on the fake site so they can reset it.

To prevent a repeat:

  • Make failures look the same. Use a generic error such as “Incorrect username or password”, with the same HTTP status and similar timing. The server can also perform a password check when no user was found.
  • Apply the rule across forms. Registration and password recovery can also leak account names. A recovery form can always say “If the account exists, you’ll receive an email.”
  • Limit attempts. Set limits per account and per IP address and alert on large numbers of failures.
  • Use multifactor authentication to reduce the risk if someone obtains a password through phishing.

Further reading

This case is inspired by the Username enumeration via different responses lab from PortSwigger Web Security Academy, where Burp Intruder compares server responses.

See Authentication and Error Messages for guidance on errors, timing, registration and recovery in the OWASP Authentication Cheat Sheet.

Testing for this vulnerability is explained in the OWASP Web Security Testing Guide: Testing for Account Enumeration.

Have a story worth investigating?

Suggest a case

A project by Eniun

How do you solve the cases?

Each case presents a mystery that seems to defy explanation.

A moderator who knows the solution reads the mystery to the group. The group works out what happened by asking questions, discussing hypotheses and using what they know.

You can project the case on a screen so everyone can read it and refer back to it during the discussion.

The moderator can guide the discussion without giving away the answer. If the group gets stuck, each case offers three graded hints under “Hints”, which can be revealed one at a time.

Once the moderator confirms that the group has found the answer, select “Show answer” to open the solution.

You can also solve the cases on your own: read the story, try to come up with an explanation and use the hints only when you need them.