Bypassing SOP with Iframes - 2
Iframes in SOP-2
Nella soluzione per questa sfida, @Strellic_ propone un metodo simile alla sezione precedente. Controlliamolo.
In questa sfida, l'attaccante deve bypassare questo:
Se lo fa, può inviare un postmessage con contenuto HTML che verrà scritto nella pagina con innerHTML
senza sanificazione (XSS).
Il modo per bypassare il primo controllo è rendere window.calc.contentWindow
undefined
e e.source
null
:
window.calc.contentWindow
è in realtàdocument.getElementById("calc")
. Puoi sovrascriveredocument.getElementById
con<img name=getElementById />
(nota che l'API Sanitizer -qui- non è configurata per proteggere contro attacchi di DOM clobbering nel suo stato predefinito).Pertanto, puoi sovrascrivere
document.getElementById("calc")
con<img name=getElementById /><div id=calc></div>
. Quindi,window.calc
saràundefined
.Ora, abbiamo bisogno che
e.source
siaundefined
onull
(perché==
è usato invece di===
,null == undefined
èTrue
). Ottenere questo è "facile". Se crei un iframe e invi un postMessage da esso e immediatamente rimuovi l'iframe,e.origin
sarànull
. Controlla il seguente codice
Per bypassare il secondo controllo riguardo al token, si invia token
con valore null
e si rende il valore di window.token
undefined
:
Inviare
token
nel postMessage con valorenull
è banale.window.token
nella chiamata della funzionegetCookie
che utilizzadocument.cookie
. Si noti che qualsiasi accesso adocument.cookie
in pagine di originenull
genera un errore. Questo farà sì chewindow.token
abbia valoreundefined
.
La soluzione finale di @terjanq è il seguente:
Last updated