Bypassing SOP with Iframes - 1
Last updated
Last updated
AWS Hacking'i öğrenin ve pratik yapın:HackTricks Eğitim AWS Kırmızı Takım Uzmanı (ARTE) GCP Hacking'i öğrenin ve pratik yapın: HackTricks Eğitim GCP Kırmızı Takım Uzmanı (GRTE)
Bu challenge NDevTK ve Terjanq tarafından oluşturulmuştur. Burada, kodlanmış bir XSS'i istismar etmeniz gerekiyor.
The main problem is that the main page uses DomPurify to send the data.body
, so in order to send your own html data to that code you need to bypass e.origin !== window.origin
.
Let's see the solution they propose.
When //example.org
is embedded into a sandboxed iframe, then the page's origin will be null
, i.e. window.origin === null
. So just by embedding the iframe via <iframe sandbox="allow-scripts" src="https://so-xss.terjanq.me/iframe.php">
we could force the null
origin.
If the page was embeddable you could bypass that protection that way (cookies might also need to be set to SameSite=None
).
The lesser known fact is that when the sandbox value allow-popups
is set then the opened popup will inherit all the sandboxed attributes unless allow-popups-to-escape-sandbox
is set.
So, opening a popup from a null origin will make window.origin
inside the popup also null
.
Therefore, for this challenge, one could create an iframe, open a popup to the page with the vulnerable XSS code handler (/iframe.php
), as window.origin === e.origin
because both are null
it's possible to send a payload that will exploit the XSS.
That payload will get the identifier and send a XSS it back to the top page (the page that open the popup), which will change location to the vulnerable /iframe.php
. Because the identifier is known, it doesn't matter that the condition window.origin === e.origin
is not satisfied (remember, the origin is the popup from the iframe which has origin null
) because data.identifier === identifier
. Then, the XSS will trigger again, this time in the correct origin.
AWS Hacking'i öğrenin ve pratik yapın:HackTricks Eğitim AWS Kırmızı Takım Uzmanı (ARTE) GCP Hacking'i öğrenin ve pratik yapın: HackTricks Eğitim GCP Kırmızı Takım Uzmanı (GRTE)