Why a wildcard change broke $request->ip(), which rate limits and allowlists it affected, and how to list your proxies explicitly.
Picture a login form that locks an IP address out after five failed attempts. It’s the standard setup: the throttle key is the email plus $request->ip(), copied from Laravel’s own starter kits. An attacker with a list of leaked passwords sends ten thousand attempts against one account, and each request carries a different X-Forwarded-For header. The limiter sees ten thousand different visitors, none of whom ever reaches five. Nothing in your logs looks broken, because each failed login is logged with a perfectly plausible, perfectly invented address.
That’s the shape of a bug that shipped in Laravel 13.20.0 and was reverted in 13.45.0. The Laravel News write-up of 13.45 describes the change that was undone and the risk it created in one sentence:
“An application that used the wildcard could have its client IP spoofed.” — Laravel News, Migration Durations and Job Memory Usage in Laravel 13.45, on
trustProxies(at: '*')
The revert, #62702 by Mior Muhammad Zaki, is listed in the 13.45.0 release notes, and Laravel News files it under the release’s security fixes. The title of this post ends with an asterisk on purpose, because “13.45 fixes it” is true of the regression and not of everything a wildcard can do. That distinction decides whether you’re safe after upgrading, so it gets its own section below.
Sources and limits. The facts about what changed come from the 13.45.0 release notes, Laravel News, the pull request that introduced the original change (#60726), and the Laravel documentation. The behavior descriptions of Symfony’s address resolution are my understanding of how it works, so test them as shown. I found no CVE or published security advisory for this issue in what I read. Both pull requests involved are labeled 13.x, and I found no 12.x change, so I’m treating 12.x as unaffected by this particular regression but I haven’t confirmed it. I haven’t run any of the code here.
How $request->ip() Decides Who You Are
A proxy sits between the visitor and your app, so the TCP connection your server sees comes from the proxy, not the visitor. The proxy passes the visitor’s address along in the X-Forwarded-For header, and each proxy in a chain adds the address it received the request from:
Visitor (203.0.113.7) → CDN edge → Load balancer → Your app
X-Forwarded-For arriving at your app: 203.0.113.7, 198.51.100.20
REMOTE_ADDR (the connection): 10.0.0.5 (the load balancer)
▲ client ▲ CDN edge
Anyone can send an X-Forwarded-For header of their own, which is why the header is only meaningful if you know which proxies to believe. Laravel’s TrustProxies middleware is the setting that says so. When you tell it which proxies to trust, Laravel only reads the header on connections that come from those addresses.
The approach that works safely, which Symfony’s request class implements underneath Laravel, is to start from the connection’s address and walk the header from the right, skipping every address you trust. The first one you don’t trust is the client. The part a visitor writes sits on the left, so it’s never reached when the chain beyond it is made of your own proxies.
The failure mode is in the word “trust.” If every address counts as trusted, there is no “first one you don’t trust” to stop at, and the walk ends on the far left of the header, which is exactly the part the visitor wrote.
What Changed in 13.20, and What 13.45 Undid
Before 13.20, trustProxies(at: '*') trusted only the address that connected to your server (REMOTE_ADDR). That’s fine for a single proxy and wrong for a chain. A contributor, writing as mattford, described the problem in pull request #60726, titled “Fix TrustProxies at:* when multiple proxies are used”:
“the most recent proxy being treated as the original client IP” — GitHub user mattford, laravel/framework #60726, on what the old wildcard did behind multiple proxies
His fix, which shipped in 13.20.0 on July 14, 2026, made the wildcard trust a catch-all range for both IPv4 and IPv6 instead of only the calling address. The pull request also corrected tests that treated the last address in the header as the original client, on the grounds that the first one should be, citing MDN’s description of the header.
Both points are right in a world where every hop in the chain is yours. The trouble is that a wildcard has no way of knowing which hops are yours. Once every address is trusted, the leftmost entry in X-Forwarded-For becomes the client’s address, and the leftmost entry is the one the visitor can write. Laravel News describes the consequence: with the change, the wildcard trusted every address in the header, so the leftmost entry, which the client can set, became the client IP.
13.45.0 reverts it. According to the release write-up, the wildcard now trusts only the proxy that calls your server, as it did in 13.19.0. That’s the whole fix, and it’s why the asterisk matters.
Who Was Actually Exposed
Three conditions have to line up, and you can check all of them:
- You ran Laravel 13.20.0 through 13.44.x. The package maintainer who wrote the clearest summary of the range says it directly: on 13.20.0 and later, the wildcard trusts every hop.
- Your configuration used the wildcard. That’s
trustProxies(at: '*')inbootstrap/app.php, or*arriving through thetrustedproxy.proxiesconfiguration fallback (aTRUSTED_PROXIESenvironment variable pointed at it, for instance). - The visitor’s header reached your app unmodified. This is the part that varies by infrastructure.
On that third condition, there are two routes for the visitor’s value to survive. If your origin server accepts connections directly, an attacker can skip the proxy and send whatever header they like. And even if the origin is reachable only through your proxy, many proxies append the connecting address to whatever X-Forwarded-For the visitor sent instead of replacing it, so the forged value stays at the left of the header and the real address is added after it. Whether yours appends or replaces is a setting you can read in its documentation.
The package author whose README I quoted above puts the result bluntly:
“any visitor can choose their IP with one header” — Robert Boes, laravel-cloudflare-proxies README, on Laravel 13.20.0 and later with the wildcard
| Your setup | 13.20–13.44 with '*' | 13.45+ with '*' | Explicit proxy list |
|---|---|---|---|
Origin reachable only through a proxy that appends to X-Forwarded-For | Spoofable through the leftmost entry | Resolves correctly behind one proxy | Correct |
| Several proxies in a chain (CDN, then load balancer) | Spoofable | Returns the address of the nearest proxy, not the visitor | Correct if every hop is listed |
| Origin directly reachable | Spoofable | Still spoofable | Not spoofable |
Proxy overwrites X-Forwarded-For and origin is locked down | Not spoofable by this route | Fine | Correct |
Read the middle-right cell and the bottom-left-most cell of that table twice. They’re the asterisk.
What a Spoofed IP Gets an Attacker
Every feature that treats an address as a fact inherits the problem.
Rate limiting. Laravel’s built-in throttle falls back to $request->ip() for guests, and the login throttle in the starter kits keys on the email plus the address. An attacker who changes the header per request never hits a limit.
// ❌ The key an attacker can vary at will when the wildcard trusts every hop
RateLimiter::for('login', fn (Request $request) =>
Limit::perMinute(5)->by($request->input('email').'|'.$request->ip())
);
Lockout of someone else. The reverse also works. Send enough failed attempts with a victim’s address in the header and the limiter locks that address out.
IP allowlists. Admin panels, metrics endpoints, internal tooling and webhook receivers are commonly restricted to a handful of addresses. If one of those is guessable, such as 127.0.0.1 or an office range, a forged header gets in.
// ❌ Only as strong as the address it compares against
abort_unless(IpUtils::checkIp($request->ip(), config('admin.allowed_ips')), 403);
Audit logs and fraud scoring. If the address is invented, a log entry can’t tell you who did something, and an abuse check scoring by network reputation scores the attacker’s chosen network.
Anything else that reads $request->secure() or the forwarded host. The same trust decision governs the other X-Forwarded-* headers. I haven’t verified that this specific regression affected them, but a separate report (below) shows the scheme being spoofed under a fully trusting configuration, so check them in the same pass.
A developer who wrote about securing signups put the general rule in terms that apply well beyond signups:
“the single worst thing you can do to an IP-based control” — DEV Community author abdullah_afzal, in A Laravel Middleware for Blocking High-Risk Signups, on
trustProxies(at: '*')
That article was written well before this regression, which tells you the wildcard’s weakness predates 13.20. What 13.20 changed was how much of the weakness required direct access to your server.
Check Whether You’re Exposed
Do these in order, and do the live test last.
1. Your version and your config.
composer show laravel/framework | grep -E "^versions"
grep -rn "trustProxies" bootstrap/ app/
grep -rn "trustedproxy" config/ .env* 2>/dev/null
grep -rn "TRUSTED_PROXIES" . --include=*.php --include=.env* 2>/dev/null | grep -v vendor
If you were on 13.20.0 to 13.44.x with a wildcard in any of those places, you were in scope.
2. A temporary endpoint that shows what Laravel sees. Remove it after testing.
// routes/web.php (temporary)
Route::get('/_ip-check', fn (Request $request) => [
'ip' => $request->ip(),
'remote_addr' => $request->server('REMOTE_ADDR'),
'x_forwarded_for' => $request->header('X-Forwarded-For'),
]);
curl -s https://your-app.example/_ip-check -H 'X-Forwarded-For: 203.0.113.99'
If ip comes back as 203.0.113.99, a visitor can choose their address. Run it once against the public URL and, if you can, once against the origin directly.
3. Look through your logs for the period since 13.20.0 (July 14, 2026). Signs of abuse include one account or one session with many unrelated addresses, and requests from the public internet logged with private or loopback addresses such as 127.0.0.1 or 10.x, which is how someone would try to look like an internal caller.
-- A user appearing from an implausible number of addresses
SELECT user_id, COUNT(DISTINCT ip) AS addresses
FROM audit_logs
WHERE created_at >= '2026-07-14'
GROUP BY user_id
HAVING COUNT(DISTINCT ip) > 20
ORDER BY addresses DESC;
That query is an illustration against a hypothetical table, so adapt it to however you record requests.
Upgrade, Then Restart the Long-Running Workers
composer update laravel/framework
composer show laravel/framework | grep -E "^versions" # confirm >= 13.45.0
php artisan test
Then restart anything that keeps framework code in memory. Queue workers and Octane workers don’t pick up the change until they restart, and a long-running process that reads the request address, such as a job built from a request’s data, is where an old copy would linger.
php artisan queue:restart
php artisan octane:reload # if you run Octane
After the upgrade, run the curl check again and then check your multi-proxy behavior, because that’s where the asterisk shows up.
The Asterisk
13.45 returns the wildcard to the behavior it had before 13.20, and before 13.20 that behavior had two known problems.
It trusts whoever connects. The wildcard means “trust the address that opened this connection.” If your origin is reachable directly, the address that opened the connection is the attacker, and their header is believed. This is why the table above shows the directly reachable origin as spoofable on 13.45 too. It’s not a regression, and it isn’t new, but it’s the reason a wildcard should never face the internet.
It breaks multi-proxy chains. This is the problem #60726 set out to fix. Behind a CDN and a load balancer, the wildcard treats the nearest proxy as the visitor, so $request->ip() returns a proxy address. The package README quoted earlier describes the effect for Cloudflare: every visitor resolves to a Cloudflare edge address. Your rate limiter then treats everyone behind the same edge as one person, which can lock out innocent users together.
If you moved to the 13.20 behavior because it made your addresses correct, upgrading to 13.45 will put the problem back. The fix for both problems is the same, and it’s what the Laravel documentation’s other option has always offered: stop using a wildcard and list your proxies.
One more thing worth noting, since the framework’s own documentation has long suggested the wildcard for exactly the environments where it hurts. The 13.x requests page tells readers using Amazon AWS or another cloud load balancer that they may not know the addresses of their balancers, and that in that case they may use * to trust all proxies. It’s a reasonable instruction for getting https links right, and a risky one for anything that depends on the visitor’s address. Treat it as a default to replace, not a recommendation to keep.
List Your Proxies Explicitly
A single proxy or load balancer whose range you know:
// bootstrap/app.php
use Illuminate\Http\Request;
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(
at: ['10.0.0.0/8'], // your load balancer's subnet; the real range, not a guess
headers: Request::HEADER_X_FORWARDED_FOR
| Request::HEADER_X_FORWARDED_HOST
| Request::HEADER_X_FORWARDED_PORT
| Request::HEADER_X_FORWARDED_PROTO,
);
})
A chain, such as a CDN in front of a load balancer, needs every hop, because the walk from the right only stops at the visitor when each proxy before them is trusted:
$middleware->trustProxies(at: [
...$cdnPublishedRanges, // from your CDN's published list
'10.0.0.0/8', // your own load balancer's subnet
]);
For Cloudflare specifically, trust Cloudflare’s published ranges. Reading its CF-Connecting-IP header directly is only safe if your origin accepts traffic from Cloudflare alone. A DEV Community author writing about the topic gives the reason:
“anyone can send a fake X-Forwarded-For header and spoof their IP” — DEV Community author muhammadyasiramin, in Laravel 13 Get Client IP Address, on a wildcard with a directly exposed server
If you’d rather not maintain Cloudflare’s ranges by hand, the package mentioned earlier trusts Cloudflare’s published ranges and the private hop of your reverse proxy and nothing else. Evaluate it like any dependency, and note that it asks you to remove your own trustProxies(at: ...) call.
If proxy addresses differ per environment, trustProxies(at:) doesn’t accept a closure, and a framework discussion about documenting the configuration fallback notes that the fallback is the built-in way to vary the list by environment and works with config:cache:
// config/trustedproxy.php
return [
'proxies' => env('TRUSTED_PROXIES'),
];
Check how the value is parsed in your version before relying on a comma-separated list, and never put * in that environment variable for a deployment that handles anything sensitive.
Make the Edge Stop Believing the Visitor
Two server-side changes close the gap from the other end, whatever Laravel does:
# On the outermost proxy: replace what the client sent instead of appending to it
proxy_set_header X-Forwarded-For $remote_addr;
And make the origin unreachable except from your proxy, using a firewall or security group. A trusted-proxy list only protects you if traffic can’t skip the proxy. With both in place, even a misconfigured application can’t be handed a forged header from the internet.
Pin It With a Test
The test that would have caught this checks what a visitor can do, not what your config says:
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
beforeEach(function () {
Route::get('/_ip-check', fn (Request $request) => ['ip' => $request->ip()]);
});
it('ignores X-Forwarded-For from a peer that is not a trusted proxy', function () {
$this->withServerVariables(['REMOTE_ADDR' => '198.51.100.7'])
->withHeaders(['X-Forwarded-For' => '203.0.113.99'])
->getJson('/_ip-check')
->assertJson(['ip' => '198.51.100.7']);
});
it('returns the rightmost untrusted address behind a trusted proxy', function () {
$this->withServerVariables(['REMOTE_ADDR' => '10.0.0.5']) // inside your trusted range
->withHeaders(['X-Forwarded-For' => '203.0.113.99, 198.51.100.7'])
->getJson('/_ip-check')
->assertJson(['ip' => '198.51.100.7']);
});
With an explicit list, both pass. With a wildcard, the first one fails on every version, 13.45 included, because a wildcard believes whoever connects. That failure is the useful result. If you want to keep a wildcard for some reason, write the test to match its real behavior so the next person doesn’t assume it’s safe.
A Related Report Worth Knowing About
A separate framework discussion (#61616, opened in September 2026 against Laravel 12.22.0 and 13.0.0) describes another route to a trust-everything list: when the trustedproxy.proxies configuration entry is missing, the middleware’s list reportedly becomes 0.0.0.0/0 plus ::/0. The reporter, writing as mindlaess, summarized the result of the demonstration:
“ip() now returns the attacker-chosen 1.2.3.4” — GitHub user mindlaess, in laravel/framework discussion #61616, on a request with no trusted proxies configured
The same report says the scheme was spoofed through X-Forwarded-Proto. I didn’t verify the report’s current status, so treat it as a reason to run the live test above even if you never used a wildcard. An explicit list in bootstrap/app.php is the thing to confirm is actually being applied.
The Checklist
- Check your version: on 13.20.0 to 13.44.x with a wildcard, you were exposed to the regression.
- Search for the wildcard in
bootstrap/app.php,config/trustedproxy.phpandTRUSTED_PROXIES. - Upgrade to 13.45.0 or later and restart queue and Octane workers.
- Run the curl check against the public URL and, if possible, the origin.
- Look at your logs since July 14 for implausible address patterns.
- Replace the wildcard with an explicit list that includes every proxy hop.
- Make your edge proxy replace
X-Forwarded-Forand firewall the origin so traffic can’t skip the proxy. - Add the two tests above so a future change can’t quietly undo it.
Which Setup You’re In
Do you use a wildcard ('*') for trusted proxies?
├─ No, an explicit list → You weren't affected by this regression.
│ Confirm the list includes every hop.
└─ Yes
├─ On 13.20–13.44 → Upgrade to 13.45+, then replace the wildcard.
└─ On 13.45+ or earlier than 13.20
├─ Origin reachable directly? → Still spoofable. Lock it down and use a list.
├─ More than one proxy in the chain? → ip() returns the nearest hop. Use a list.
└─ One proxy, origin locked down → Works today. Still prefer a list.
Regardless: make the edge overwrite X-Forwarded-For, and test what a visitor can send.
The Verdict
The regression was real and is fixed, and the way to be sure it can’t hurt you again isn’t a version number. A wildcard asks Laravel to believe a header from a source it can’t identify, and every release since that setting was introduced has differed only in how much of the header it believes. 13.20 believed all of it, which turned a convenience into a bypass for anything keyed on an address. 13.45 believes the part from the connecting address, which is safer and still wrong the moment your server is reachable by someone who isn’t your proxy, or sits behind more than one. The durable fix is the boring one: name the proxies you actually have, make the edge overwrite the header, and keep the origin off the open internet. Then an address in your logs is a fact you can act on, and a rate limit is a limit.
