On this page
- Why does a leaked APP_KEY become remote code execution?
- Is every leaked key an RCE?
- How did the key leak, and where else is it?
- How do I rotate the key without a mess?
- Should I use APP_PREVIOUS_KEYS for a leaked key?
- Am I affected? A three-state self-test
- Was the key already used, and what should I look for?
- Which Laravel versions are still supported?
- What can an outside scan tell me about this?
If your Laravel APP_KEY has leaked, treat it as compromised today. Anyone holding it can forge cookies and other encrypted values your app trusts, and in some code paths that reaches remote code execution. Generate a new key, deploy it to every server and worker, and keep the old key out of APP_PREVIOUS_KEYS unless you need it briefly to re-encrypt stored data. Deleting the file from GitHub changes nothing.
| Fact | Detail | Source |
|---|---|---|
| What the key does | Encrypts and signs every cookie, including the session cookie | Laravel docs |
| Why a leak matters | decrypt() unserializes by default, so a forged encrypted value can become code execution | Synacktiv, 10 July 2025 |
| Scale | 267,952 keys in public sources; about 260,000 on GitHub; 400 validated as functional | Synacktiv, GitGuardian, 10 July 2025 |
| Oldest CVE | CVE-2018-15133, CVSS v3.1 8.1, Laravel up to 5.5.40 and 5.6.0 to 5.6.29 | NVD |
| Known exploited | CVE-2018-15133 added to CISA KEV on 16 January 2024 | CISA |
| Graceful rotation | APP_PREVIOUS_KEYS, introduced in Laravel 11 | Laravel 11 notes |
| Checked | 4 November 2026 | this page |
The first number is Synacktiv's count of keys it collected, and the other two are GitGuardian's counts from its own research, both published 10 July 2025. They describe a research dataset, not every Laravel site.
Why does a leaked APP_KEY become remote code execution?
Laravel encrypts every cookie, including the session cookie, with the key and signs the result with a message authentication code. The signature is what stops a visitor from editing a cookie. Whoever holds the key can produce a valid one.
That alone is a forgery problem. It turns into code execution when the app decrypts the forged value and then unserializes it. Synacktiv's analysis explains that decrypt() defaults to unserialization, which lets PHP object deserialization run. We do not reproduce the technique here.
The older example is CVE-2018-15133. NVD describes an unserialize call on an X-XSRF-TOKEN value and says the attacker needs the application key. CISA lists it as known exploited, with the same condition.
Is every leaked key an RCE?
No, and the honest answer is "it depends on the code path". Current Laravel does not unserialize cookies by default. The 12.x source for EncryptCookies has a static serialization flag that defaults to false.
Applications still create their own paths. Synacktiv's three application CVEs involved a route that accepts encrypted input, a cookie deserialization enabled by a Passport setting, and SESSION_DRIVER=cookie, which stores the session payload in the cookie itself. The Laravel session docs list that driver.
GitGuardian found 400 functional keys and 4 confirmed code execution cases. Those four are the cases it confirmed, so read them as a floor. The decision is the same either way. You cannot prove from outside which path your app exposes, so rotate. A separate Laravel-family risk is an outdated Livewire, and checking your Livewire v3 version takes a minute.
How did the key leak, and where else is it?
The usual routes are a committed .env, a .env served by the web server, and a default key shipped inside a purchased or open-source application. Synacktiv found a vendor default key that appeared on 1,650 public instances.
The Laravel configuration docs say the .env file should not be committed, and that an intruder reaching the repository would see every credential in it. The deployment docs say the web root must be public/, because serving from the project root exposes sensitive files, and their sample Nginx config denies dotfiles.
git log --all --oneline -- .env lists every commit that touched the file.The 30-second check for .env and .git requests shows how to see whether your server answers for those paths. If the file already reached a remote, what to do when .env was pushed to GitHub covers the first hour, and a push-protection and pre-commit scanner stops the next one. The key is rarely the only secret in that file, so the same incident usually needs the steps in this guide to rotating every other credential.
How do I rotate the key without a mess?
The order matters more than the commands. The aim is a new key everywhere, the old key accepted nowhere, and your stored data still readable.
What are the steps?
- Find where the key lives:
.envon each server, container environment, CI variables, a secrets manager, and any staging copy that shares it. - Generate a new key with
php artisan key:generate, which writes it to your environment file. In a hosted pipeline, put the new value into the platform's secret store instead. - Deploy the same new key to every server and container. A mixed fleet logs users out at random and fails decryption on some requests.
- Rebuild cached configuration. The Laravel configuration docs say that once
config:cachehas run,.envis no longer loaded, so runphp artisan config:cacheagain. - Reload long-running processes. The deployment docs say queue workers, Reverb and Octane need a reload to use new code, with
php artisan reload. Otherwise restart them through your process monitor. - Decide what to do about encrypted stored data (next section), then remove any old key from
APP_PREVIOUS_KEYS. - Rotate the other secrets that sat beside the key in the same file.
Expect every user to be logged out. The encryption docs say a key change signs out all authenticated sessions, so warn your users, or your clients, before you do it.
Should I use APP_PREVIOUS_KEYS for a leaked key?
This is the trap the documentation does not spell out. Laravel 11 added APP_PREVIOUS_KEYS so that a routine rotation does not log everyone out. When decrypting, Laravel tries the current key, then each previous key in turn until one works.
For a routine rotation that is the feature you want. For a leaked key it means the leaked key keeps decrypting whatever it is sent. It follows from the documented behaviour, so a leaked key left in that list is still a working key.
| Option | Users | Stored encrypted data | Leaked key still accepted | Use when |
|---|---|---|---|---|
New key only, nothing in APP_PREVIOUS_KEYS | All logged out | Unreadable until restored | No | You store nothing encrypted, or you can restore it from backup |
New key plus the old key in APP_PREVIOUS_KEYS for a short window | Not logged out for stale sessions | Readable | Yes, until you remove it | You must re-encrypt data first. Keep the window short |
| Routine rotation of a key that never leaked | Not logged out | Readable | Not applicable | Scheduled hygiene |
If you need the second row, re-encrypt in one planned job: read each encrypted column with the old key still listed, write it back so it is encrypted with the new key, then remove the old key and reload. Run it on a copy first. Check your models for encrypted casts and your code for Crypt::encryptString calls, because those are the values a rotation strands.
Am I affected? A three-state self-test
Am I affected? Where you stand right now
A check from outside can see an exposed environment file or a source map. It cannot see your repository history, your servers' environment, or whether anyone used the key.
- Detected Your key appears in a repository or history, or your domain serves
.envor.gitto anyone. Treat the key as public. Rotate it today and start the incident steps below. - Unknown Nothing visible from outside, but you cannot say where the key has been. This is the common case. Search repository history and CI logs, check old backups and shared staging servers, and rotate if you cannot rule it out.
- Confirmed by owner evidence You hold a deploy record of the new key on every server, a reload after it, and a settings dump showing the old key is not in
APP_PREVIOUS_KEYS. The rotation is complete. Whether the old key was used before then is a separate question.
No scan, ours included, moves you from "unknown" to "confirmed".
Was the key already used, and what should I look for?
Rotation closes the door going forward. It does not remove anything planted while the key was public. If the key was exposed for a long period, assume the question is open until you have looked.
Look inside the server for files you did not deploy, especially under storage/, public/ and bootstrap/cache/. Check scheduled tasks and queue jobs you did not create, new administrator accounts, changed .env values, and unexpected outbound connections from the PHP process. Compare logs for the period the key was public against requests that carried unusually long cookie values.
If you find anything, follow a step-by-step incident response plan and rotate every credential the server could read, not only this key. After the fix, this checklist for confirming the fix held explains what evidence counts.
Which Laravel versions are still supported?
Rotation is easier on a supported release, and older ones have no graceful option at all. This table is from the Laravel support policy, read on 4 November 2026.
| Version | Released | Security fixes until | Status on 4 November 2026 |
|---|---|---|---|
| 10 | 14 February 2023 | 4 February 2025 | Past end of security fixes |
| 11 | 12 March 2024 | 12 March 2026 | Past end of security fixes |
| 12 | 24 February 2025 | 24 February 2027 | Security fixes only |
| 13 | 17 March 2026 | 17 March 2028 | Supported |
APP_PREVIOUS_KEYS arrived in 11, so on 10 and earlier a rotation always signs users out and strands encrypted data. Plan the upgrade as part of the same job.
What can an outside scan tell me about this?
The free scan reads the stack your site serves and matches each version to known vulnerabilities. It also checks for .git, .env, backups and open directory listings, and for API keys and tokens in shipped bundles. It is a lookup. It can say a file is readable. It cannot say the key sat in a private repository for two years or that your workers reloaded.
For a closer look at what an outside view cannot settle, read the limits of an outside-only scan. If you run Laravel next to other PHP CMSs, how PHP2Shell affects Drupal, Joomla, MediaWiki and Laravel is the related read, and the other framework guides cover the rest. The wider context is in the October 2026 tracker.
Questions people ask
I committed my .env to GitHub and deleted it. Am I fine?
No. The key is still in the commit history, in forks and in any clone made while it was public, and your running app still uses it. GitGuardian found 50 keys that had been deleted from repositories but still worked in production. Rotate the key, then treat deletion as housekeeping.
If I change APP_KEY, will every user be logged out?
Yes. Laravel's documentation says changing the key logs out all authenticated sessions, because every cookie, including the session cookie, is encrypted. It also says data encrypted with the previous key can no longer be decrypted, unless you list that key in APP_PREVIOUS_KEYS.
Does a leaked APP_KEY always mean someone can run code on my server?
No, and you should still rotate. Whether a forged value reaches code execution depends on your Laravel version, your settings and your own code. Synacktiv documented cases in the cookie, session and route layers, and GitGuardian confirmed 4 production cases among 400 functional keys.
Should I put the leaked key in APP_PREVIOUS_KEYS?
Only briefly, and only if you must re-encrypt stored data. Laravel tries every previous key when decrypting, so a leaked key listed there still decrypts what an attacker sends. Re-encrypt your data, then remove it. If you have no encrypted columns, leave APP_PREVIOUS_KEYS empty.
How do I know whether someone already used the key?
From the outside you cannot tell. Look inside the server for files you did not deploy, new scheduled tasks, unfamiliar admin users and odd outbound connections, and check logs for the period the key was public. If you find any, follow an incident process rather than only rotating.
Which Laravel versions support APP_PREVIOUS_KEYS?
Laravel 11 introduced it, and the 12.x and 13.x documentation describe it. Laravel 11 and older are past their security fix dates at our check on 4 November 2026, so on those versions plan an upgrade as well as a rotation.
Sources
- GitGuardian: Exploiting public APP_KEY leaks (10 July 2025)About 260,000 APP_KEYs on GitHub, 400 validated as functional, 4 confirmed code execution cases, and 50 keys deleted from repositories that stayed valid in production. Checked 24 October 2026.
- Synacktiv: Laravel APP_KEY leakage analysis (10 July 2025)267,952 keys from public sources, why decrypt() defaulting to unserialization matters, the three application CVEs, 3.56% of public instances. Checked 24 October 2026.
- Laravel 12.x documentation: EncryptionWhat APP_KEY drives, graceful rotation with APP_PREVIOUS_KEYS, the decryption order. Checked 24 October 2026.
- Laravel 13.x documentation: EncryptionSame rotation section on the newest release. Checked 24 October 2026.
- Laravel 11.x release notes: graceful encryption key rotationWhere APP_PREVIOUS_KEYS was introduced. Also the support policy table. Checked 24 October 2026.
- Laravel 13.x release notes: support policyBug fix and security fix end dates per major version, including the 17 March 2026 release of 13. Checked 4 November 2026.
- Laravel 12.x documentation: ConfigurationKeep .env out of source control, config caching and the env() function, debug mode.
- Laravel 12.x documentation: DeploymentWeb root must be public/, dotfile rule in the sample Nginx config, php artisan reload for long-running workers.
- Laravel 12.x documentation: HTTP SessionSession drivers, including the cookie driver.
- NVD: CVE-2018-15133Unserialize on a token value, needs the application key. CVSS v3.1 8.1. Affects up to 5.5.40 and 5.6.0 to 5.6.29. Checked 24 October 2026.
- CISA Known Exploited Vulnerabilities catalog: CVE-2018-15133Listed as Laravel Deserialization of Untrusted Data Vulnerability, added 16 January 2024.
- laravel/framework: EncryptCookies middleware (12.x source)Cookie serialization flag and its default.
Facts on this page are dated and point at the primary source next to them. If a vendor status changes after the date shown, the vendor's page wins; tell us at support@run.cloud and we will update it.