Auth0 anomaly detection

Auth0 anomaly detection with a single Action.

Keep Auth0 as your identity provider and add real-time anomaly detection and device fingerprinting on top. A Post-Login Action scores each login and enables MFA or blocks high-risk attempts — no new auth stack required.

What Auth0's anomaly detection covers

Auth0 now calls these features Attack Protection. You switch each one on in the Auth0 Dashboard.

Auth0 featureWhat it stops
Bot DetectionShows a CAPTCHA when a login comes from an IP suspected of bot use.
Suspicious IP ThrottlingSlows an IP that tries too many logins or sign-ups in a short time.
Brute-Force ProtectionBlocks repeated attempts at one account, and can email the user.
Breached Password DetectionStops passwords known from third-party breaches.

What it misses

  • A correct password used from a new device, country or network. Credential stuffing and phishing hand attackers working passwords, so nothing is guessed and nothing is breached.
  • Impossible travel between two logins to the same account.
  • Telling the user. Apart from the brute-force notice, nothing emails the account owner when a login comes from somewhere new.

Why layer anomaly detection on Auth0

Auth0 handles authentication well and includes brute-force and breached-password protection (see the Auth0 integration guide for setup). But when an attacker logs in with valid, stolen credentials, the password check passes. Catching that requires scoring the anomaly around the login itself — the device, the network, the location, and the account's history.

Rather than build device fingerprinting and impossible-travel detection yourself, you add a Post-Login Action that forwards the login context to LoginLlama and acts on the returned score. This is the same account takeover detection approach, wired into the Auth0 login flow.

What the Action adds to Auth0

  • Device fingerprinting with an unrecognized-device flag.
  • A 0-10 risk score and reason codes per login.
  • Conditional MFA — step up only when risk is elevated.
  • A custom token claim your app can read downstream.

The Post-Login Action

This Action runs after Auth0 authenticates the user, sends the login context to LoginLlama, and then blocks, challenges, or allows based on the score. It fails open so an outage never blocks a login.

Auth0 Post-Login Action
/**
 * Auth0 Post-Login Action: score each login with LoginLlama.
 * Add "axios" as a dependency and a secret named LOGINLLAMA_API_KEY.
 */
exports.onExecutePostLogin = async (event, api) => {
  try {
    const axios = require('axios');

    const response = await axios.post(
      'https://loginllama.app/api/v1/login/check',
      {
        identity_key: event.user.email,
        ip_address: event.request.ip,
        user_agent: event.request.user_agent,
        geo_country: event.request.geoip?.countryName,
        geo_city: event.request.geoip?.cityName,
        email_address: event.user.email
      },
      {
        headers: {
          'X-API-KEY': event.secrets.LOGINLLAMA_API_KEY,
          'Content-Type': 'application/json'
        },
        timeout: 5000
      }
    );

    const attrs = response.data?.data?.attributes || {};
    const riskScore = attrs.risk_score || 0;
    const codes = attrs.risk_codes || [];

    // Expose the score to your app via a custom claim
    api.idToken.setCustomClaim('login_risk_score', riskScore);

    // Block clear anomalies (new device + risky network + stuffing)
    if (attrs.status === 'fail' || riskScore >= 8) {
      api.access.deny(`Suspicious login blocked (${codes.join(', ')})`);
      return;
    }

    // Step up to MFA for medium-risk logins instead of blocking
    if (riskScore >= 5) {
      api.multifactor.enable('any', { allowRememberBrowser: false });
    }
  } catch (error) {
    // Fail open: never block a login if LoginLlama is unavailable
    console.error('LoginLlama check failed:', error.message);
  }
};

Set it up in three steps

Step 1

Create a custom Action

In the Auth0 Dashboard, go to Actions → Library → Build Custom and pick the "Login / Post Login" trigger.

Step 2

Add the axios dependency and API key

Add "axios" as a module dependency and a secret named LOGINLLAMA_API_KEY with your key from the LoginLlama dashboard.

Step 3

Paste the Action and add it to the flow

Paste the code, deploy, then drag the Action into Actions → Flows → Login between Start and Complete.

Anomalies the Action detects

Unrecognized device fingerprints for the account

New country or impossible-travel between logins

Traffic from VPNs, proxies, TOR, and high-risk IPs

Credential-stuffing bursts across many accounts

Logins at unusual times for the user

Step up instead of blocking

Allow low-risk logins with no added friction

Enable Auth0 MFA only for medium-risk attempts

Block clear anomalies with api.access.deny()

Expose the risk score to your app as a custom claim

Where LoginLlama fits

LoginLlama adds a risk score to your Auth0 login flow without replacing Auth0. If you would rather detect suspicious logins without adding friction for everyone, read our guide on detecting suspicious logins without blocking customers, or check pricing for volume tiers.

Auth0 anomaly detection FAQ

What is Auth0 anomaly detection?

Anomaly detection was Auth0's earlier name for the features its docs now call Attack Protection: Bot Detection, Suspicious IP Throttling, Brute-Force Protection and Breached Password Detection. They stop password guessing and known-breached passwords. They do not score a correct password used from a new device or country. For that you add a Post-Login Action that calls a login risk service such as LoginLlama.

Does Auth0 alert users about a login from a new device?

Not as part of Attack Protection. The only user email it describes is the brute-force notice sent when an account is being attacked. LoginLlama emails the user a "was this you?" alert, in your name, when a login comes from a device it has not seen for that account.

How do I add device fingerprinting to Auth0?

Add device fingerprinting to Auth0 with a Post-Login Action that forwards the login context (IP, user agent, and geo from event.request) to LoginLlama. LoginLlama fingerprints the device and returns whether it is unrecognized for that account, along with a risk score, so you can require MFA on new devices without maintaining your own fingerprinting infrastructure.

Does this replace Auth0?

No. LoginLlama runs inside the Auth0 Login flow as a Post-Login Action. Auth0 stays your identity provider and continues to handle authentication, sessions, and MFA enrollment. LoginLlama only adds the anomaly-detection risk score and reason codes that let you decide when to challenge or block.

What happens if LoginLlama is unreachable during an Auth0 login?

The Action is written to fail open. If the LoginLlama call errors or times out, the catch block returns and the Auth0 login proceeds normally, so an outage in the anomaly-detection service never locks legitimate users out of your app.

Auth0 login protection

Add anomaly detection to Auth0 in one Action

Score every login, fingerprint devices, and step up MFA only when it matters.

Start with 100 free checks