
Descripción
This lab contains a DOM-based cross-site scripting vulnerability in the stock checker functionality. It uses the JavaScript document.write
function, which writes data out to the page. The document.write
function is called with data from location.search
which you can control using the website URL. The data is enclosed within a select element.
To solve this lab, perform a cross-site scripting attack that breaks out of the select element and calls the alert
function.
Reflected XSS into a JavaScript string with angle brackets HTML encoded writeup
Al entrar al laboratorio veremos una tienda online. Al darle a ‘View details’ de algún producto, encontraremos la función de ‘Check stock’ vulnerable. El código que ejecuta este botón es el siguiente:

Como vemos, busca en la URL el parámetro ‘storeId’ y lo pone como valor del atributo ‘name’ de la etiqueta ‘select’ sin realizar ninguna comprobación.
Añadiremos a la URL el siguiente fragmento:
&storeId="></select><img src=1 onerror=alert(1)>
Nota: Hay que cerrar el select («></select>), si no, pese a que el alert se ejecute, el laboratorio no se marcará como completado.
Al entrar en la URL completaremos el laboratorio:
