Account takeover prevention and recovery after a suspicious login

Decide when to challenge a sensitive change, revoke sessions and recover an account. Follow a suspicious login from the first alert through owner verification.

A table from this post: Tell, Field / reason code, Weight at a login.
From this post: the table of takeover tells and their reason codes.
In short
  • Pause sensitive changes when a new sign-in is followed by a recovery-email or payout change. Ask for a factor already enrolled on the account.
  • When the owner reports a compromise, revoke server-side sessions and refresh tokens, review changes and contact the owner through a previously verified channel.
  • Record the login and subsequent actions on one timeline. A pending transfer and a settled payment need different responses.
On this page
  1. What to do after a suspicious successful login
  2. How to read the account history
  3. The tells, and what each one is worth
  4. Where the check goes: lookup, evaluate, then compare
  5. The response ladder
  6. What it costs you
  7. Checklist

A customer reports an email-change notice they never requested. Your logs show a successful login and a new payout destination six minutes later. Which action can you still stop, which sessions are active, and how can the customer reach you through a channel they still control?

What to do after a suspicious successful login

Start with the action the session is trying to take. A new device alone is common. A new device followed by a change to the recovery email or payout destination warrants a fresh identity check before that change takes effect.

What you knowWhat to do nowHow to check it worked
A customer signed in from an unfamiliar device.Send a sign-in notice to an established contact. Require a previously enrolled factor before changing recovery details or moving money.A legitimate customer can confirm the action. The pending change stays on hold until that check succeeds.
The customer denies a sign-in or a recovery change.Hold pending payouts and contact changes. Revoke active sessions and refresh tokens on the server. Record the affected session IDs and action times for review.The old sessions can no longer read the account or obtain fresh tokens. A held payout has not been released.
The owner has completed your recovery process.Review recovery addresses, phone numbers and enrolled factors with them. Remove unauthorized additions, reset compromised credentials and notify the owner through a previously verified channel.The owner signs in afresh with a factor they control. The account history shows which changes were reversed and which completed transactions still need investigation.

A recently changed email address is a poor place to send the only recovery link. If the owner has lost access to all established contacts, use your documented assisted-recovery process. OWASP’s account recovery guidance covers session invalidation, MFA review and notifying the legitimate user.

Try it on your own forms

One call before signup, login or checkout returns allow, review or block; the Free plan includes 10,000 visitor checks a month with no card, and setup starts in watch mode, which logs every decision and blocks no one until you turn blocking on.

How to read the account history

For example, a sign-in at 09:04, a recovery-email change at 09:06 and a payout request at 09:10 belong on one timeline. Join them using the account and session identifiers. Check which contact received the notice, which factor authorized the change and whether the transfer is pending or settled. Those details determine whether you can stop the transfer or need to start a payment investigation.

If your logs show repeated failed attempts across many accounts before a session exists, use the credential-stuffing detection guide for pre-login controls. The rest of this guide covers the signals you can carry into a session and the checks to repeat before a sensitive action.

The tells, and what each one is worth

A verdict from /v1/evaluate carries a network block and, when the client SDK's event id was forwarded, a device block. "Engine default" below is the decision with no custom rules: a residential proxy, Tor, automation, emulator or antidetect signal each produce block alone, a VPN alone produces review, a datacenter exit alone stays allow. Why the decision and the score are separate axes explains the split.

TellField / reason codeWeight at a login
One device, many accountsdevice.linked_accounts, device.multi_account / multi_account_deviceEvidence at 2 or 3; block in double digits
Never-seen device on an established accountdevice.times_seen: 1, device.first_seen, device.returning: falseStep-up, never block alone
Browser misrepresents its enginedevice.antidetect / antidetect_browserBlock (engine default)
Scripted browserdevice.automation / automation_detectedBlock (engine default)
Residential proxy exitnetwork.proxy / proxy_detectedBlock (engine default); network.residential is a route, not a clearance
Tor exitnetwork.tor / tor_exit_nodeBlock (engine default)
Datacenter exitnetwork.datacenter / datacenter_asnEvidence; step-up with a second tell; exempt relay ranges
Consumer VPNnetwork.vpn / vpn_detectedEvidence on a returning device; step-up on a first-seen one
Clock disagrees with the exit countrytimezone.matches_ip: false with timezone.checked: true / timezone_mismatchStep-up; never blocks alone
Same device or account, many attemptsYour own counters (below), not an API fieldStep-up; block when it agrees with a device tell

