OWASP WSTG v4.2 Explained

OWASP WSTG: Part 4 - Identity Management

WSTG v4.2 section 4.3 explained: role definitions, user registration, account provisioning, account enumeration and guessable usernames, and weak username policies, with test steps and fixes.

10 min read
views
visits
OWASP WSTG Part 4 - Identity Management
OWASP WSTG Part 4 - Identity Management

Before an application can decide whether you are who you say you are (authentication, Part 5) and what you are allowed to do (authorization, Part 6), it has to manage who exists at all: which roles there are, how accounts are created, who can create them, and how much the application reveals about existing users.

Identity Management testing (WSTG section 4.3, IDs WSTG-IDNT-*) is a short category, but its findings feed directly into the next ones: an enumerated list of valid usernames turns a blind brute-force attack into a targeted one.

Source: WSTG v4.2 §4.3 Identity Management Testing (CC BY-SA 4.0), explained and expanded. Only test systems you are authorised to test.


Key Takeaways

  • Document every role and what it may do before testing authorization. You cannot test what you have not mapped.
  • Registration and provisioning are privileged operations. Check who can create which accounts and with which role.
  • Any difference in responses can leak valid usernames: messages, status codes, redirects, timing, even page titles.
  • Predictable usernames (jbloggs, employee IDs, emails) make enumeration trivial.
  • Fix with uniform responses for valid and invalid users, plus rate limiting.

The Identity Life Cycle

flowchart LR
    R["Role definitions<br/>(IDNT-01)"] --> REG["Self-registration<br/>(IDNT-02)"]
    R --> PROV["Provisioning by admins<br/>(IDNT-03)"]
    REG --> ACC["Accounts"]
    PROV --> ACC
    ACC --> ENUM["What leaks about accounts?<br/>enumeration (IDNT-04)<br/>username policy (IDNT-05)"]
    ENUM --> AUTH["Authentication<br/>(Part 5)"]

WSTG-IDNT-01: Test Role Definitions

What it checks: which roles exist (anonymous, customer, support agent, manager, administrator, auditor…), what each one is supposed to do, and whether the roles follow least privilege.

How to test:

  1. Identify the roles from documentation, the UI (menus that differ per user), the registration form, cookies and tokens (role=user, JWT claims like "role": "admin"), and API responses.
  2. Build a permission matrix: roles as columns, functions as rows, and the expected answer in each cell.
Function Anonymous Customer Support Admin
View own orders no yes no yes
View any customer’s orders no no yes yes
Refund an order no no yes yes
Manage users no no no yes
  1. Try to switch roles: change role values in cookies, hidden fields, request bodies or JWT claims, and see whether the server accepts them.
  2. Review granularity: is “admin” one giant role, or are permissions split so that, for example, support staff cannot delete accounts?

Tools: Burp Autorize and AuthMatrix extensions, ZAP Access Control Testing add-on; they replay requests with each role’s session and compare results automatically.

Fix: define roles and permissions explicitly (RBAC or ABAC), apply least privilege, separate duties for sensitive actions, and enforce the matrix on the server, never based on a role value supplied by the client.


WSTG-IDNT-02: Test User Registration Process

What it checks: that self-registration matches the business and security requirements of the application.

Questions to answer:

  • Can anyone register? Is that intended, or should registration be invite-only or approved?
  • Is identity verified, and how strongly? An email link, a phone OTP, a document check? A banking app and a forum need very different levels.
  • Can one person or bot register many accounts? Is there rate limiting or CAPTCHA? Can the same email be reused with variations (user+1@gmail.com, User@Gmail.com)?
  • Can users choose a privileged role during registration (a role field, a mass-assignment bug)?
1
2
3
4
POST /api/register HTTP/1.1
Content-Type: application/json

{"email":"tester@example.com","password":"Str0ng!Passw0rd","role":"admin","isVerified":true}

If the extra role or isVerified fields are accepted, that is mass assignment: the API blindly maps request fields to the user object.

  • Can you register an existing user’s identity (same email with different case, Unicode look-alikes), possibly taking over their account?

Fix: require verification proportional to the risk, rate-limit registration, normalise identifiers (case, Unicode) before checking uniqueness, and bind only allow-listed fields from the request.


WSTG-IDNT-03: Test Account Provisioning Process

What it checks: which accounts can create (provision) other accounts, of which roles, and whether that process can be abused.

How to test:

  • Can an administrator create another administrator? Should they, or does that need a second approver?
  • Can a lower-privileged user (e.g. a team manager) provision accounts with more privileges than they have?
  • Is there verification or approval before a provisioned account becomes active?
  • Can a user de-provision (delete or disable) accounts they should not control, including higher-privileged ones?
  • Replay the provisioning request with a lower-privileged session; it should fail.

Fix: a user should only be able to grant permissions they hold themselves; require approval for privileged accounts; log every provisioning and de-provisioning event.


WSTG-IDNT-04: Testing for Account Enumeration and Guessable User Accounts

What it checks: whether the application reveals which usernames or emails exist. A list of valid accounts makes password spraying, credential stuffing and phishing much more effective.

How to test: send three login attempts and compare everything in the responses:

  1. A valid username with the correct password.
  2. A valid username with a wrong password.
  3. A non-existent username.
1
2
valid user, wrong password  ->  "The password is incorrect."
non-existent user           ->  "No account with this email."     <- enumeration

Even when the messages match, look for differences in:

Signal Example of a leak
Error message “wrong password” vs “user not found”
HTTP status code 200 vs 403, or 401 vs 404
Redirects /login?error=1 vs /login?error=2
Page title or length an extra space or hidden field changes the size
Response time the server hashes the password only for existing users, so valid users are slower
URI probing /~alice/ returns 403, /~nobody/ returns 404

