PHP SSRF

Aprende a hackear AWS desde cero hasta convertirte en un experto con htARTE (HackTricks AWS Red Team Expert)!

Otras formas de apoyar a HackTricks:

Try Hard Security Group


Funciones PHP para SSRF

Algunas funciones como file_get_contents(), fopen(), file(), md5_file() aceptan URLs como entrada que seguirán, lo que hace posibles vulnerabilidades de SSRF si el usuario puede controlar los datos:

file_get_contents("http://127.0.0.1:8081");
fopen("http://127.0.0.1:8081", "r");
file("http://127.0.0.1:8081");
md5_file("http://127.0.0.1:8081");

CRLF

Además, en algunos casos, incluso podría ser posible enviar encabezados arbitrarios a través de "vulnerabilidades" CRLF en las funciones anteriores:

# The following will create a header called from with value Hi and
# an extra header "Injected: I HAVE IT"
ini_set("from", "Hi\r\nInjected: I HAVE IT");
file_get_contents("http://127.0.0.1:8081");

GET / HTTP/1.1
From: Hi
Injected: I HAVE IT
Host: 127.0.0.1:8081
Connection: close

# Any of the previously mentioned functions will send those headers

Para obtener más información sobre esa vulnerabilidad de CRLF, consulta este error https://bugs.php.net/bug.php?id=81680&edit=1

Ten en cuenta que estas funciones podrían tener otros métodos para establecer encabezados arbitrarios en las solicitudes, como:

$url = "";

$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" .  // check function.stream-context-create on php.net
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" // i.e. An iPad
)
);

$context = stream_context_create($options);
$file = file_get_contents($url, false, $context);

Grupo de Seguridad Try Hard

Aprende hacking en AWS de cero a héroe con htARTE (HackTricks AWS Red Team Expert)!

Otras formas de apoyar a HackTricks:

Última actualización