Where the check goes: lookup, evaluate, then compare

Three things have to be true at once: you know which account is claimed, you have not spent a password verification, and you have issued nothing. That window is after the account lookup and before the hash compare. For an Express app, suspicious login detection in Node.js wires the check into the login route with the SDK.

Login handler order: account lookup, then evaluate, then hash compare 1. look up the account email → accountId 2. POST /v1/evaluate token + accountId 3. bcrypt.compare only if step 2 did not refuse linked_accounts exists here, and no hash round has been spent
Step 1 supplies the accountId step 2 needs; step 2 decides whether step 3 runs.

Ordering it that way buys two things. Passing the claimed accountId with the event id links the device to every account it tries, right password or not, and returns the count as device.linked_accounts, both stored as one-way hashes; that is why the worked model's ring shows within minutes. And refusing before the compare means the operator cannot make you pay for a hash per attempt. The hash is slow on purpose — the OWASP password storage cheat sheet (checked 2026-08-30) puts bcrypt's minimum work factor at 10 — so five thousand free compares is a small denial of service.

javascript
// POST /login: lookup, evaluate, then compare. Express + bcrypt.
// sentinel_* inputs come from the client SDK, which keeps the product's original name.
app.post('/login', async (req, res) => {
  const user = await users.findByEmail(req.body.email);          // 1. lookup
  const v = await evaluateLogin(req, user);                      // 2. evaluate; null on timeout
  if (!v) degraded.inc();
  const flags = await velocity(req, user, v);

  const ring = (v?.device?.linked_accounts ?? 0) >= 10;
  if (v?.decision === 'block' || ring) {
    return res.status(401).json(LOGIN_FAILED);                   // same body as a wrong password
  }

  const hash = user?.hash ?? DUMMY_HASH;                         // unknown email costs the same time
  const ok = await bcrypt.compare(req.body.password, hash) && user; // 3. compare
  if (!ok) return res.status(401).json(LOGIN_FAILED);

  const firstSeen = v?.device?.times_seen === 1;
  const vpnOnly = v?.reasons?.length === 1 && v.reasons[0] === 'vpn_detected';
  const reviewed = v?.decision === 'review' && !(vpnOnly && v.device?.returning);
  if (reviewed || firstSeen || flags.length || !matchesHistory(user, v)) {
    return res.json({ next: 'step_up', challenge: await startWebAuthnOrOtp(user) });
  }
  return res.json({ session: await sessions.create(user, v) });
});

async function evaluateLogin(req, user) {
  try {
    const r = await fetch('https://maskbreak.com/v1/evaluate', {
      method: 'POST',
      signal: AbortSignal.timeout(800),
      headers: { Authorization: 'Bearer sk_test_YOUR_TEST_KEY', 'Content-Type': 'application/json' },
      body: JSON.stringify({
        token: req.body.monocle,                  // network half: hidden input the client SDK adds
        fingerprintEventId: req.body.sentinel_fp, // device half: unlocks device.*
        accountId: user?.id,                      // required for device.linked_accounts
        tz: req.body.sentinel_tz,                 // adds the timezone block
      }),
    });
    return r.ok ? await r.json() : null;
  } catch {
    return null;                                  // fail open: "no opinion", never "safe"
  }
}

There is no ip field in that body: the address comes from the token, the device from the event id, and every read is optional-chained because the function returns null on a timeout. Test the routing first. The public sk_test_sandbox key answers test_clean, test_vpn, test_proxy, test_datacenter and test_tor with deterministic shapes, and your own sk_test_ key runs the full pipeline without billing or webhooks.