Also test every other place that takes a username: registration (“email already taken”), password reset (“we sent a link” vs “unknown email”), and APIs.

1
2
3
# Timing-based enumeration with ffuf: compare response times and sizes
ffuf -u https://example.com/api/login -X POST -H 'Content-Type: application/json' \
     -d '{"email":"FUZZ","password":"WrongPass123!"}' -w emails.txt -mc all -o out.json

Fix: return the same message, status code and timing for valid and invalid accounts (“If an account exists, you will receive an email”), rate-limit and monitor these endpoints, and remove default and test accounts before going live.


WSTG-IDNT-05: Testing for Weak or Unenforced Username Policy

What it checks: whether usernames follow a predictable structure that makes them easy to guess.

Examples: jbloggs for Joe Bloggs, emp10234 employee IDs, sequential customer numbers, or simply the corporate email format firstname.lastname@example.com, which can be built from LinkedIn.

How to test: identify the format from known accounts (registration, public profiles, emails), generate candidates and confirm them with the enumeration techniques from IDNT-04.

1
2
# Generate candidate usernames from a list of names
awk '{print tolower(substr($1,1,1) $2)}' names.txt > candidates.txt   # jbloggs style

Fix: where usernames cannot be secret, assume they are known: rely on strong authentication (MFA, good password policy, lockout) and generic error messages rather than on usernames being hard to guess.


Worked Example: Fixing Account Enumeration (IDNT-04)

Enumeration is usually a code problem: the login handler branches differently for “no such user” and “wrong password”, and often skips the password hash entirely when the user is missing, which leaks through both the message and the timing.

Vulnerable (Node/Express) — two leaks in one function:

1
2
3
4
5
6
7
8
9
10
11
app.post('/login', async (req, res) => {
  const user = await db.users.findByEmail(req.body.email);
  if (!user) {
    // leak 1: distinct message.  leak 2: returns instantly (no hash computed)
    return res.status(404).json({ error: 'No account with this email' });
  }
  if (!bcrypt.compareSync(req.body.password, user.hash)) {
    return res.status(401).json({ error: 'Incorrect password' });
  }
  // ...issue session
});

Exploit — the attacker does not even need the messages; timing alone separates valid from invalid emails:

1
2
3
4
5
6
7
8
# valid email -> server computes bcrypt (~80ms); invalid -> returns in ~2ms
for e in alice@corp.com nobody@corp.com; do
  printf '%-18s ' "$e"
  curl -s -o /dev/null -w '%{time_total}s  code=%{http_code}\n' \
    https://example.com/login -d "email=$e&password=x"
done
# alice@corp.com     0.084s  code=401     <- exists
# nobody@corp.com    0.003s  code=404     <- does not

Fixed — one response, and constant work whether or not the user exists:

1
2
3
4
5
6
7
8
9
10
const DUMMY_HASH = '$2b$12$C6......invalidbutwellformed';  // precomputed once
app.post('/login', async (req, res) => {
  const user = await db.users.findByEmail(req.body.email);
  // always run bcrypt so timing is identical for valid and invalid emails
  const ok = await bcrypt.compare(req.body.password, user ? user.hash : DUMMY_HASH);
  if (!ok || !user) {
    return res.status(401).json({ error: 'Invalid email or password' });
  }
  // ...issue session
});

Apply the same discipline to registration (“If this email is new, we’ll send a confirmation”) and password reset (“If an account exists, we’ll email a link”), the three places enumeration hides.

Real-world case. User-enumeration findings are among the most frequently reported on bug-bounty platforms precisely because this branching pattern is so common. On its own it is usually Low/Medium, but it is the first step of every password-spray and credential-stuffing campaign, which is why it feeds directly into Part 5.


Hands-on Practice

  • PortSwigger Academy — Authentication labs include “Username enumeration via different responses” and “…via response timing”.
  • Juice Shop — the login and registration flows leak enough to practise IDNT-04/05.
  • Burp Intruder / Comparer — load a username list, diff the responses by length, status and time to spot the tell.

Checklist: Identity Management

ID Test Main tools
WSTG-IDNT-01 Role definitions Permission matrix, Burp Autorize / AuthMatrix, ZAP Access Control
WSTG-IDNT-02 User registration process Burp Repeater, mass-assignment payloads
WSTG-IDNT-03 Account provisioning process Burp, replay with lower-privileged sessions
WSTG-IDNT-04 Account enumeration and guessable accounts Burp Intruder / Comparer, ffuf, timing analysis
WSTG-IDNT-05 Weak or unenforced username policy Name lists, OSINT, scripts

Previous: Part 3 - Configuration and Deployment Management · Next: Part 5 - Authentication


References

Further reading

Comments

Questions, corrections or another approach? Comment with your GitHub account.

Open Research & Community Labs
صدقة جارية • Ongoing Charity

Empowering the Cybersecurity Community

All research, lab walkthroughs, and technical series on this platform remain 100% free. You can support server hosting, research environments, and lab infrastructure.

Support & Wall of Honor
اللهم اجعل هذا العمل علمًا نافعًا وصدقةً جارية، واكتب لي به الأجر والقبول، وانفع به كل من قرأه أو تعلّمه.
اللهم احفظ لي والديّ وأهلي، وبارك في أعمارهم وصحتهم، وأدم عليهم نعمة الصحة والعافية، ولا تريني فيهم بأسًا يبكيني.
Dedicated as ongoing charity and beneficial knowledge. May Allah bless my parents and family, protect them, and grant them lasting health and happiness.