All articlesBlog / secure login

Secure Login for Website: Layered Controls That Stop Abuse

Secure login for website needs layered controls: session hardening, rate limits, replay-resistant browser checks and a safe Observe-first rollout.

MANDATEsecure loginwebsite login securitycredential stuffingreplay protectionCAPTCHA alternatives
Multiple account paths converge before a separate entitlement boundary.

Roughly 88% of breaches in the Basic Web Application Attack pattern of Verizon's 2025 Data Breach Investigations Report involved the use of stolen credentials, according to the report's healthcare snapshot. The attacker isn't defeating the password check. They're walking through it with a password that already works, then doing something with the session that follows.

That reframes the problem. Secure login for website accounts is no longer a question of whether a password is correct. The failures that matter now happen after authentication: a recovery link used twice, a checkout request resubmitted by a script, a promotion code redeemed by an already-authenticated session running faster than any human can click.

Most login guides stop at passwords and MFA. This one treats the browser action that arrives after the session exists as the place where replay and duplicate execution cause damage, and it shows how to roll out browser verification in Observe mode before a single legitimate user meets a challenge.

Which Control Stops Which Login Threat

Verizon's 2025 Data Breach Investigations Report analyzed more than 22,000 security incidents, including 12,195 confirmed data breaches, and found that credential abuse was the leading initial access vector, appearing in 22% of breaches (Verizon 2025 DBIR). Exploitation of vulnerabilities followed closely at 20%. Stolen passwords remain a working attack long after MFA became standard advice.

The same report carries a finding that matters more for capacity planning than for board slides. Across organizations monitored over an extended period, credential-stuffing attempts made up a substantial share of daily authentication traffic, and that share held up even at small businesses. On a typical day, a meaningful portion of the requests hitting your login form is somebody replaying a list.

Four threats that get used as synonyms and shouldn't be

  • Credential stuffing is the replay of username-and-password pairs leaked from other services against your login form. It isn't guessing, which is why lockout thresholds tuned for guessing sail right past it.
  • Account takeover is the outcome, not the technique. By the time an attacker controls the account, the login event is long finished.
  • Session theft is use of a stolen session identifier, which lets an attacker skip authentication entirely and land inside an existing session.
  • Trial eligibility abuse is deliberate repeated account creation to claim a free-trial benefit more than once. It's a fraud pattern in its own right, distinct from misleading billing or cancellation practices, and no amount of browser verification fixes the latter.

With those separated, the controls stop looking interchangeable.

Control Threat it addresses Where it runs What it does not cover
HTTPS with Secure cookies Session interception on the network Transport and browser Theft from a compromised device
Session rotation with server-side state Session fixation and stolen session identifiers Application server Proof that the person is human
MFA with risk-based step-up Credential stuffing and account takeover Authentication flow Sessions that are already authenticated
Rate limits on login and recovery High-volume guessing from one source Edge or application Low-volume attempts spread across many addresses
Short-lived action credentials checked on the server Replayed or reused proof for sensitive actions Server-side verification Authorization and transaction validity
Idempotency keys Duplicate orders or benefits from retries Operation handler Bot detection

Read the table as a planning tool rather than a ranking. The right-hand column is the part teams skip, and it's the part that causes incidents. A login form with strong MFA still needs replay controls on checkout, because an attacker holding a valid session passes MFA by definition.

Take the fifth row seriously. Controls that make a browser action replay-resistant have to bind proof to current server state rather than to a user identity alone. A proof tied only to the user can be copied and replayed by whoever steals it; a proof checked against server state at the moment of the action expires with that state. And a credential's presence on a request means nothing on its own. Your server has to submit it for verification, keep it out of logs, and treat the hosted service's decision as the only signal that counts.

Start with the row whose threat already appears in your logs. If password reset tokens show up twice for the same account, fix that before you tune anything else.

How to Harden Sessions and Passwords First

Session handling is the cheapest layer to fix and the one most often left half-finished. It costs a sprint, removes entire classes of attack, and requires no vendor conversation. Do it first, because bolting verification onto a weak session model just gives an attacker a second door.

