Skip to content
Laravel Security

Detecting Suspicious Logins in Laravel: Signals, Responses and False Positives

Shakewell ·

An account takeover often looks like a normal login: the right password, accepted. That is why a password check alone, even with rate limiting, leaves a gap: the question that matters is not “was the password correct?” but “does this login look like this user?”

Spatie, which maintains many open-source Laravel packages, released laravel-suspicious-login in November 2026 to answer that question inside a Laravel application. Freek Van der Herten introduced it on freek.dev on 20 November 2026, and Packagist shows a 1.0.0 tag on 19 November. This post covers which signals matter, what to do when one fires, why false positives are the hard part, and what to consider in Australia. Where we describe the package, we describe only what its README, documentation and Freek’s announcement say. We have not run it on a client system.

The signals that matter

A useful suspicious-login system watches several weak signals and combines them, because any one of them is often innocent.

  • A new device or browser. A common signal, since a legitimate user mostly returns from the same browser.
  • A new location. A new country, or two countries in a short time. Travel too fast to be real is a sharper form of the same signal.
  • Recent failed attempts. Many failures on one account before a success suggest password guessing. Failures against many accounts from one IP suggest credential stuffing, where leaked email and password pairs are tried at scale.
  • Unusual user agents or IP reputation, which add smaller contributions to the score.

Spatie’s package takes exactly this approach. It scores each successful login. Each check adds points when it flags the login, the points sum to a risk score, and two thresholds decide the response. The defaults in config/suspicious-login.php are 40 for medium and 70 for high.

A successful login passes through checks that add points to a risk score, which leads to allow, or an email to the user at medium and high risk. Blocking needs your own preset.

The documentation lists these checks: new device, new IP address, new country, impossible travel, allowed and blocked countries, failed attempts, credential stuffing, unusual time, suspicious user agent, IP reputation and multiple countries. The DefaultPreset combines new device, new IP, new country, impossible travel, repeated failed attempts, credential stuffing and suspicious user agents.

Check What it flags Documented default
New device A browser the user has not logged in from before 25 in DefaultPreset
New IP address An IP not seen on earlier logins 10 in DefaultPreset
New country A country not seen on earlier logins 30 in DefaultPreset
Failed attempts A success after many failures on that account 5 or more in 15 minutes, score 30
Credential stuffing A success from an IP that failed on many accounts 5 or more accounts in 60 minutes, score 40

The README’s worked example adds a new device (25), a new IP (10) and a new country (30) to reach 65, which is medium risk and sends an email. Device and country checks compare against earlier successful logins that were not blocked, so a user’s first login is not flagged. The country check needs location data.

What to do when one fires

There are three responses, and they escalate.

Notify. Email the user “was this you?” with the time, an approximate location and the browser, and a way to secure the account. It costs the legitimate user a glance and tells a victim immediately. The package’s NotifyUserAction sends a queued mailable to the user’s email address, so it needs working mail configuration and a running queue worker unless you use the sync connection.

Step up. Ask for something more before letting the user in: a second factor, or a confirmation email. The package has no built-in step-up action, but its README says actions are plain classes with an execute() method, and its examples include asking for a second factor or alerting a security team. This is the response we would reach for first at medium risk, because it protects the account without locking out a genuine traveller.

Block. The package’s BlockLoginAction marks the attempt as blocked, fires SuspiciousLoginBlockedEvent, logs the user out of their guard and throws a validation exception, so your login controller handles it like any other validation error. Three details matter:

  • It works with session-based logins. For other authentication flows, you write your own blocking action.
  • List it last in a preset’s actions, because it ends the request.
  • The package scores a login that has already succeeded. Blocking therefore means revoking a login, not preventing a password check.

Pair any block with a recovery route. A blocked genuine user needs a message and a way to reach support or reset access, or the control creates a support queue.

The false-positive problem

Every signal above misfires on real people.

Four everyday situations and the signal each can raise: travel or VPN, mobile network, shared office, and cleared cookies.

  • VPNs and travel trigger new-country and impossible-travel checks. Freek’s post says so directly and recommends monitoring first, with blocking enabled later.
  • Mobile networks change IP addresses often, which is why the package does not treat an unfamiliar IP as enough on its own.
  • Shared offices put many accounts behind one IP. The credential stuffing documentation suggests raising its threshold if many users share one address.
  • Cleared cookies create a new device identity. The default device fingerprint is an encrypted browser cookie, so clearing cookies makes the same person look new.

