How to detect credential stuffing

How to detect credential stuffing without blocking good users

Credential stuffing is distributed and automated. Detection requires signals across accounts, not just one user session. Here are the seven signals that actually work — with the logic to implement them.

What credential stuffing looks like in your logs

Credential stuffing is the automated testing of leaked username/password pairs from data breaches against your login endpoint. Because attackers use valid-looking credentials and try each account only once or twice, individual attempts look like a user mistyping a password. The attack is only visible in aggregate: many accounts, many sources, one coordinated pattern — a "low and slow" shape designed to stay under per-account rate limits.

That is why the naive defenses fail: blocking by IP misses rotating proxies, aggressive rate limiting punishes real users behind shared networks, and alerting on failure spikes only catches the clumsiest attacks. Detection has to correlate signals across accounts and sessions.

7 signals that detect credential stuffing

1. Failed-login velocity across accounts, not per account

Stuffing attacks test one password per account across thousands of accounts, so per-account rate limits never trip. Measure the sitewide failed-login rate and the number of distinct accounts attempted per source over a sliding window.

Example heuristic: more than 20 distinct usernames attempted from one source in 5 minutes, or sitewide failed-login rate above 3× the hourly baseline.

2. Rotating IPs sharing one device fingerprint

Botnets rotate residential proxies to defeat IP blocking, but the underlying automation often reuses the same TLS fingerprint, header order, or device signature across IPs.

Example heuristic: one fingerprint seen across 10+ IPs within an hour is automation, not a person.

3. Failure-rate spikes by ASN, country, or datacenter range

Group failed logins by network owner. Legitimate traffic fails at a fairly stable rate per network; stuffing traffic concentrates failures in datacenter ASNs and countries where you have few users.

Example heuristic: an ASN whose failure rate jumps from ~10% to 80%+ is sourcing an attack, even if total volume looks modest.

4. Bursts during low-activity hours

Attackers schedule runs when fraud teams sleep and traffic baselines are low. A burst of login attempts at 4am local time stands out against your normal diurnal curve.

Example heuristic: login attempts above the 99th percentile of the same hour-of-week baseline.

5. Breached-credential matches

Stuffing lists come from public breaches. Checking submitted passwords against known-breached corpora (the Have I Been Pwned k-anonymity API) tells you an attempt is using leaked data even when everything else looks clean.

Example heuristic: a spike in logins using breached credentials — successful or not — means your user list is in an active combo list.

6. Atypical user agents and headless markers

Automation frameworks leak: outdated or impossible user-agent strings, missing Accept-Language headers, headless browser properties, and request cadence too regular to be human.

Example heuristic: identical millisecond-regular submission intervals across "different users" is a bot cadence signature.

7. Account-lockout spikes as a lagging indicator

A sudden rise in lockouts, password resets, or "was this you?" support tickets means an attack is already underway. It is the cheapest alert to wire up — but it fires after the attack starts, so treat it as a tripwire, not a defense.

Example heuristic: alert when hourly lockouts exceed 5× the trailing 7-day average.

Detection logic you can implement today

The highest-value signal is cross-account velocity. This is the core of it — a sliding-window counter of distinct usernames per source:

stuffing-score.ts
// Cross-account velocity score — the core stuffing signal.
// Runs on every failed login; keyed by source (IP or device fingerprint).
const WINDOW_MS = 5 * 60 * 1000;

async function stuffingScore(source: string, username: string) {
  await redis.zadd(`fails:${source}`, Date.now(), `${username}:${Date.now()}`);
  await redis.zremrangebyscore(`fails:${source}`, 0, Date.now() - WINDOW_MS);

  const attempts = await redis.zrange(`fails:${source}`, 0, -1);
  const distinctUsers = new Set(attempts.map((a) => a.split(':')[0])).size;

  // Many distinct accounts from one source = stuffing, not a forgotten password.
  if (distinctUsers > 20) return 'block';
  if (distinctUsers > 5) return 'challenge';
  return 'allow';
}

Why this gets hard at scale

  • • Attackers distribute attempts across thousands of residential proxy IPs to stay under any per-source threshold.
  • • CGNAT and mobile networks put thousands of real users behind one IP, so aggressive per-IP rules block legitimate customers.
  • • Bots adapt to static rules within days; thresholds need continuous re-tuning against your real traffic.
  • • The cross-account context has to be computed in the login path itself — batch jobs find attacks hours late.

Build vs buy

The velocity counter above is a solid first tripwire, and for a small site it may be enough. The parts that are not worth building yourself are the data feeds: IP and proxy reputation, breached credential corpora, device fingerprint intelligence, and bot cadence models all require continuous upkeep. That is the line where buying beats building.

LoginLlama covers the IP and history side behind one call at the login step: IP and proxy reputation, each user's own devices and places, and failed attempts counted across accounts. You get a 0–10 risk score with reason codes, and it fails open by design:

Login check
curl -X POST https://loginllama.app/api/v1/login/check \
  -H "X-API-KEY: $LOGINLLAMA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/vnd.api+json" \
  -d '{
    "identity_key": "[email protected]",
    "ip_address": "203.0.113.42",
    "user_agent": "python-requests/2.31.0"
  }'

# Response: {"status":"success","risk_score":9,
#   "codes":["ip_address_suspicious","known_bot"]}
# risk_score above 5: challenge or block the login.

Comparing products? See our guide to credential stuffing detection software.

Credential stuffing detection FAQ

How do I detect credential stuffing attacks using IP signals?

Group login attempts by IP address, ASN, and network type. The three strongest IP signals are: failure-rate spikes concentrated in a single ASN or country; traffic from datacenter, VPN, proxy, or TOR ranges hitting your login endpoint (real users rarely log in from datacenters); and many distinct usernames attempted from one IP in a short window. Combine them — a datacenter IP with an 80% failure rate across 30 usernames is unambiguous.

What is the difference between credential stuffing and brute force?

Brute force tries many passwords against one account, so per-account rate limits and lockouts stop it. Credential stuffing tries one known-leaked password per account across thousands of accounts — each account sees a single plausible attempt, so per-account defenses never trigger. Detection has to correlate activity across accounts, which is why cross-account velocity is the core stuffing signal.

Can rate limiting stop credential stuffing?

Per-account or per-IP rate limiting alone cannot. Attacks are distributed across thousands of IPs with one attempt per account, staying under every individual limit. Rate limiting is still worth having as a baseline defense, but stopping stuffing requires cross-account signals: shared device fingerprints, ASN failure rates, breached-credential matches, and bot cadence detection.

What are the best credential stuffing detection tools?

For most engineering teams the choice is between enterprise bot-mitigation platforms (Arkose, Kasada, DataDome) that sit in front of your traffic, and login-focused risk APIs. LoginLlama takes the API approach: one call at the login step returns a 0–10 risk score with reason codes covering IP reputation, device history, velocity, and bot markers — no traffic re-routing or sales cycle required.