Most teams add login, MFA, and session management, then ship. But attackers dont always break in with obvious exploits. They log in like real userswith real credentialsand then drain value quietly. Thats account takeover (ATO). You wont catch it with a strong password policy alone.
This article walks through how to design ATO detection and response for SaaS: what signals to collect, how to model them, how to score risk, and concrete, low-friction responses that protect users without locking out legitimate ones. Youll also see how to build the essential dashboards and workflowsand how to iterate safely.
Start with the threat model, not the tool
ATO involves an attacker successfully authenticating as a real user. Entry vectors include credential stuffing, reused passwords from unrelated breaches, social engineering, phishing, malware on a device, or API key leakage. Because sign-in completes, it looks like normal activity unless you analyze context and behavior.
Your ATO posture should answer three questions:
- What would an attacker do if they were in? (Change payout info, export data, create API keys, invite collaborators, turn off alerts.)
- What signals reliably distinguish an attacker from a legitimate user? (New device, impossible travel, unusual IP ASN, atypical API usage.)
- What is a safe, minimally disruptive response? (Step-up auth, limited quarantine, user notifications, session review.)
Signals worth tracking from day one
You dont need a data science team to spot high-signal anomalies. Start with these:
1) Authentication context
- New device vs known device fingerprint
- New browser, OS, or app version
- New or unusual IP address, ASN, or country
- Geographic distance since last login (impossible travel)
- Time-of-day patterns (e.g., sudden 3am logins when a user normally logs in at noon local time)
- Auth method changes (password-only after months of passkey use, or recovery code usage)
2) Session and token behavior
- Multiple parallel sessions from distant geos
- Rapid token refresh attempts or abnormal token lifetimes
- OAuth access by unfamiliar third-party clients
3) Application activity
- Bulk export or download bursts
- Mass changes to access controls, API keys, or webhooks
- Updates to payout/billing destinations
- Disabling security measures (e.g., removing MFA, turning off alerts)
4) API usage anomalies
- High error rates indicating probing
- Spikes in privileged endpoints
- New IPs hitting API keys never seen from those IPs
Collect these signals as structured events. Dont block at the first whiff of oddness; combine signals into a risk score before you act.
Model the data: keep it simple and queryable
You want to query his this login unusual for this user? and which sessions should be challenged, not killed? quickly. Start with clear entities and append-only events.
{ "users": [ { "id": "u_...", "email": "...", "mfa_enabled": true, "created_at": "..." } ], "devices": [ { "id": "d_...", "user_id": "u_...", "fingerprint": "hash", "first_seen": "...", "last_seen": "...", "trust_level": "trusted|new|blocked" } ], "sessions": [ { "id": "s_...", "user_id": "u_...", "device_id": "d_...", "ip": "203.0.113.7", "asn": 64500, "country": "US", "created_at": "...", "last_activity": "...", "mfa_level": "none|sms|totp|passkey", "risk_score": 18, "status": "active|challenged|revoked" } ], "auth_events": [ { "id": "ae_...", "user_id": "u_...", "type": "login_success|mfa_challenge|password_reset|device_trust_change", "session_id": "s_...", "ip": "...", "metadata": {"device_fingerprint":"...","geo_distance_km": 6900}, "ts": "..." } ], "risk_events": [ { "id": "re_...", "user_id": "u_...", "session_id": "s_...", "signals": ["new_device","impossible_travel"], "score": 42, "state": "open|mitigated|false_positive", "ts": "..." } ] }Use append-only events for auditability. For mutable state (e.g., session status), store it in a current-state table and derive it from events when rebuilding.
Risk scoring: rules first, ML later (maybe)
A transparent rules engine is fast to implement and easy to tune. Assign weights to signals, then sum and normalize. Keep it interpretable so support can explain actions to users.
{ "rules": [ { "signal": "new_device", "weight": 15 }, { "signal": "new_country", "weight": 15 }, { "signal": "impossible_travel", "weight": 25 }, { "signal": "untrusted_asn", "weight": 10 }, { "signal": "bulk_export_burst", "weight": 20 }, { "signal": "mfa_downgrade", "weight": 25 } ], "thresholds": { "monitor": 15, "challenge": 30, "quarantine": 50 } }Examples:
- Score 18: mark session as low risk, continue but record a risk event for monitoring.
- Score 35: require step-up authentication before allowing sensitive actions.
- Score 55: temporarily restrict critical operations (exports, payout changes) and notify the user and your team.
You can add machine learning later for personalization (e.g., per-user baseline models), but rules cover the majority of impactful cases and avoid black box surprises.
Design responses that protect users without punishing them
Not every anomaly is malicious. Structure responses by risk tier.
Tier 1: Observe and inform
- Show a non-blocking banner: We noticed a new device sign-in from City, Country.
- Send an email with a clear This was me / Not me action.
- Add the device to a pending state until user confirms.
Tier 2: Step-up authentication (challenge)
- Prompt for MFA/passkey before sensitive actions (exports, billing, API key creation).
- Gate risky endpoints behind a fresh challenge within the last N minutes.
Tier 3: Quarantine and contain
- Restrict critical actions (no exports, no role changes, no payout edits) until verification completes.
- Revoke suspicious sessions but keep trusted ones active to reduce lockouts.
- Require OOB verification (e.g., confirm code sent to email/phone or support-verified callback for high-value accounts).
Always provide a path to resolution
- Offer This was me to upgrade trust on the device and remove restrictions.
- Offer Not me to immediately revoke all sessions except the current trusted one, rotate tokens, and force MFA enrollment if not enabled.
Secure the high-impact moments
Protect flows attackers crave. Require a recent step-up challenge (e.g., MFA within last 5 minutes) for:
- Changing email, password, or recovery methods
- Disabling MFA or adding a weaker factor
- Creating or rotating API keys
- Exporting bulk data
- Changing payout or bank info
- Promoting users to admin roles
Enforce this with server-side checks; the client cannot be trusted to gatekeep.
Build the operational cockpit
ATO defense isnt just rules; its operations. Give support and security staff tools to investigate and act quickly.
- Risk event queue with filters (score, signals, segment, time)
- User timeline: auth events, device history, location changes, sensitive actions
- Bulk actions: revoke sessions, rotate API keys, invalidate tokens
- Notes and state transitions: open, mitigated, false positive (with reason)
- Exportable audit trail for compliance
Example payload for a risk event, designed for clear review:
{ "id": "re_72af...", "user": {"id": "u_9c2...", "email": "ops@example.com"}, "session": {"id": "s_1b3...", "ip": "203.0.113.7", "country": "DE", "device": "Chrome 126 / macOS"}, "signals": [ {"type": "new_device", "weight": 15}, {"type": "impossible_travel", "weight": 25, "details": {"from": "US", "to": "DE", "minutes": 35}}, {"type": "mfa_downgrade", "weight": 25} ], "score": 65, "recommended_action": "quarantine", "ts": "2026-07-21T10:02:54Z" }Notifications that reduce panic, not cause it
Users need clarity during a scare. Keep messages short, specific, and actionable. Include geolocation, device, and time. Provide two safe buttons.
Subject: New sign-in on a new device: Berlin, Germany We noticed a sign-in to your account. - When: 10:02 UTC, Jul 21 - Where: Berlin, Germany (approx.) - Device: Chrome 126 on macOS If this was you, confirm the device to avoid future challenges: [This was me] If this wasnt you, secure your account now: [Not me] Well keep sensitive actions restricted until you confirm.
Testing your detection without waiting for attackers
Build repeatable drills:
- Simulate a sign-in from a new country within 30 minutes of a domestic sign-in.
- Perform a bulk export immediately after a password reset.
- Attempt to disable MFA from a new device and ensure step-up auth triggers.
- Generate an access token from an unknown OAuth client and verify a challenge fires.
Capture expected vs actual results in a test matrix. Run these in staging and against a seeded sandbox account in production (with test-only export limits) to validate end-to-end alerting, UI, and email templates.
Edge cases and pitfalls to avoid
- Roaming users and VPNs: focus on consistency for that user rather than global good/bad IP reputation. ASN and historical use are more helpful than VPN==bad.
- Device fingerprint drift: browsers update; dont overreact to minor changes. Use fuzzy matching and a trust decay model.
- Overzealous revocation: dont nuke all sessions for a medium score. Prefer targeted challenges and quarantines.
- Silent failures: alert your team when quarantine or revocation actions fail, and fall back safely.
- Privacy: collect only what you need, be transparent, and retain data for a defined, justified period.
Implementation checklist
- Event capture: login_success, mfa_challenge, password_reset, device_trust_change, export_started, api_key_created, payout_change
- Session model with risk_score and status
- Device model with trust_level and last_seen
- Geo/IP/ASN enrichment service (pluggable)
- Rule engine with thresholds and explanations
- Step-up auth middleware for sensitive routes
- User-facing device manager and security log
- Admin risk queue and runbook links
- Notifications with This was me/Not me actions
- Playbooks and drills; on-call alerting for quarantine events
Server-side enforcement: keep the gate on the backend
Wrap sensitive endpoints with risk checks. Example pseudocode:
function requireRecentStepUp(session, withinMinutes = 5) { if (session.mfa_level === 'passkey' && session.mfa_verified_within <= withinMinutes) return; if (session.last_step_up < now() - minutes(withinMinutes)) { throw ChallengeRequiredError('Fresh verification required'); } } function guardSensitiveAction(req, res, next) { const session = getSession(req); if (session.risk_score >= THRESHOLDS.quarantine) return res.status(423).send('Account temporarily restricted'); if (session.risk_score >= THRESHOLDS.challenge) return res.status(401).send('Step-up required'); requireRecentStepUp(session, 5); next(); }Expose controls to customers (and reduce support tickets)
Give users a security center:
- Active sessions list with revoke buttons
- Trusted devices list with remove capability
- Recent security events with clear timestamps and locations
- MFA management, recovery codes, passkey registration
Integrations: route critical signals where people work
Forward high-severity events to your internal channels for rapid response:
{ "type": "risk.quarantine.applied", "user_id": "u_...", "session_id": "s_...", "score": 71, "signals": ["new_device","new_country","bulk_export_burst"], "recommended": ["revoke_sessions_except_trusted","require_oob_verification"], "ts": "..." }Send to your incident channel and SIEM. Automate playbook links based on event type.
Using YeshBe to build the ATO workflow faster
YeshBe is a platform for building software by describing what you want in natural language and iterating through conversation with AI. You can build the ATO data model, risk rules UI, and enforcement middleware without starting from a blank codebase.
Build an admin Risk Events dashboard showing open, mitigated, and false-positive items. Each row displays user, score, signals, current session status, and quick actions: Require step-up, Revoke sessions, Mark false positive. Add filters by score, signal, and created date.
Create a Security Center page for users: list active sessions (device, IP, last activity) with revoke buttons; show trusted devices with remove option; display recent security events; and provide MFA/passkey enrollment.
# Risk rule configuration editor Create an interface for security admins to manage ATO rules. - Fields: signal (select), weight (0-50), description (text) - Thresholds: monitor, challenge, quarantine - Preview: input a hypothetical event and compute score + recommended action - Persist rules as JSON and hot-reload without redeploy
Add middleware to sensitive routes that checks session risk score and requires a recent MFA challenge within 5 minutes. If not met, return a structured error the client can handle to trigger the step-up flow.
Iterate: ask the AI to add impossible travel detection, enrich IPs with ASN using your provider, then simulate scenarios to verify notifications and UI responses end-to-end.
Measuring success
- Percentage of high-score events resolved with step-up instead of full lockouts
- Time-to-mitigation from detection to quarantine release
- False positive rate (events marked legitimate)
- Adoption of MFA/passkeys after risk prompts
- Reduction in sensitive-action abuse following deployment
When to tighten, when to relax
Start with monitor-level thresholds and clear audit logs. As you learn your products normal patterns, raise enforcement for the top 23 high-signal combinations. Review false positives weekly and adjust weights. Consider per-tenant baselines for large customers with distinct behavior profiles.
Wrap up
ATO detection isnt an on/off switch. Its a set of small, composable capabilities: capture the right signals, score them transparently, choose proportional responses, and give people tools to resolve incidents quickly. You can build this step by stepand your users will feel the difference the first time something odd happens and your product helps them stay safe without getting in the way.