Velocity is the part you have to build

An evaluation describes one request. It cannot tell you the same device just tried forty accounts, because it does not know what your last forty requests looked like. That correlation is yours, and the key you count on decides whether it works: per IP, the pool gives every attempt a fresh address and the counter never fills. Count on what does not rotate.

javascript
const LIMITS = { device: 20, account: 10, ip: 30 };   // per 15 min; tune from your own logs

async function velocity(req, user, v) {
  const flags = [];
  for (const [kind, value] of [['device', v?.device?.visitor_id], ['account', user?.id], ['ip', req.ip]]) {
    if (!value) continue;
    const key = `login:${kind}:${value}`;
    const n = await redis.incr(key);
    if (n === 1) await redis.expire(key, 900);
    if (n > LIMITS[kind]) flags.push(`velocity_${kind}`);
  }
  return flags;
}

The device ceiling should sit high enough that a household sharing one laptop never reaches it. Telling a household from a resale is the same judgment from the other side: one account on many devices there, one device on many accounts here.

What "normal for this account" means

History turns a generic verdict into one about the person logging in. Store three things on every successful login: device.visitor_id, country and the hour. A login matching all three is boring; one matching none, on an account that has logged in from the same city for two years, earns a second factor even when every signal is clean. That is matchesHistory().

Read the geographic tell with care. timezone.matches_ip looks like the perfect signal until you read timezone.checked: on a VPN, proxy, Tor or datacenter exit a mismatch is expected and the API raises nothing. When checked is false, the mismatch describes the tunnel, not the person.

Check sensitive account changes again

For an email, phone, password or payout change, evaluate a fresh token from that page and use the account ID from the authenticated session. Compare the resulting device information with the sign-in record. If the device has changed or the customer reports unexpected activity, follow the containment and recovery steps before applying the change.

The response ladder

A blanket block on anything unfamiliar strands real customers, and a blanket allow is where you started. Three outcomes, with the middle one doing most of the work.

OutcomeEvidence it needsWhat the customer sees
Allowdecision: allow, device.returning: true, history matches, no counter tripped. A returning device with vpn_detected as its only reason lands here too.Nothing. This is most logins.
Step upAny one of: decision: review, times_seen: 1, a velocity flag, a history mismatch, timezone_mismatch with checked: true, a datacenter exit plus a second tell.A second factor: a passkey first, which NIST classes as phishing-resistant, then OTP.
Blockdecision: block, or independent tells agreeing: a proxy exit plus a first-seen device plus a velocity flag. One tell blocks alone only when it is linked_accounts in double digits, because that is not a proxy for the attack, it is the attack.The same failure response as a wrong password.

The last cell is not a detail. A refusal never reads the password, so it cannot leak which pairs were valid; what a distinguishable refusal leaks is that a defense fired, a cue to rotate exits and retry — hence the same failure shape as a wrong password. On the path that does read it, the OWASP authentication cheat sheet (checked 2026-09-01) prescribes one generic response "regardless of whether: The user ID or password was incorrect. The account does not exist. The account is locked or disabled" and warns that a processing-time gap between those cases lets an attacker "mount a time-based attack"; the handler's DUMMY_HASH is that advice applied.

Two exemptions belong in the ladder before it goes live. The first is privacy relays. Apple's guidance for web servers on iCloud Private Relay (checked 2026-08-30) publishes the egress ranges as a CSV and asks operators to treat them "like larger carrier-grade NAT or enterprise IP addresses". An exit on that list is a customer on an iPhone and should never reach the block tier on network evidence. The engine already treats a relay it recognises that way: since 2026-10-10 it answers review with the reason privacy_relay (and network.privacy_relay: true) instead of blocking it as a proxy, so on its own the relay lands in the step-up tier. The second is the shared machine: a family laptop, an office desktop, a refurbished phone, each linked to a few accounts legitimately. That is why linked_accounts at 2 or 3 is noise and double digits is a finding.

