August 16, 2026 · appsec.training
How to Test Web Application Authentication

A login page that accepts a valid password is not proof that authentication is secure. The meaningful question is whether an attacker can establish, retain, elevate, or recover an authenticated session outside the intended rules. Learning how to test web application authentication means examining the complete identity lifecycle: enrollment, login, session handling, multi-factor authentication, account recovery, logout, and audit evidence.
For AppSec engineers, this work is not a single scanner run or a collection of default proxy checks. It requires threat modeling the application’s trust boundaries, testing behavior in a controlled environment, reviewing implementation decisions, and translating findings into fixes that engineering teams can sustain.
Start With the Authentication Design
Before sending requests through an intercepting proxy, establish what the application is supposed to do. Document the identity provider, supported login methods, user roles, session format, MFA requirements, recovery paths, trusted devices, and API authentication mechanisms. A traditional server-side session, a signed JSON Web Token, OAuth authorization code flow, and a passkey implementation fail in different ways.
Map the relevant assets and trust boundaries. For example, identify where credentials are entered, where tokens are issued, which services validate them, and whether the browser, mobile client, or API gateway makes authorization decisions. Include administrative portals, staging environments, password-reset endpoints, SSO callback handlers, and legacy APIs. Authentication weaknesses often appear at these edges rather than on the primary login form.
This design review also prevents false positives. A short session timeout may be appropriate for an administrative console but disruptive for a consumer application. A remembered-device feature may be an accepted business decision, provided it is bound to a device and protected with meaningful reauthentication requirements. The tester’s role is to identify whether the implemented control matches the stated risk decision.
Build a Safe, Repeatable Test Setup
Use dedicated test accounts with distinct roles and known attributes. At a minimum, create two standard users, one privileged user where permitted, a locked or disabled account, and accounts enrolled and not enrolled in MFA. Separate accounts make it possible to detect horizontal access issues, stale sessions, and incorrect identity binding.
Capture normal browser and API traffic first. Record the requests involved in logging in, refreshing a session, changing a password, enrolling an authenticator, recovering an account, and logging out. A proxy tool is useful here because it exposes cookies, headers, redirect parameters, anti-CSRF tokens, and response behavior that may be hidden by the interface.
Define expected results for each test before modifying requests. This keeps testing evidence-based. If a session cookie is changed, the expected response should be rejection and creation of no authenticated context. If a password reset token is reused, the expected result should be invalidation. Repeatability matters because a finding that cannot be reproduced and explained is difficult to prioritize or remediate.
Only test systems you are authorized to assess. Rate limits, lockout controls, and production monitoring can be affected by authentication testing, particularly when testing recovery and credential-guessing defenses.
Test Login and Credential Handling
Begin with the core login flow. Verify that authentication succeeds only with valid credentials and that error responses do not disclose whether a username, email address, or account exists. Exact wording is only part of the issue. Differences in response time, status code, redirect destination, or response size can also enable account enumeration.
Test credential handling at both the interface and request layer. Confirm that passwords are submitted only over TLS, are never returned in API responses, and do not appear in client-side logs, URLs, analytics payloads, or error messages. During secure code review, verify that passwords are stored with a modern adaptive password-hashing function and unique salts. A dynamic test cannot establish safe storage on its own.
Evaluate defenses against automated attacks without running uncontrolled password attacks against production. Review rate limiting, progressive delays, IP and account-based controls, CAPTCHA or bot-detection decisions, alerting, and lockout recovery. Account lockout has a trade-off: aggressive lockouts can create a denial-of-service condition against targeted users. Good designs balance detection, throttling, and secure recovery rather than relying on a permanent lockout.
Also test alternate entry points. APIs, mobile backends, older login endpoints, and SSO fallback paths must enforce the same credential and policy requirements. It is common to find MFA or account-status checks on the web UI but not on an API endpoint that accepts the same credentials.
Test Sessions, Tokens, and Logout
Session management determines what happens after authentication. Inspect every cookie and token issued at login. Browser session cookies should use Secure, HttpOnly, and an appropriate SameSite setting. The right SameSite value depends on application flows, especially when external identity providers or cross-site integrations are involved. Setting it too strictly can break a legitimate login callback; setting it too loosely can increase cross-site request risk.
Verify that the application creates a new session identifier after login and after privilege changes. This reduces session fixation risk. Test whether a pre-login session identifier remains valid after authentication, whether the same identifier works in another browser, and whether session state survives a password change, MFA reset, account disablement, or role change when it should not.
For token-based APIs, inspect signature validation, expiration, audience, issuer, and algorithm handling. Do not assume a JWT is safe because it is signed. Test whether services reject expired tokens, tokens from another environment, altered claims, unexpected signing algorithms, and tokens intended for a different audience. Confirm that authorization decisions are made by trusted server-side components, not by roles or flags supplied by the client.
Logout deserves the same scrutiny as login. After logout, replay requests using the previous cookie or bearer token. The expected result is rejection when the application claims to invalidate the session. Stateless token architectures complicate immediate revocation, so the design may rely on short expiration periods and refresh-token controls. That can be acceptable, but it must align with the application’s risk profile and documented behavior.
How to Test Web Application Authentication With MFA and Recovery
MFA testing should prove that the second factor is enforced, not merely displayed. Attempt to access authenticated resources after completing only the password step. Test whether users can skip MFA through direct navigation, API calls, alternate login endpoints, or manipulated workflow state. Check that MFA enrollment requires recent authentication and that removing or changing a factor triggers appropriate verification.
Recovery flows frequently weaken an otherwise strong MFA design. Test password resets, backup codes, email-change processes, help-desk recovery, and trusted-device enrollment. Recovery tokens should be high entropy, single use, time limited, and bound to the intended account. Check whether a reset link remains valid after use, whether it can be replayed from another session, and whether changing an email address requires confirmation through the old and new channels when the product’s risk model calls for it.
A useful authentication test matrix should cover at least these distinct states:
- Valid, invalid, disabled, and unverified accounts
- MFA enrolled, unenrolled, challenged, failed, and recovered states
- Active, expired, logged-out, and revoked sessions
- Standard and privileged roles across browser and API clients
- Password changes, account recovery, and identity-provider changes
The matrix is more valuable than a long list of payloads because it exposes missing state transitions. If a session remains valid after an account is disabled, the issue is not simply a cookie problem. It is a failure to propagate identity state across the system.
Separate Authentication From Authorization
Authentication answers who the user is. Authorization answers what that user can do. They are tightly connected, but testing them as one control causes missed findings. A valid low-privilege session must not become an administrative session because a client changes a role field, object ID, tenant ID, or API parameter.
After authenticating as multiple accounts, replay the same requests while changing object references and tenant context. Confirm that each server-side endpoint enforces ownership and role checks. Test for forced browsing to privileged routes, direct calls to administrative APIs, and token claims that are accepted without independent validation. These tests often reveal broken object-level authorization, which can have a higher impact than the original login weakness.
Collect Evidence and Drive Remediation
For every finding, preserve the minimum evidence needed to reproduce it: preconditions, exact request changes, observed response, security impact, and expected behavior. Avoid recording real credentials or sensitive tokens in tickets. Explain the exploit path in engineering terms, then recommend a specific corrective control such as server-side session invalidation, centralized token validation, reauthentication for sensitive actions, or consistent MFA enforcement at the API gateway.
Validate fixes with regression tests. Authentication defects tend to return when teams add a new client, migrate an identity provider, introduce a caching layer, or change token libraries. Combining DAST observations with threat modeling and secure code review gives AppSec teams stronger coverage than any one technique alone.
The practical standard is simple: every authentication state change should be intentional, verifiable, and enforced consistently wherever the application accepts identity. Building that discipline through hands-on testing prepares engineers to find the failures that a successful login screen will never reveal.