The order below runs from transport upward, and each step assumes the one before it.

  1. Serve every page and form over HTTPS, including session traffic after login. A TLS-only login POST is a common and useless configuration: the password is protected and the cookie replacing it travels in the clear.
  2. Issue a high-entropy session identifier only after successful authentication. Keep authorization state on the server. If a browser-readable field says role: admin, the permission model now lives somewhere the user controls.
  3. Rotate the identifier at login and at privilege changes. A session that survives a role upgrade is a fixation opening. OWASP's Authentication Cheat Sheet is blunt about why: a session identifier is temporarily equivalent to the strongest authentication method in use, so stealing it bypasses the login step.
  4. Set Secure, HttpOnly and an appropriate SameSite value, scoped to the narrowest domain and path. Strict on admin cookies costs nothing. SameSite=None on everything hands cross-site requests a free ride.
  5. Invalidate the session on logout and on risk-triggered reauthentication. Logout that only clears the cookie leaves the server-side record alive for anyone holding a copy.
  6. Require fresh reauthentication for password, email and authenticator changes. These are the actions an attacker takes after takeover, and the ones users least expect a prompt for.

Two slips that survive code review

The first is protecting the login request with TLS while API calls after login ride weaker transport or a proxy that terminates and re-originates without the same guarantees. The second is packing identity or authorization claims into a browser-readable token with no server-side revocation, which makes every claim self-certifying until it expires.

Both produce the same failure: a session that looks valid long after it should have died. Rotation, server-side state and revocation let you answer "is this session still supposed to exist?" instead of "does this token parse?" The mechanics of converting a stolen identifier into an active session are covered in this explainer on session hijacking.

Passkeys change the front door, not the back door

Passkeys cut phishing exposure because there's no shared secret to type into a lookalike page. They don't solve device loss, cross-device enrollment, or the recovery path, and recovery is where takeover lands. The FIDO Alliance's 2025 World Password Day report found that 36% of respondents across five markets had experienced at least one account compromise linked to weak or stolen passwords. The same research tracked account-enumeration exposure on 68 websites and weaknesses in passkey management, including handling of key identifiers that could allow unauthorized passkey removal.

Whatever the primary factor, the change-password and add-authenticator flows need the same authorization checks as sign-in, plus fresh server-validated proof that the request came from the account holder's current session. MFA, account risk checks, session management and recovery controls remain responsible for account security. Browser verification sits beside them, not above them. Teams working through the account-level side of this can read this guide to stop automated account takeover attacks.

A checklist you can run today

  • Cookie attributes confirmed on every session cookie: Secure, HttpOnly, SameSite, narrow path.
  • Rotation visible in logs at login and at role change, not just documented.
  • Server-side session store with a real revocation call on logout.
  • Reauthentication enforced for password, email and authenticator changes.
  • Recovery tokens single-use, short-lived, and invalidated the moment the password changes.

Slow Credential Stuffing Without a CAPTCHA

Synthetic example. A login route takes 40 failed attempts against a single email address over twenty minutes, spread across 300 source addresses. A per-IP limit set at 10 per minute never fires, because no address comes close. A per-account limit set at 20 failures per hour does fire, and the response is a second-factor prompt rather than a lockout.

That's the shape of most stuffing. Attackers replay username-and-password pairs leaked from other services, so per-address volume looks like ordinary traffic from ordinary users on ordinary networks.

What each layer catches and misses

  • Per-account limits catch many attempts against one identity from many addresses. They miss a slow rotation across thousands of accounts at one attempt each.
  • Per-source limits catch one address hammering many accounts. They miss distributed attempts, which is why the OWASP Credential Stuffing Prevention Cheat Sheet warns against relying on a single predictable IP-volume threshold and recommends MFA as the strongest general defense.
  • Breached-password checks stop known pairs from being accepted at all. They do nothing when the leaked pair is new to your list.
  • Risk-based MFA asks for a second factor only when a login looks unusual, which keeps the cost near zero for ordinary sign-ins. OWASP cites Microsoft analysis estimating MFA could have stopped 99.9% of account compromises.

