Cybersecurity testing workstation with an ethical security analyst examining systems and vulnerabilities.

Testing Login Flows and JWTs: Break It, Then Fix It

Authentication flaws are attractive to attackers because they often lead directly to full account takeover, with no further exploitation needed. Testing this area covers the login flow itself, session token handling, and, increasingly, JSON Web Tokens (JWTs).

Testing the login flow

Rate limiting and account lockout

Using Burp Intruder with a small, authorized list of candidate passwords against a test account, testers confirm whether the application throttles or locks out after repeated failures, and whether that control applies per account, per IP, or (ideally) both:

POST /login HTTP/1.1
Host: app.example.com
Content-Type: application/x-www-form-urlencoded

username=testuser&password=§candidate§

The §§ markers define Burp’s payload insertion point. A missing lockout, combined with a large real-world credential-stuffing list, is how most “sophisticated” account takeovers actually happen.

Username enumeration

Compare the application’s responses for a valid versus invalid username, both in message text and response time. “Invalid username” versus “invalid password” is a direct leak; a response-time difference of even a few hundred milliseconds, visible in Burp’s response timer, can be just as exploitable through automation.

Testing session management

Inspect the Set-Cookie header for the session token and confirm the required flags are present:

Set-Cookie: session=8f3a...; Secure; HttpOnly; SameSite=Strict; Path=/

HttpOnly blocks JavaScript access, limiting the impact of any XSS that does slip through; Secure prevents transmission over plain HTTP; SameSite restricts cross-site requests that carry the cookie, mitigating CSRF. Also confirm that the session identifier rotates after login (preventing session fixation) and is invalidated server-side on logout, not just cleared from the browser.

Testing JWTs

JWTs move authentication state to the client, which shifts the risk to how the token is verified. Decode the token (Burp’s JWT Editor extension does this inline) to inspect its header and claims:

{"alg":"HS256","typ":"JWT"}
{"sub":"1024","role":"user","exp":1893456000}

Two checks catch most real-world JWT implementation bugs:

  • “alg”: “none” acceptance. Some libraries historically accepted an unsigned token if the header claimed no algorithm was used. Testers set alg to none and remove the signature to confirm the server correctly rejects it.
  • Algorithm confusion (RS256 to HS256). If a server expects RS256 (asymmetric) but the verification code is miswritten to accept HS256 (symmetric) using the public key as the shared secret, an attacker who knows the public key can forge a validly-signed token.

The fix is to pin the expected algorithm explicitly in verification code rather than trusting the token’s own header, for example in Node’s jsonwebtoken library:

// FIXED: algorithm is pinned server-side, not read from the token
jwt.verify(token, publicKey, { algorithms: ['RS256'] });

Also verify that exp (expiry) is enforced, that tokens are short-lived with a separate refresh mechanism, and that a revoked or logged-out token cannot still be used until its original expiry.

How Egaros can help

We test login flows, session handling and token-based authentication (JWT, OAuth2) for the implementation flaws automated scanners routinely miss. Contact us to schedule a test.

References and further reading

Related EGAROS articles

API pentesting and BOLA flaws · MFA and passkeys explained

Want an expert to review your security?

Tell us about your business and we will recommend the right starting point. The first consultation is free.


Discover more from Egaros

Subscribe to get the latest posts sent to your email.


Comments

اترك تعليقاً