Vulnerability analysis The MessageInBottle application makes us enter a text input, and it saves it in a database. The input field is not SQL-injectable. However it is unsafely copied into the return page, allowing for a stored XSS attack. With the "pray.php" page, we can ask to another client (the real victim) to load the "index.php" page to see the malicious message and run the included scripts. As it is usual for XSS attacks, we have to steal the cookies of the victim client. Exploitation In order to steal the cookies, we run a web server locally with: php -S 10.0.2.8:9999 where 10.0.2.8 is an IP address controlled by us. If we are in the same network of the victim client (which runs in the same host of the server) we can store the following message: Otherwise, if attacker and victim do not have a common network, we have to run an ngrok tunnel with: ./ngrok http http://10.0.2.8:9999 and we can store the following message: where https://059a-81-56-51-2.ngrok-free.app is our public ngrok endpoint. Then, it is sufficient to request the pray.php page, and retrieve the cookie value from the php logs or the ngrok logs. Remediation Untrusted input cannot be copied as-is into a return page. We have at least to use htmlspecialchars() in order to escape dangerous HTML characters.