Halo, teman-teman mahasiswa! Selamat datang di praktikum super misterius tentang Server-Side Request Forgery atau SSRF β vulnerability yang bikin hacker kayak detektif siluman! Bayangkan aplikasi web kamu punya fitur fetch data dari URL lain (misal preview link, import gambar, atau cek webhook). Kalau nggak dijaga, hacker bisa "paksa" server kamu request ke tempat terlarang: internal network, metadata cloud (AWS/GCP/Azure), atau bahkan localhost! Hasilnya? Baca file rahasia, scan port internal, atau ambil credential cloud. Kayak server kamu jadi boneka hacker tanpa sadar.
SSRF sering dipakai buat serangan advanced di cloud environment. Yuk kita eksplor bareng, santai tapi mind-blowing, dengan contoh sederhana di PHP/Laravel!
Kartun hacker lagi manfaatin SSRF ini lucu tapi nunjukin betapa liciknya β server dipaksa request ke internal! π
Diagram klasik dari PortSwigger ini gambarin alur SSRF secara jelas β attacker β server β target terlarang!
Apa Itu SSRF? π€π
SSRF terjadi saat server melakukan request ke URL yang dikontrol user tanpa validasi ketat. Server "percaya" input user dan fetch ke mana saja, termasuk:
- Internal IP (127.0.0.1, 192.168.x.x, 10.x.x.x)
- Metadata service cloud (http://169.254.169.254 di AWS)
- Local files (file:///etc/passwd)
Dampak: Port scanning, data leakage, RCE kalau chain dengan vuln lain.
Ilustrasi update ini detail banget: Hacker paksa server request ke internal services!
Flowchart exploit SSRF ini step-by-step β dari input user sampai akses internal!
Contoh 1: Preview Link atau Gambar (Klasik SSRF!)
Kode rentan:
$url = $request->input('url');
$content = file_get_contents($url); // Langsung fetch tanpa cek!
echo $content;
Input normal: https://example.com/image.jpg β Tampil gambar.
Input jahat: http://127.0.0.1:8080/admin β Tampil halaman admin internal!
Atau http://localhost/server-status β Lihat info Apache internal.
Contoh 2: Akses Metadata Cloud (Bahaya di AWS/Azure/GCP!)
URL jahat: http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name
Server fetch β Dapat AWS credentials temporary! Hacker ambil alih akun cloud.
Contoh real di Azure services β SSRF buat akses internal!
Contoh 3: Port Scanning Internal
Input: http://192.168.1.1:22 β Kalau response beda (timeout vs connected), hacker tahu port open!
Atau bypass filter dengan: http://2130706433:80 (IP decimal untuk 127.0.0.1)
Contoh 4: Baca File Local
Kalau allow file:// protocol: file:///etc/passwd β Tampil isi file server!
Cara Mencegah SSRF (Best Practices Keren!) π‘οΈβ¨
- Whitelist Domain yang Diizinkan
$allowed = ['example.com', 'api.public.com'];
if (!in_array(parse_url($url, PHP_URL_HOST), $allowed)) abort(403);
Blacklist Internal IP
Cek kalau IP private (127., 10., 192.168., 172.16-31.) β Blokir!Disable Redirect & Non-HTTP Protocol
Pakai Guzzle dengan opsi:
$client = new \GuzzleHttp\Client(['allow_redirects' => false, 'protocols' => ['http', 'https']]);
-
Validasi & Sanitasi URL Ketat
Pakai library seperti
league/uriuntuk parse aman.
OWASP common flow prevention β whitelist & blacklist adalah kunci!
Infografis Akamai ini nunjukin cara cegah SSRF secara visual!
Latihan Seru Buat Kamu! πͺπ₯
- Buat fitur preview URL rentan, test akses localhost.
- Coba metadata AWS (di lab seperti PortSwigger).
- Tambahin whitelist, test bypass (decimal IP, dll).
- Implementasikan secure fetch dengan Guzzle.
Selamat praktikum, guys! SSRF ini vulnerability "ninja" yang diam-diam kuat, terutama di cloud β tapi dengan whitelist & validasi, server kamu aman kayak benteng tak terlihat ππ Jadi developer yang aware cloud security dari sekarang! Ingat: Never trust user-provided URLs! Keep coding safely and have fun! ππ΅οΈββοΈ







Top comments (0)