Skip to content
XSS Disclosed report Intermediate

DOM XSS on multiple Automattic domains through postMessages

A DOM XSS flaw on widgets.wp.com allowed an attacker to run script in that origin, and a Jetpack postMessage listener on sites using the Likes feature trusted that origin but inserted the avatar_url parameter into the DOM without encoding, so the attacker could achieve XSS on any site with the feature enabled.

renniepak Follow

Originally disclosed on HackerOne

  • Fixed in 9 days
  • Paid in 9 days
  • Disclosed after 14 days

Hi Automattic team,

I have found a 2 flaws that when combined lead to DOM XSS on every website that is using Jetpack with the Likes feature enabled.

The 2 flaws are respectively:

  • A DOM XSS vulnerability on https://widgets.wp.com/sharing-buttons-preview/
  • The Jetpack plugin creates a postMessage listener allowing messages from the "widgets.wp.com" origin, but will not validate nor encode the avatar_url parameter before applying it to the DOM causing XSS.

Reproduction:

Result

In the newly opened window a alert(document.domain) will pop on https://wordpress.com

image.png
image.png From the original on HackerOne

Root causes

XSS on widgets.wp.com

The DOM XSS here is caused by the following included script:

https://widgets.wp.com/sharing-buttons-preview/js/preview.js

JavaScript
        if (_.isArray(r.custom)) {
            i = _.template(e("#tmpl-custom-button").html());
            s = _.map(r.custom, function(e) {
                var t = g.parseUrl(e.icon);
                return new d({
                    ID: e.name,
                    markup: i({
                        icon: o + "/" + t.host + t.pathname,
                        name: e.name
                    })
                })
            });
            n = n.concat(s)
        }

It's not that obvious because of the minified javascript but what happens is that 2 url parameters are parsed and used to add a UI element to the DOM:

?custom[0][icon]=iconurl&custom[0][name]=name

We can abuse the name parameter to create an XSS.

https://widgets.wp.com/sharing-buttons-preview/?custom[0][icon]=iconurl&custom[0][name]=%22%3E%3Cimg%20src%20onerror=alert()%3E

Screenshot_2024-02-12_at_09.35.51.png
Screenshot_2024-02-12_at_09.35.51.png From the original on HackerOne

Insecure postMessage listener / codeblock

When we navigate to a website that has the Jetpack Likes feature enabled, a postMessage listener will be launched that will execute the JetpackLikesMessageListener function when a message arrives.

We can see it contains an origin check to only allow messages from widgets.wp.com. We can bypass this now since we have XSS on that domain:

JavaScript
const allowedOrigin = 'https://widgets.wp.com';
	if ( allowedOrigin !== event.origin ) {
		return;
	}

When we follow the code to the showOtherGravatars case, you'll see it use a liker.avatar_URL parameter (that is received via a postMessage) directly with innerHTML. This will allow us to send a tampered postMessage causing the XSS to be triggered.

JavaScript
element.innerHTML = `
				<a href="${ encodeURI( liker.profile_URL ) }" rel="nofollow" target="_parent" class="wpl-liker">
					{{media:2}}
					<span></span>
				</a>
				`;

Mitigation

  • Applying input validation and output encoding on the sharing-button page to mitigate the XSS https://widgets.wp.com/sharing-buttons-preview/
  • Defence in depth: now any XSS on widgets.wp.com will lead to multiple XSSes all over the internet (anyone using the Jetpack Likes features). To mitigate this, I would also apply encodeURI to the avatar_url before using it in innerHTML. Upon further research it seemed older version of the plugin did exactly this, but in later versions this was removed.

Impact

XSS on a number of Automattic domains:

https://0-a.nl/jetpackxssclick.html?url=https://wordpress.com/blog/2024/01/31/http3 https://0-a.nl/jetpackxssclick.html?url=https://jetpack.com/blog/wordpress-navigation-menu/

You probably have better insights in this (also I'd love to hear the actual number :) ) but searching publicwww.com revealed over 100k websites using this feature, meaning 100k domains vulnerable to this XSS.

This is also the reason I picked High for severity. If it was just wordpress.com I would probably have gone for Medium which is more typical for these kind of XSSes without providing more impact specific to the vulnerable domain. But in this case the vulnerability reaches far beyond the 1 domain.

In general, if an attacker can control a script that is executed in the victim's browser, then they can typically fully compromise that user. Amongst other things, the attacker can:

  • Perform any action within the application that the user can perform.
  • View any information that the user is able to view.
  • Modify any information that the user is able to modify.

The original report as published on HackerOne, by renniepak. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

Likely the sharing-buttons preview page inserted a URL parameter into the DOM without encoding, and the Jetpack Likes listener trusted messages from widgets.wp.com but inserted the avatar_url value into innerHTML without encoding.

Impact

An attacker could run script in the context of any site using the Jetpack Likes feature, potentially performing any action the user can perform, viewing any information the user can view, and modifying any information the user can modify.

What the attacker needed

Victim visits a crafted link; target site uses Jetpack Likes feature

The fix

The report recommends applying input validation and output encoding on the sharing-button page and encoding the avatar_url before using it in innerHTML.

How it was found

  1. Navigate to the provided proof-of-concept page with a target URL parameter.
  2. Click the PoC link.
  3. A new window opens and an alert showing the document domain pops on the target site.

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 report has not been written yet. The Original tab links to the source.

The sharing-buttons preview page on widgets.wp.com took a name from the URL and put it into the page without cleaning it, so a crafted link could run script. Many WordPress sites use a Jetpack feature that listens for messages from widgets.wp.com and then puts an avatar URL into the page without cleaning it, so once the attacker had script on widgets.wp.com they could send a message that ran script on those sites too.

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 renniepak

View all

3 more disclosed reports, best first.

More from Automattic

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.