Skip to content
XSS Write-up Beginner

Paypal DOM XSS main domain

A DOM-based cross-site scripting flaw existed on PayPal's main domain: appending a crafted fragment to the URL caused the page's client-side JavaScript to execute attacker-supplied markup. An attacker could have used this against registered PayPal users, though the report was closed as a duplicate.

Patrik Fehrenbach Follow

Published on blog.it-securityguard.com

i recently discovered a DOM Cross Site Scripting issue while testing on Paypal, the process here was pretty straight forward, if you inserted the payload in :

Patrik Fehrenbach (@ITSecurityguard), on blog.it-securityguard.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.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target was PayPal, and the researcher was testing how the site handled input placed in the URL. The finding was a DOM-based cross-site scripting issue: a payload inserted into the URL was executed by client-side JavaScript rather than being reflected by the server.

The payload used was:

Text
#"><img src=/ onerror=alert(2)>

Placed in the URL, this caused the DOM to execute JavaScript. The report describes the process as straightforward: insert the payload in the URL and the DOM runs it. The researcher notes that the issue would have affected all registered PayPal users and could have been used to exploit them.

The report gives no endpoint, parameter name, browser version or HTTP request. It also does not describe the vulnerable JavaScript, the response, or any fix. The submission was tagged as a duplicate, and no severity or CVSS score is recorded here.

The proof of concept sent to the PayPal bug bounty team is shown below.

Or watch on YouTube
From the original on blog.it-securityguard.com

Root cause

The report shows that a payload placed in the URL was executed by the DOM, but does not identify the sink or the code involved.

Impact

The researcher states that the vulnerability would have affected all registered PayPal users and could have been used to exploit them. In DOM XSS terms, that means script running in the browser of a PayPal user who opened the crafted URL. The report does not demonstrate a specific attack chain, data theft or account takeover, so the practical impact beyond script execution in a victim's browser is not shown.

How this kind of bug works

DOM XSS happens entirely in the browser. A source, such as the URL fragment, window.name, a query string read by JavaScript, or data from postMessage, feeds a sink that interprets its input as HTML or JavaScript. Common sinks include innerHTML, outerHTML, document.write, eval, setTimeout with a string argument, and jQuery helpers such as .html(). If the value reaches the sink unescaped, an attacker who can get a victim to open a crafted URL runs script in the target origin.

The fragment is a particularly useful source because browsers do not transmit it to the server. Any protection that lives only on the server is bypassed by design. Defences are therefore client-side: avoid HTML sinks for untrusted data, use textContent or safe templating, sanitise with a maintained library when HTML is genuinely required, and deploy a Content Security Policy that blocks inline script and event handlers.

How to test for it

  1. Map the client-side code. Read the JavaScript bundles and look for sources such as location.hash, location.search, document.referrer, window.name and message event handlers.
  2. Trace each source forward to a sink. Tools that instrument sinks in the browser, or simply breakpoints in the debugger, make this faster than reading minified code by hand.
  3. Send a benign marker first, for example a unique string in the fragment, and confirm it appears in the DOM at the point you expect. This separates real data flow from dead code.
  4. Replace the marker with a harmless proof such as an image tag whose onerror calls alert or writes a value to the page. Watch for execution in the console and in the DOM inspector.
  5. Repeat with the URL encoded and with different browsers, since fragment handling and decoding differ.

A positive result is script executing in the target origin from a URL you control, with no server-side reflection involved. Common false positives are markers that appear only as text (correctly escaped), payloads that execute only after you paste them into the console, and reflections that are actually server-side and already covered by output encoding. Also check whether a framework sanitises the value before it reaches the sink; a marker in the DOM is not proof of execution.

How it is fixed

The standard fix is to stop passing untrusted data to HTML sinks. Use textContent or attribute setters for text, build DOM nodes programmatically, and where HTML is required, sanitise with a well-maintained library on the client. Avoid eval and string-based timers. A strict Content Security Policy without unsafe-inline limits the damage of any sink that is missed, and framework-level escaping should be kept enabled rather than bypassed with raw HTML directives.

Hunting notes

DOM XSS tends to hide in single-page applications, search and filter pages that update from the fragment, login and error flows that read URL parameters in JavaScript, and any code that copies location values into templates. Recon signals include heavy client-side routing, hash-based navigation, large JavaScript bundles with HTML-building helpers, and pages that behave differently when a fragment is present. To make a report land, show the full data flow from source to sink, provide a minimal URL that executes a harmless payload, and state clearly which users and which origin are affected.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What happened, in plain words

A security researcher was testing PayPal, the online payment service many people use to send and receive money. While testing PayPal, he found a way to make the site run JavaScript code that he supplied through the URL. JavaScript is the programming language that web pages use to be interactive: it is what makes buttons respond, menus open and forms submit. Normally only the site's own code should run on its pages. Here, inserting the payload in the URL made the DOM execute JavaScript.