Fail open, and alert on the rate. Login is availability-critical in a way signup is not; fail closed on a vendor timeout and you have locked out every customer at once. Let the login proceed, mark it degraded, and alert on the proportion of degraded logins in a window. Store reasons and risk_score on the attempt record; when you ask later whether the step-up tier is too tight, the reason codes are the only thing that can answer.

What it costs you

The step-up has a list price. Twilio Verify (checked 2026-08-30) charges $0.05 per successful verification plus the channel fee, $0.0083 per US SMS. A passkey challenge costs nothing per use. As a worked model, a service stepping up 2,000 logins a day by SMS pays about $117 a day; over passkeys, nothing. That budget is why the tier fires on evidence rather than on everything unfamiliar; send codes to whoever asks and SMS pumping is that invoice, driven on purpose.

The takeover you did not stop has a list price too. Stripe's dispute fee schedule (effective 2025-06-17, checked 2026-08-30) sets the dispute received fee at $15 in the US and €20 in Estonia; the disputes documentation says that outside Mexico "the fee for receiving a dispute is non-refundable", with a further $15 or €20 to counter, returned only on a win. A stored card used from a taken account produces exactly that dispute. The refused-attempt hash compares and the "I did not change my email" support tickets appear on no invoice; the two costs that do are worth knowing.

Checklist

  • Revoke sessions and refresh tokens on confirmed compromise. Review recovery contacts with the verified owner and notify them through an established channel.
  • Account lookup, then /v1/evaluate, then the password compare. Refuse before the hash.
  • accountId and the device event id both sent, or device.linked_accounts never appears; tz forwarded.
  • Velocity counted on visitor_id and account before IP; the counter that tripped is logged.
  • Step up on review, first-seen devices and history mismatches; block on agreement or a double-digit device ring.
  • vpn_detected alone on a returning device changes nothing; timezone.matches_ip read only when checked is true.
  • Route on device.antidetect and the reason code, never on tampering_score.
  • Private Relay ranges and shared machines exempted from the block tier; the same failure shape for a wrong password and for a refusal.
  • Email, phone, password and payout changes evaluated with the same call; fail open, mark degraded, alert on the rate. The engine defaults these routes rely on are in the API reference, and the sandbox tokens are never counted against a plan.

Questions people ask

What should I do if a customer reports an account takeover?
Hold pending sensitive changes, revoke active sessions and refresh tokens, and use your established recovery process to verify the owner. Review enrolled factors, recovery contacts and recent transactions with them before restoring access.
How do you detect account takeover before the login succeeds?
Run the evaluation between the account lookup and the password compare, with the claimed accountId and the device event id in the request. The verdict then carries device.linked_accounts, times_seen and the network class, and because every attempt links the device to the account it claimed, a device working a stolen list shows a rising count before any password succeeds.
Should I block logins from a VPN?
Not on a device the account has used before. A consumer VPN alone returns decision review and vpn_detected, which is ordinary privacy hygiene on a returning device. Treat it as evidence, step up when the device is first-seen or a counter has tripped, and block only when independent tells agree, such as a proxy exit plus a new device plus velocity.
Does MFA stop credential stuffing?
It stops most of it. NIST SP 800-63B classes OTP and out-of-band codes as not phishing-resistant, so a real-time phishing page can relay them; passkeys and security keys are the phishing-resistant option. MFA belongs in the ladder as the step-up, and the evaluation decides when to ask, so most customers never see it.
What is the difference between credential stuffing and account takeover?
Credential stuffing means trying previously exposed credentials at another service. Account takeover means someone gains unauthorized control of an account. A compromised session or recovery channel can also lead to takeover.

Put the check where the attack enters

One call before signup, login or checkout returns decision, risk_score and the reasons behind them. The Free plan includes 10,000 visitor checks a month with no card, and setup starts in watch mode, so nothing is blocked until you turn blocking on.

Get started freeRead the API docs