How we would tune it, based on the package’s own tools:

  1. Start in monitor-only mode. The MonitorOnlyPreset records scores and fires events without notifying or blocking, and the README recommends it for existing applications. Read the scores for a few weeks against real users.
  2. Adjust scores and thresholds to what you saw. If your users are mostly in one office, a new IP is routine and a new country is not.
  3. Turn on notification first, then blocking only for the accounts where a takeover costs most. SuspiciousLogin::determinePresetUsing() lets you choose a preset per login, so administrators can get a stricter one than everyone else.
  4. Write the response, not just the rule. Decide who reads the events, and how a blocked user gets back in.

Privacy and the Australian context

A login log is a record about a person. In Australia, the Privacy Act’s definition of personal information covers information about an individual who is reasonably identifiable. An IP address, a device identifier and a location stored against an account are linked to a user, so we would treat them as personal information. The OAIC’s page on what is personal information explains how the test is applied. This is general information, not legal advice, and your own adviser should confirm how it applies to you.

Practical questions to settle before you deploy:

  • What is stored and for how long. Attempts go into a login_attempts table. We did not find a retention setting in the README or documentation pages we read, so check, and if there is none, schedule your own deletion of old rows.
  • Where lookups go. The default ipinfo geolocation driver looks up public IP addresses with an external service, caching results for a week. You can choose another driver, or set it to 'null' to disable lookups and avoid sending IPs to an outside service, at the cost of the location checks. If you do send them, check where the lookup provider processes the data, and ask your adviser what that means for you.
  • What your privacy policy says. It should describe the login data you collect and why you use it for security.
  • Automated blocking. Automatic blocking is a decision made by software. Ask your adviser whether the Privacy Act’s automated decision rules apply to you. Our post on automated decisions and your privacy policy covers them.

Collecting less is the simplest control. Keep what the checks need to work and delete the rest.

Where this sits next to MFA and passkeys

These are layers, and each answers a different question.

  • Rate limiting slows guessing. Laravel’s starter kits use Fortify, and their documentation shows a login limiter of five attempts a minute keyed on email and IP address.
  • Multi-factor authentication makes a stolen password insufficient. The starter kits include two-factor authentication with any TOTP authenticator app, enabled by default.
  • Passkeys remove the password. Laravel’s starter kit documentation lists passkey authentication in its WorkOS AuthKit variant, which can also avoid handling passwords at all.
  • Suspicious-login detection watches what happens after a credential is accepted, and catches the case where the credential was valid but the person was not.

If you must choose an order, strong sign-in comes first. Detection is the net underneath, and it helps most where you cannot yet require MFA for every user.

Setting it up

The package is installed with Composer and an install command:

composer require spatie/laravel-suspicious-login
php artisan suspicious-login:install

The install command publishes config/suspicious-login.php and the migration for the login_attempts table. The package listens for Laravel’s Login and Failed auth events, so it works with Breeze, Jetstream, Fortify and custom login controllers without changes. Logins restored from a “remember me” cookie are not recorded. It also ships Laravel Boost guidelines and a skill, if your team uses Boost.

Check the requirements first. PHP 8.4 or later is the one most likely to stop a Laravel 12 application, and our Laravel 12 to 13 upgrade guide and PHP 8.2 end of life posts cover the runtime side. If your application is older and the login code is a tangle, our Laravel development team can review authentication as part of a wider upgrade.

Sources: Detecting suspicious logins in your Laravel app by Freek Van der Herten, 20 November 2026, spatie/laravel-suspicious-login on GitHub, the package documentation, its requirements, failed attempts and credential stuffing pages, Packagist, Laravel starter kits and the OAIC guidance on personal information, checked 29 November 2026.

Common questions

What does Spatie's laravel-suspicious-login package need?

Its documentation says it requires PHP 8.4 or later and Laravel 11 or later. Login attempts are stored in a JSON column, so MySQL needs to be version 5.7 or higher. The MaxMind geolocation driver also needs the geoip2/geoip2 package. A Laravel 12 application on PHP 8.3 would need a PHP upgrade first.

Does it replace multi-factor authentication or passkeys?

No. Multi-factor authentication and passkeys make a stolen password harder to use. The package scores each successful login by device, IP address, location and history, then lets you notify the user, block, or run your own action. It is a second layer that watches what happens after sign-in, not a way to prove who is signing in.

Will it flag people using a VPN or travelling?

It can. The package's author notes that travel and VPN use can trigger the country check, and recommends monitoring first and enabling blocking later. A single unfamiliar IP address is not treated as enough on its own, because mobile networks change addresses.

Is a login IP address personal information under the Privacy Act?

It can be. Under the Privacy Act, personal information includes information about an individual who is reasonably identifiable, and an IP address stored against an account is linked to a person. Treat login records as personal information, keep only what you need, and ask your legal adviser about your own situation. This is general information, not legal advice.

Start a conversation

Start a conversation

Tell us what you want to build, fix or scale, we’ll come back with a clear way forward.