The researcher calls this a DOM Cross Site Scripting issue. The DOM, short for Document Object Model, is the browser's in-memory model of the page: a tree of elements such as headings, images and links that JavaScript can read and change. Cross-site scripting, usually shortened to XSS, means getting your own code to run inside someone else's website, as if it were part of that site. The "DOM" part refers to the browser's model of the page, which executed the JavaScript.

The process was, in the researcher's words, pretty straightforward. If you inserted this payload into the URL:

Text
#"><img src=/ onerror=alert(2)>

the DOM executed the JavaScript. A payload is simply the piece of input an attacker supplies to trigger a bug. Let us take the payload apart, because each character has a job:

  • # starts the fragment, the part of a web address after the hash mark. It usually points to a section of a page, and browsers keep it on the client side: it is not sent to the server.
  • "> closes an HTML attribute and the tag it sits in. The idea is to break out of whatever piece of markup the page is building, so that what follows is treated as new HTML rather than as harmless text.
  • <img src=/> opens an image tag. The src attribute is where the image should come from; here it is set to /, which is not a valid image.
  • onerror=alert(2) is an event handler. Because the image fails to load, the browser fires an error event, and the handler runs the JavaScript alert(2), which pops up a small dialogue box showing the number 2.

The alert(2) is deliberately harmless: it proves code ran without doing any damage. The researcher notes that this vulnerability would have affected all registered PayPal users and could have been used to exploit them. In other words, the issue would have affected all registered PayPal users. The report does not show a specific attack beyond that, so what an attacker could actually have done with it is not demonstrated.

The submission was tagged as a duplicate. No bounty amount, severity rating or CVSS score is recorded here. The researcher wrote about it anyway.

The proof of concept he sent to the PayPal bug bounty team is shown below. A proof of concept is the smallest demonstration that a bug is real: here, a link that makes the pop-up appear.

Or watch on YouTube
From the original on blog.it-securityguard.com

In general, how this kind of bug works

DOM XSS happens entirely in the browser. The pattern is always the same: a source feeds a sink. A source is any place untrusted data enters the page's JavaScript, such as the URL fragment, the query string, window.name, or messages from other windows. A sink is any place that treats its input as HTML or as code, such as innerHTML, document.write, eval, or a timer given a string. If the value travels from source to sink without being escaped, meaning special characters are turned into harmless text, the browser obeys the attacker's markup.

The fragment is a particularly handy source for an attacker because browsers never send it to the server. Think of it like a note written on the outside of an envelope: the postal service (the server) never reads it, only the recipient (the browser) does. Any protection that lives only on the server therefore cannot see it, which is why the payload survived all the way to the page.

In general, the defences are on the client side:

  1. Do not pass untrusted data to HTML sinks. Use textContent, which always treats input as plain text, or build elements programmatically.
  2. Where HTML really is needed, sanitise it with a maintained library that strips dangerous markup and event handlers.
  3. Avoid eval and string-based timers.
  4. Deploy a Content Security Policy, a set of rules the server sends telling the browser which scripts may run, and leave out unsafe-inline so that inline scripts and event handlers are blocked.

If you ever test for this yourself, the usual path is: read the page's JavaScript and look for sources; follow each one to a sink; send a unique harmless marker in the fragment and confirm it lands in the page; then replace the marker with a harmless proof such as the image tag above and watch for the pop-up. Repeat with the URL encoded and in different browsers, since fragment handling varies. A marker that appears only as text, correctly escaped, is not a bug, and neither is a payload that only runs after you paste it into the browser console.

Glossary

  • DOM (Document Object Model): the browser's tree-shaped model of a web page, which JavaScript can read and modify.
  • JavaScript: the programming language that runs in browsers to make pages interactive.
  • Cross-site scripting (XSS): getting attacker-supplied code to run inside another website's pages.
  • DOM XSS: XSS where the malicious data is handled and executed by the page's own JavaScript in the browser, not by the server.
  • Payload: the piece of input an attacker supplies to trigger a vulnerability.
  • URL fragment: the part of a web address after the #, kept on the client side and not sent to the server.
  • HTML attribute: a setting inside an HTML tag, such as src on an image.
  • Event handler: code attached to an element that runs when something happens, such as an image failing to load (onerror).
  • alert(): a JavaScript function that shows a small pop-up dialogue; often used as a harmless proof that code ran.
  • Source: a place where untrusted data enters the page's JavaScript.
  • Sink: a place that interprets its input as HTML or code, letting injected markup execute.
  • Escaping / sanitisation: converting or stripping special characters so input is treated as harmless text.
  • Content Security Policy (CSP): rules sent by a server that tell the browser which scripts are allowed to run.
  • Proof of concept: a minimal demonstration that a bug is real and reproducible.
  • Duplicate: a report for an issue that has already been reported by someone else.
  • CVSS: a standard scoring system for rating the severity of a vulnerability.
  • Bug bounty: a programme that pays researchers for reporting security issues responsibly.

More by Patrik Fehrenbach

View all

12 more disclosed reports, best first.

More from PayPal

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.