Skip to content
XSS Write-up Intermediate

Finding DOM Polyglot XSS in PayPal the Easy Way

A DOM-based XSS vulnerability existed in a PayPal page where user input was reflected into an id attribute and later used in a jQuery selector. An attacker could execute arbitrary JavaScript, and although a CSP was present, it could be bypassed using existing libraries on the allow list.

Gareth Heyes Follow

Published on portswigger.net

Finding DOM XSS can be tricky when it's buried in thousands of lines of code. We recently developed DOM Invader to help tackle this using a combined dynamic+manual approach to vulnerability discovery, and promptly found an interesting polyglot DOM XSS affecting PayPal.

Gareth Heyes (@garethheyes), on portswigger.net

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application inserted user-controlled input into an HTML attribute and then used that value in a jQuery selector without proper sanitisation, allowing script injection.

Impact

An attacker could execute arbitrary JavaScript in the context of the PayPal domain, potentially stealing user data or performing actions on behalf of the user, and the CSP could be bypassed using allowed libraries.

What the attacker needed

Victim clicks a crafted link; CSP must be bypassed (or absent)

The fix

The vulnerability should be fixed by properly sanitising user input before inserting it into HTML attributes and jQuery selectors, and by not relying solely on CSP for XSS protection.

How it was found

  1. Navigate to the vulnerable page and inject a canary to see which sources and sinks are used.
  2. Send probes of characters such as <>'" along with the canary and inspect the sink to see if they were allowed.
  3. Observe that the canary is reflected inside an id attribute and that a double quote breaks the page.
  4. Escape the double quote to keep the page working and confirm the value reaches the sink.
  5. Inject other characters to cause JavaScript execution, noting that the value must be a valid CSS selector.
  6. Use a crafted payload that creates an iframe with srcdoc to execute scripts, bypassing CSP with allowed libraries.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

This is a cross-site scripting (XSS) bug where a website takes input from the URL and puts it into the page without proper cleaning. Because of that, an attacker can craft a link that, when clicked, runs their own JavaScript in the victim's browser. The site had a security policy (CSP) to block such scripts, but the researchers found a way around it.

What is XSS?

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

More by Gareth Heyes

View all

15 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.