Password reuse is what makes the input list cheap. A 2024 Bitwarden survey of 2,400 people across the United States, United Kingdom, Australia, France, Germany and Japan found that 25% reused passwords across 11 to 20 or more sites and apps (Bitwarden World Password Day 2024). One breach elsewhere seeds thousands of attempts here.

Where risk scores fit

Browser risk scores are one signal among several, never a verdict. Google's reCAPTCHA v3 returns a score from 0.0 (likely a bot) to 1.0 (likely legitimate interaction), and Google's documentation suggests starting with a default threshold of 0.5 and then adjusting against observed traffic. For login it recommends using low scores to trigger stronger measures such as two-factor authentication or email verification, not to treat the score as proof of fraud.

A CSRF token issued before the login form isn't an anti-bot control, and treating it as one leads teams to over-trust it. It's form-integrity hygiene that defends against cross-site request forgery, a different problem. It does force an automated client to make one extra request to fetch the token, which nudges the cost of scripting the flow upward, but that's a side effect rather than the point.

Practical rule: if a control can't state what it rejects and why, it isn't a control yet. Rate limits, step-up prompts and score thresholds each need a written response for the requests they catch.

No single layer here is complete. Account limits, source limits, breached-password checks, step-up MFA and score thresholds each cover a different slice, and automation lives in the gaps between them. For a fuller walk through how these attempts are structured, see this explainer on credential stuffing.

Stop Signup and Trial Abuse Without CAPTCHAs

Signup abuse inverts the problem. The attacker creates accounts instead of logging into existing ones, so per-account login limits never see it, and per-IP limits often don't either.

Synthetic example. A signup route receives 200 account creations in one hour from 90 addresses, all using one disposable email domain and one device fingerprint hash. Per-IP limits see nothing unusual. A velocity limit on account creation per email domain and per billing identifier fires, and the response is email verification before the trial starts plus a review queue, not an outright block.

Comparing the three controls

Email or phone verification raises the cost per account, but it adds friction to every honest signup and can be bypassed with purchased numbers and throwaway inboxes. Velocity limits are cheap, invisible to honest users, and need tuning: too tight and a legitimate marketing push gets throttled, too loose and the limit never fires. Risk scores evaluated before the form renders need an explicit enforcement policy, exactly as with reCAPTCHA v3, because a score with no decision attached is telemetry.

Start with verification plus per-domain velocity limits. Both are measurable in Observe mode before you enforce anything, which means you learn what normal signup traffic looks like at your traffic levels rather than at a vendor's.

Trial eligibility abuse is a fraud pattern that anti-automation controls can address. Misleading billing or cancellation practices are a different problem entirely, usually a product and compliance one, and browser verification has no bearing on them. Keeping those two apart matters, because conflating them produces policies that punish legitimate customers for a problem they don't have.

How to Make Browser Actions Replay-Resistant

Synthetic example. A checkout route accepts an order request. The server issues a short-lived challenge bound to the cart contents, the session, and the specific action. The browser returns proof covering that challenge, the server verifies it against current state, marks the challenge consumed atomically, and rejects any second presentation. A retried request carries an idempotency key so the order is created once even if the network drops the first response.

Without that challenge, a captured request replayed by another caller looks almost exactly like a legitimate retry. The application can't separate them because it keeps no record of which proofs it has already accepted.

The turnstile is the right mental model. The ticket is checked once, and a ticket that already went through the gate doesn't work a second time.

NIST frames this as replay resistance: making successful authentication impractical when an attacker records and retransmits an earlier message. Its digital identity guidelines state that a verifier must accept a given authentication secret only once during its validity period, and that at least one authenticator at AAL2 must be replay-resistant. A memorized secret fails that test by design, because the password is submitted over and over.

The five checks a verifier runs

Check Reject when Why it matters
Expiry The challenge is past its short lifetime Bounds how long proof is usable
Consumption The same proof is presented a second time Stops a recorded request from being replayed
Action binding Proof for sign-in is used at checkout Prevents proof from one action authorizing another
Context match The session or account differs from the one issued Ties proof to the requester
Challenge freshness The challenge value is predictable or reused Keeps old messages from passing as current

