Prompt
I want to harden a SaaS app against token theft, account takeover, and insecure integrations. What are the most important fixes?
Latest observation
Oct 23, 2026
OpenAI APIWeb search: off
Here are the highest-value fixes, prioritized for token theft, account takeover (ATO), and insecure integrations in a SaaS app.
1) Make stolen tokens much less useful
Goal: reduce replay value and blast radius.
- Short-lived access tokens
Keep access tokens brief (often 5–15 minutes). - Rotate refresh tokens on every use
If a refresh token is reused, treat it as theft and revoke the whole session family. - Bind tokens to the client/device when possible
Use sender-constrained tokens such as DPoP or mTLS for high-risk APIs. - Use secure storage on clients
- Browser: prefer HttpOnly, Secure, SameSite cookies over localStorage for session tokens.
- Mobile/desktop: use platform secure storage/keychain/keystore.
- Limit token scope
- Least privilege scopes
- Separate tokens for user actions vs API integrations
- Separate admin vs standard user sessions
- Session revocation everywhere
- Single-click logout all devices
- Revoke refresh tokens, API keys, and active sessions on password change / MFA reset / suspicious activity
2) Harden authentication against account takeover
Goal: make credential abuse and session hijack much harder.
- Require MFA
- Best: passkeys/WebAuthn
- Good fallback: TOTP
- Avoid SMS as primary factor
- Protect login with risk controls
- Rate limit and bot protection
- IP / device / geo anomaly detection
- Step-up auth for risky logins, password changes, API key creation, payout/admin actions
- Block credential stuffing
- Login throttling
- Breach-password checks
- Detection for impossible travel, repeated failures, credential spray patterns
- Secure password handling
- Strong password hashing: Argon2id (or bcrypt/scrypt with good parameters)
- Unique salt per password
- Enforce password reset on known compromised credentials
- Fix recovery flows
- Secure email reset links with short TTL and one-time use
- Re-authenticate before changing MFA, email, or recovery methods
- Protect support-assisted account recovery from social engineering
- Harden admin and support accounts
- Separate admin identities
- MFA required
- Just-in-time elevation
- Audit every privileged action
3) Secure integrations and API access
Goal: prevent third-party apps, API keys, and webhooks from becoming a backdoor.
- Use OAuth correctly
- Prefer Authorization Code + PKCE
- Avoid implicit flow
- Use exact redirect URI matching
- Validate
stateand PKCE verifier
- Minimize integration privileges
- Fine-grained OAuth scopes
- Per-integration permissions
- Tenant/org-level approval for high-risk scopes
- Treat API keys like secrets
- Show once
- Store hashed if possible
- Allow rotation and revocation
- Scope and expire them
- Prefix keys for identification
- Secure webhooks
- Sign payloads
- Use timestamped signatures to prevent replay
- Allowlist destinations where appropriate
- Retry safely and idempotently
- Harden outbound/inbound integration endpoints
- Strict validation of redirect/callback URLs
- SSRF protections for URL-fetching features
- Don’t trust metadata from third-party systems without verification
- Tenant isolation
- Never allow integration tokens from one tenant to access another
- Enforce authorization server-side on every request
4) Reduce blast radius if something is stolen
Goal: make compromise containable.
- Least privilege everywhere
- Users, services, integrations, internal staff
- Segment sensitive actions
- Separate permissions for export, billing, admin, and secrets access
- Device/session management
- Visible active sessions
- Per-device revoke
- Alerts for new device login
- Secret management
- Put app secrets in a vault/KMS
- Rotate regularly
- Never ship secrets in frontend code or mobile binaries if avoidable
- Audit logging
- Login events, token issuance, refresh, revocation
- API key creation/use
- MFA changes, recovery changes, permission changes
- Export/download events
- Keep logs tamper-evident
5) Fix common web and app weaknesses that lead to token theft
Goal: close the usual paths attackers use.
- Stop XSS
- Output encoding
- Content Security Policy (CSP)
- Avoid dangerous DOM sinks
- Sanitize rich text
- CSRF protection
- SameSite cookies plus CSRF tokens for state-changing requests
- Secure cookie settings
HttpOnly,Secure,SameSite=LaxorStrictwhen possible- Tight cookie domain/path scoping
- Prevent clickjacking
frame-ancestorsCSP orX-Frame-Options
- Patch dependency and supply-chain risks
- Lockfiles, SCA, signed builds, review third-party scripts
- Server-side authorization checks
- Never rely on frontend-only permission checks
6) Monitoring and response
Goal: catch theft early and respond quickly.
- Alert on suspicious auth events
- New geo/device
- Refresh token reuse
- API key creation spikes
- MFA disable/reset
- Automated containment
- Revoke sessions on high-confidence compromise
- Force step-up auth
- Temporary lock on suspicious flows
- Incident playbooks
- Token theft
- OAuth client compromise
- Support account abuse
- Webhook secret leakage
If you only do 10 things first
- Use passkeys/WebAuthn with MFA fallback
- Switch browser auth to HttpOnly Secure SameSite cookies
- Make access tokens short-lived
- Add refresh token rotation + reuse detection
- Implement strict logout/revocation for sessions and API keys
- Enforce Authorization Code + PKCE for OAuth
- Hash and scope API keys; allow rotation/revocation
- Add rate limits, bot defense, and credential-stuffing detection
- Fix XSS/CSRF and set a strong CSP
- Build audit logs + alerts for auth/integration changes
If you want, I can turn this into a concrete hardening checklist for:
- a browser-based SaaS
- a mobile app
- an API-first platform
- or an OAuth/integration-heavy product.