--- title: "Bypassing SOP with Iframes - 1" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/postmessage-vulnerabilities/bypassing-sop-with-iframes-1.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/postmessage-vulnerabilities/bypassing-sop-with-iframes-1.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Bypassing SOP with Iframes - 1 ## Iframes in SOP-1 This challenge by NDevTK and Terjanq requires exploiting an XSS in the following message handler; the original creator profiles are retained for attribution.[[1]](#references)[[3]](#references)[[4]](#references) ```javascript const identifier = "4a600cd2d4f9aa1cfb5aa786" onmessage = (e) => { const data = e.data if (e.origin !== window.origin && data.identifier !== identifier) return if (data.type === "render") { renderContainer.innerHTML = data.body } } ``` The main page sanitizes its normal `data.body` flow with DOMPurify. To send attacker-controlled HTML to this handler, the challenge requires bypassing the `e.origin !== window.origin` check. Let's see the solution they propose.[[1]](#references) ### SOP bypass 1 (e.origin === null) When a document is embedded in an iframe whose sandbox flags omit `allow-same-origin`, it receives an opaque origin. Its serialized origin in messaging is `null`, so `