These fail in production in predictable ways: a token validated for expiry but never marked consumed, a challenge derived from a timestamp and a user ID that makes it guessable, or proof bound to the user rather than the operation so a sign-in proof authorizes a checkout.

Replay checks and idempotency keys solve different problems. The challenge proves the request is fresh and unclaimed. The idempotency key guarantees the operation happens once even when the client retries. A system with only one of them is still exposed.

A valid proof also says nothing about whether the order was committed. Stock levels, price changes and payment authorization remain the application's job at the point of verification. The MANDATE research note on retries, replay and business outcomes covers where request integrity ends and operation recovery begins, which is the boundary that is often misunderstood on the first pass. For the attack side of this, see what a replay attack is.

Keep credentials opaque and short-lived, run current-state checks at the verification point, and reject client-supplied risk or authorization fields outright. A request that carries its own permission claim is a request you're trusting to be honest.

Roll Out Browser Verification in Observe Mode

Pick one route. Not the API surface, not the whole application. The route where abuse already shows in your logs, such as account recovery, sign-in or promotion redemption, is the one that pays for the work.

  1. Name one route and one action. "POST /api/login" is a scope. "Login security" isn't.
  2. Inventory the callers. Webhooks and machine APIs don't take part in a browser verification flow, so keep them outside browser-only coverage. Only routes whose callers can complete a browser flow belong in scope.
  3. Define the application event that means a legitimate request completed. A session created, an order committed, a reset email sent. Without that definition, Observe mode produces logs nobody can score.
  4. Run Observe mode. Evidence is recorded and proposed decisions are inspected, but nothing is enforced, so no legitimate user is affected.
  5. Review grouped evidence per action, not a single blocked count. Automated traffic you'd have caught matters less than legitimate-user impact you'd have caused.
  6. Enable enforcement on that route only, with a rollback path. One route, one policy, one switch you can turn off.

The gate before enforcement

  • Session hardening is in place from the earlier steps, so verification isn't compensating for a fixable session bug.
  • Rate limits run per account and per source, because verification doesn't replace throttling.
  • Idempotency keys guard every operation that must execute exactly once.
  • A written answer exists for verification unavailability, covering retries, whether the route fails open or closed, and the support path when a real customer is stuck.
  • The server credential stays on the server, out of logs, and is never treated as proof of success just because it's present.

OWASP's anti-automation guidance maps each action to a different control set, and the differences are wide enough that any single global policy will be too loose for checkout or too tight for sign-in.

Action Typical abuse Recommended controls
Login Credential stuffing Rate limiting, breached-password checks, MFA
Account creation Automated signup abuse Email or phone verification, velocity limits
Checkout and cart Scalping and carding Queues, purchase limits, 3-D Secure
Public API Key misuse and scripted calls API keys, per-key quotas, signed requests
Browser-originated high-value action Scripted browser abuse Observe-mode review, then enforcement on that route only, alongside the controls above

Browser verification doesn't establish human identity, doesn't catch every automated request, and doesn't replace MFA, authorization or payment-provider fraud controls. It's one more signal on a route where the consequences justify it. MANDATE runs this verification invisibly on browser-originated routes, with Observe mode available before enforcement and managed guards for Next.js and Express, and the integration pages are worth checking before planning around a specific SDK, since availability differs by integration.

Rollout rule: observe on one route, enforce on that route, then expand only after the evidence review changes someone's mind about the policy.

Test the flow the way you'd test any browser-dependent feature, and read up on the Claude Code browser testing limits before building a regression suite around it. Run Observe mode for a defined period, review results with product and support, then decide. A month of evidence on one route beats a global policy nobody on the support team can explain.


MANDATE verifies the browser behind sign-in, account recovery and checkout routes without showing a CAPTCHA, so a replayed or scripted request can be judged against current server state before your application acts on it. You can start in Observe mode, review grouped evidence for a single route, and enable enforcement only when the data supports it. Visit MANDATE to see how the hosted verification flow fits your stack.