Skip to content
Race condition Advisory Advanced CVE-2024-7017

Inappropriate implementation in DevTools (CVE-2024-7017)

A race condition in the DevTools API server and insufficient permission checks allowed an extension with the devtools_page permission to run arbitrary JavaScript on privileged pages. This was used to set local test policies that configured an alternative browser to execute arbitrary commands, achieving sandbox escape.

Allen Ding Follow

Originally disclosed on Chrome VRP

Bounty$20,000 High View original
  • Fix shipped in 3 months

VULNERABILITY DETAILS

  1. A race condition in the devtools API server and chrome.devtools.inspectedWindow.reload, along with insufficient permissions checks, allows an extension with the devtools_page permission to run arbitrary JS on any privileged page.
  2. This is used to run JS on chrome://policy, which executes cr.sendWithPromise("setLocalTestPolicies", policy, "");. It is never checked if local test policies are actually allowed, so this applies arbitrary user policies to the browser.
  3. The BrowserSwitcherEnabled, BrowserSwitcherUrlList, AlternativeBrowserPath, and AlternativeBrowserParameters policies are set. This sets /bin/bash (or cmd.exe) as the "alternative browser."
  4. The extension navigates to example.com, which triggers the browser switcher, causing it to execute the commands specified by the policy.

EXPLANATION

Devtools API Permissions Bypass

As far as I can tell, the chrome.devtools.inspectedWindow.reload function has no checks to see if the extension is actually allowed to execute scripts on the inspected page. The only thing preventing this from being used normally is having the devtools extension server block access once the URL of the inspected page changes.

We can verify this by opening chrome://settings/resetProfileSettings, clicking on the "current settings" link (which opens an about:blank window with the chrome://settings origin), and opening devtools on that page. If our extension calls chrome.devtools.inspectedWindow.reload, then code will run on the privileged about:blank page.

Unfortunately, since only the URL is checked rather than the page's origin, so there is a small window of time after a navigation occurs where the origin is set to the new page but the URL is unchanged. If chrome.devtools.inspectedWindow.reload is called during this period, then it will execute arbitrary JS on the page that is being navigated to.

This window of time can be fairly reliably hit by spamming chrome.devtools.inspectedWindow.reload calls, then using chrome.tabs.update(chrome.devtools.inspectedWindow.tabId, {url: "chrome://policy"}); to perform the navigation. Now we can run arbitrary JS on any chrome:// page, bypassing any permissions checks.

Sandbox Escape With chrome://policy

The chrome://policy page has a feature which allows a user to set local policies for testing. This is disabled by default, but the webui message listener is added no matter what.

Thus once we have code execution on chrome://policy, we can run cr.sendWithPromise("setLocalTestPolicies", policy, "");, and this will cause the test policies to be enabled. The policy variable is a JSON string containing a list of user policies that will be applied. These policies will be immediately applied to the running browser.

There is supposed to be two options which have to be explicitly enabled to prevent this, however both checks fail. The feature flag policy::features::kEnablePolicyTestPage defaults to false, and this is supposed to be checked, but for some reason this check always fails. The policy policy_prefs::kPolicyTestPageEnabled is also checked, however, it requires the pref_service argument to be passed into the IsPolicyTestingEnabled function. For some reason, the pref_service argument is set to a nullptr when this function is run, negating this check.

Therefore, because the two previous checks both fail, only the release channel is taken into consideration when the browser decides whether or not to allow local test policies. Release channels Channel::CANARY and Channel::DEFAULT are always allowed (and Channel::DEV works on Linux). The release channel is always Channel::DEFAULT for builds that are not branded as Google Chrome, so test policies are always allowed on Chromium and its derivatives (or Google Chrome Canary/Dev).

Now that we have the ability to set any user policy we want, the following policies are set:

JavaScript
name: "BrowserSwitcherEnabled"
value: true

name: "BrowserSwitcherUrlList"
value: ["example.com"]

name: "AlternativeBrowserPath"
value: "/bin/bash"

name: "AlternativeBrowserParameters"
value: ["-c", "xcalc # ${url}"] 

The alternate browser switcher is enabled, and example.com is set to trigger it. The AlternativeBrowserPath policy is set to Bash, and the arguments provided specify which command to run. # ${url} is included so that the page URL is substituted in as a comment rather than its own argument.

Now all that's required is for the browser to navigate to example.com, which will cause Chrome to run /bin/bash -c 'xcalc # https://example.com'.

For reasons mentioned above, using chrome://policy will not work on official Google Chrome builds in the stable channel. However, chrome://downloads can be used to perform the sandbox escape instead, though this requires an extra user gesture. An POC for this alternative method is attached as devtools_downloads.js.

Although a full sandbox escape is not possible on Chrome OS, the devtools API permissions bypass will still work, so considerable damage can still be done. It may be possible for arbitrary code to be run on chrome://settings (which can steal passwords) or chrome://file-manager which can possibly inject something into the Crostini's bashrc.

VERSION

I tested this to work on Chromium in Linux, Windows, and MacOS.

Chrome Version: 124.0.6367.78 (Official Build) 64-bit) 
Operating System: Linux (Debian 12) 
Chrome Version: 126.0.6453.0 (Developer Build) (64-bit) 
Operating System: Windows 10 22H2
Chrome Version: 126.0.6452.0 (Developer Build) (x86_64)
Operating System: MacOS 11.7.10

REPRODUCTION CASE

  1. Open Chromium on Windows, Linux, or MacOS.
  2. Download the files attached to this report, and place them in the same folder.
  3. Load the attached files as a Chrome extension.
  4. Open devtools on about:blank or any other unprivileged page.

Videos are attached which demonstrate this.

CREDIT INFORMATION

Reporter credit: Allen Ding

The original report as published on the Chromium issue tracker, by Allen Ding. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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

Context

Chrome extensions that declare the devtools_page permission can extend DevTools. One of the APIs available to such an extension is chrome.devtools.inspectedWindow.reload, which reloads the page currently inspected by the DevTools window the extension is attached to. The DevTools extension server is supposed to stop an extension from running script against pages it is not allowed to touch, and it does this by blocking access once the URL of the inspected page changes.

The report describes how a race in that server, combined with a missing permission check on reload, lets an extension with devtools_page run arbitrary JavaScript on any privileged page, including chrome:// pages. The author then chains this with the local test policy feature of chrome://policy and the browser switcher policies to reach command execution on the host. The issue is tracked as CVE-2024-7017, an inappropriate implementation in DevTools, rated high severity, with a bounty of 20,000 USD, disclosed on 16 July 2024. The reporter credit is Allen Ding.

Setup

The author tested on Chromium across three platforms, with these builds:

Text
Chrome Version: 124.0.6367.78 (Official Build) 64-bit)
Operating System: Linux (Debian 12)
Chrome Version: 126.0.6453.0 (Developer Build) (64-bit)
Operating System: Windows 10 22H2
Chrome Version: 126.0.6452.0 (Developer Build) (x86_64)
Operating System: MacOS 11.7.10

The reproduction requires an extension that declares the devtools_page permission, plus the files attached to the report, placed in the same folder and loaded as a Chrome extension. The starting point is DevTools opened on about:blank or any other unprivileged page. The report also attaches a proof of concept for an alternative route, devtools_downloads.js, and videos demonstrating the attack.

Finding it

The author started from the observation that chrome.devtools.inspectedWindow.reload has no checks to see whether the extension is actually allowed to execute scripts on the inspected page. The only thing that prevents the API from being used against pages the extension should not touch is the DevTools extension server blocking access once the URL of the inspected page changes.

That block is easy to observe. Open chrome://settings/resetProfileSettings, click the "current settings" link, which opens an about:blank window with the chrome://settings origin, and open DevTools on that page. If the extension then calls chrome.devtools.inspectedWindow.reload, code runs on the privileged about:blank page. The check is on the URL, not on the page's origin.

Because only the URL is compared, there is a small window after a navigation starts where the origin has already been set to the new page but the URL has not yet changed. A reload call landing inside that window executes arbitrary JavaScript on the page being navigated to. That is the core of the bug: a race between the navigation and the permission check.

Exploitation

Step 1: win the race to get script execution on a chrome:// page

The window is small but can be hit fairly reliably by spamming chrome.devtools.inspectedWindow.reload calls and, at the same time, navigating the inspected tab with:

JavaScript
chrome.tabs.update(chrome.devtools.inspectedWindow.tabId, {url: "chrome://policy"});

The reload calls are the payload delivery; the tabs.update call starts the navigation whose origin/URL mismatch opens the window. When a reload lands in that window, the extension gets arbitrary JavaScript execution on the target chrome:// page, bypassing the permissions checks entirely.

Step 2: enable local test policies from chrome://policy

chrome://policy has a feature that lets a user set local policies for testing. It is disabled by default, but the WebUI message listener is registered regardless. So with code execution on the page, the extension can send:

JavaScript
cr.sendWithPromise("setLocalTestPolicies", policy, "");

Here policy is a JSON string containing a list of user policies to apply. Nothing checks whether local test policies are actually allowed at this point, and the policies are applied to the running browser immediately.

Step 3: understand why the guard on test policies does not hold

Two options are supposed to have to be explicitly enabled before local test policies work, and both checks fail. The feature flag policy::features::kEnablePolicyTestPage defaults to false and is supposed to be checked, but the check always fails. The policy policy_prefs::kPolicyTestPageEnabled is also checked, but it needs the pref_service argument passed into IsPolicyTestingEnabled; that argument is set to a nullptr when the function runs, which negates the check.

With both checks failing, only the release channel is considered. Channel::CANARY and Channel::DEFAULT are always allowed, and Channel::DEV works on Linux. Builds that are not branded as Google Chrome always report Channel::DEFAULT, so test policies are always allowed on Chromium and its derivatives, and on Google Chrome Canary and Dev.

Step 4: set the browser switcher policies

With arbitrary user policy available, the author sets four policies:

JavaScript
name: "BrowserSwitcherEnabled"
value: true

name: "BrowserSwitcherUrlList"
value: ["example.com"]

name: "AlternativeBrowserPath"
value: "/bin/bash"

name: "AlternativeBrowserParameters"
value: ["-c", "xcalc # ${url}"]

BrowserSwitcherEnabled turns the alternative browser switcher on, and BrowserSwitcherUrlList makes example.com a trigger. AlternativeBrowserPath points the "alternative browser" at Bash, and AlternativeBrowserParameters supplies the arguments, which is where the command to run is specified. The # ${url} is there so the page URL is substituted in as a comment rather than becoming its own argument.

Step 5: trigger the switcher

The extension navigates to example.com. That triggers the browser switcher, and Chrome runs:

Text
/bin/bash -c 'xcalc # https://example.com'

The report notes that /bin/bash (or cmd.exe) is set as the alternative browser. The report describes this as a sandbox escape.

Limits and alternatives

On official Google Chrome builds in the stable channel, chrome://policy will not work for the reasons above. chrome://downloads can be used for the sandbox escape instead, though it requires an extra user gesture; the proof of concept for that route is attached as devtools_downloads.js.

On Chrome OS a full sandbox escape is not possible, but the DevTools API permissions bypass still works, so considerable damage can still be done. The author notes it may be possible to run arbitrary code on chrome://settings, which can steal passwords, or on chrome://file-manager, which can possibly inject something into Crostini's bashrc.

Reproduction case

  1. Open Chromium on Windows, Linux or MacOS.
  2. Download the files attached to the report and place them in the same folder.
  3. Load the attached files as a Chrome extension.
  4. Open DevTools on about:blank or any other unprivileged page.

Root cause

The permission model for DevTools extensions relies on the extension server blocking access when the inspected page's URL changes, but the check compares the URL rather than the origin. During a navigation there is a period where the origin already belongs to the new page while the URL still reflects the old one, and chrome.devtools.inspectedWindow.reload has no independent check that the extension is allowed to script the inspected page. A reload issued in that period therefore runs on the destination page.

The second half of the chain is a design weakness in the local test policy feature: the WebUI message listener for setLocalTestPolicies is registered unconditionally, and the two guards that should gate it both fail. The feature flag check always fails, and the preference check is defeated because pref_service is passed as nullptr. That leaves the release channel as the only gate, and unbranded Chromium builds always report Channel::DEFAULT.

Impact

An extension holding the devtools_page permission can run arbitrary JavaScript on any privileged page, including chrome:// pages, without the user granting anything beyond that permission. On Chromium and its derivatives, and on Google Chrome Canary and Dev, this escalates through chrome://policy to arbitrary user policy and then, via the browser switcher policies, to command execution on the host as the user running the browser. On official stable Google Chrome the chrome://policy route does not work, but chrome://downloads can be used for the sandbox escape instead, though it requires an extra user gesture. On Chrome OS a full sandbox escape is not possible, but the permissions bypass still works; the author notes it may be possible to run arbitrary code on chrome://settings or chrome://file-manager.

Fix

The report does not describe a fix. It points at the code involved: the missing check in chrome.devtools.inspectedWindow.reload, the URL-only comparison in the extension server, and the failing IsPolicyTestingEnabled checks.

Variants to test

  1. Other DevTools APIs that act on the inspected page. Call them in the same race window against a chrome:// navigation and see whether script runs on the destination page; a positive result is any execution on a privileged origin.
  2. Other privileged pages with WebUI message handlers that are registered unconditionally. Look for handlers that change browser state and try to reach them after winning the race; a positive result is a state change that survives a restart or affects other profiles.
  3. Other policy-driven features that launch external programs or load paths, beyond the browser switcher. Set them through local test policies on a Chromium build and check whether a process starts; a positive result is execution of the configured binary.
  4. The chrome://downloads route on stable Google Chrome. Reproduce the extra user gesture and check whether the sandbox escape still completes; a positive result is command execution on a branded stable build.
  5. The Chrome OS surfaces the author names, chrome://settings and chrome://file-manager. Confirm script execution there and check whether credential material or Crostini's bashrc can be reached; a positive result is access to either.

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

What happened, in plain words

A browser extension is a small program you add to Chrome to change how it behaves. Some extensions are allowed to add features to DevTools, the panel built into Chrome that web developers use to inspect and change pages. This report is about a flaw that let one of those extensions run its own code on pages it should never be able to touch, including Chrome's own internal settings pages, and then use that foothold to run commands on the computer itself.

The chain has two halves. First, a timing problem (a "race condition") in the part of DevTools that decides which pages an extension may script, combined with a missing permission check, lets the extension run JavaScript on any privileged page. Second, one of those privileged pages, chrome://policy, has a testing feature that can apply settings to the browser, and those settings can be abused to launch an outside program. Put together, an extension that only asked for the devtools_page permission could end up running a command on your machine.

The issue is tracked as CVE-2024-7017, described as an inappropriate implementation in DevTools, rated high severity, with a bounty of 20,000 USD, disclosed on 16 July 2024. The reporter credit is Allen Ding.

A few words you will meet constantly below:

  • JavaScript is the programming language web pages run inside your browser. "Running JavaScript on a page" means making that page do things, as if the page's own code had done them.
  • An API (application programming interface) is a set of named actions one program offers to another. Think of a restaurant menu: you do not walk into the kitchen, you order from the list. chrome.devtools.inspectedWindow.reload is one item on the menu Chrome offers to extensions.
  • A permission is a specific item an extension is allowed to order from that menu. Chrome asks you to approve permissions when you install an extension.
  • A privileged page is one of Chrome's own internal pages, the ones whose address starts with chrome://. They control browser settings and are deliberately kept away from ordinary web content, because they are powerful.
  • A race condition is a bug where the result depends on which of two things happens first. Think of two people reaching for the same door handle at the same moment: normally nothing bad happens, but if the timing lines up, one gets through when they should not.
  • A sandbox is the cage the browser keeps web content in, so that a bad page cannot harm your computer. A "sandbox escape" is getting out of that cage.

Context

Chrome extensions that declare the devtools_page permission can extend DevTools. One of the APIs available to such an extension is chrome.devtools.inspectedWindow.reload, which reloads the page currently inspected by the DevTools window the extension is attached to. The DevTools extension server is supposed to stop an extension from running script against pages it is not allowed to touch, and it does this by blocking access once the URL of the inspected page changes.

The report describes how a race in that server, combined with a missing permission check on reload, lets an extension with devtools_page run arbitrary JavaScript on any privileged page, including chrome:// pages. The author then chains this with the local test policy feature of chrome://policy and the browser switcher policies to reach command execution on the host.

Two more terms from that paragraph:

  • The DevTools extension server is the internal part of DevTools that keeps track of which extension is attached to which inspected page, and decides what each extension may do there. It is the bouncer at the door.
  • A URL is the address of a page, such as https://example.com/page. An origin is the stricter identity behind that address: the scheme, the host and the port together. Two URLs on the same site share an origin; a URL and an origin are not the same thing, and this distinction matters later.

Setup

The author tested on Chromium across three platforms, with these builds:

Text
Chrome Version: 124.0.6367.78 (Official Build) 64-bit)
Operating System: Linux (Debian 12)
Chrome Version: 126.0.6453.0 (Developer Build) (64-bit)
Operating System: Windows 10 22H2
Chrome Version: 126.0.6452.0 (Developer Build) (x86_64)
Operating System: MacOS 11.7.10

Line by line: the first pair says the test ran on an official 64-bit build of Chrome 124 on Debian 12 Linux. The second pair says a developer build of Chrome 126 ran on Windows 10 22H2. The third pair says another developer build of Chrome 126 ran on macOS 11.7.10. "Chromium" is the open-source browser Chrome is built from; "developer build" is a test build rather than the normal release.

The reproduction requires an extension that declares the devtools_page permission, plus the files attached to the report, placed in the same folder and loaded as a Chrome extension. "Unpacked" means loading the extension straight from a folder on disk instead of installing it from the Chrome Web Store, which is how developers test their work. The starting point is DevTools opened on about:blank or any other unprivileged page. about:blank is the empty page a browser shows when there is nothing to show; it is unprivileged, meaning it is not one of Chrome's internal pages. The report also attaches a proof of concept for an alternative route, devtools_downloads.js, and videos demonstrating the attack.

Finding it

The author started from the observation that chrome.devtools.inspectedWindow.reload has no checks to see whether the extension is actually allowed to execute scripts on the inspected page. The only thing that prevents the API from being used against pages the extension should not touch is the DevTools extension server blocking access once the URL of the inspected page changes.

That block is easy to observe. Open chrome://settings/resetProfileSettings, click the "current settings" link, which opens an about:blank window with the chrome://settings origin, and open DevTools on that page. If the extension then calls chrome.devtools.inspectedWindow.reload, code runs on the privileged about:blank page. The check is on the URL, not on the page's origin.

Why does that matter? The new window shows an empty page, so its URL is about:blank, which looks harmless. But the window was opened from a settings page, so its origin is still chrome://settings, which is privileged. The bouncer looked at the address on the door and let it through, without checking who actually owned the room.

Because only the URL is compared, there is a small window after a navigation starts where the origin has already been set to the new page but the URL has not yet changed. A reload call landing inside that window executes arbitrary JavaScript on the page being navigated to. That is the core of the bug: a race between the navigation and the permission check.

Exploitation

Step 1: win the race to get script execution on a chrome:// page

The window is small but can be hit fairly reliably by spamming chrome.devtools.inspectedWindow.reload calls and, at the same time, navigating the inspected tab with:

JavaScript
chrome.tabs.update(chrome.devtools.inspectedWindow.tabId, {url: "chrome://policy"});

Line by line: chrome.tabs.update is the API for changing a browser tab. chrome.devtools.inspectedWindow.tabId is the identifier of the tab the DevTools window is inspecting, so the call targets exactly that tab. The second argument, {url: "chrome://policy"}, tells the tab to go to Chrome's policy page. In short: "take the tab I am inspecting and send it to chrome://policy."

The reload calls are the payload delivery; the tabs.update call starts the navigation whose origin/URL mismatch opens the window. When a reload lands in that window, the extension gets arbitrary JavaScript execution on the target chrome:// page, bypassing the permissions checks entirely. The reason for spamming is that the window is tiny: you cannot aim precisely, so you fire many times and hope one lands inside it, like repeatedly pressing a lift button as the doors close.

Step 2: enable local test policies from chrome://policy

chrome://policy has a feature that lets a user set local policies for testing. A policy in Chrome is a setting an administrator can impose on the browser, for example which home page it uses or which programs it may launch. The local test policy feature exists so administrators can try policies out without a management server. It is disabled by default, but the WebUI message listener is registered regardless. A WebUI message listener is the piece of the internal page that waits for messages from the page's own code and acts on them; "registered regardless" means it is listening even when the feature is supposed to be off.

So with code execution on the page, the extension can send:

JavaScript
cr.sendWithPromise("setLocalTestPolicies", policy, "");

Line by line: cr is the object the internal page uses to talk to the browser. sendWithPromise sends a named message and waits for a reply. The name here is "setLocalTestPolicies", which asks the browser to apply a set of test policies. policy is the data sent along: a JSON string containing a list of user policies to apply. JSON is a plain-text way of writing structured data, like a shopping list written in a fixed format so a program can read it. The final "" is an extra argument the message takes, sent empty here.

Nothing checks whether local test policies are actually allowed at this point, and the policies are applied to the running browser immediately.

Step 3: understand why the guard on test policies does not hold

Two options are supposed to have to be explicitly enabled before local test policies work, and both checks fail. The feature flag policy::features::kEnablePolicyTestPage defaults to false and is supposed to be checked, but the check always fails. A feature flag is an on/off switch inside the browser's code that turns a feature on or off; "defaults to false" means it starts switched off. The policy policy_prefs::kPolicyTestPageEnabled is also checked, but it needs the pref_service argument passed into IsPolicyTestingEnabled; that argument is set to a nullptr when the function runs, which negates the check. nullptr means "nothing here", an empty value where a real object was expected; a check that needs that object cannot work when it is missing.

With both checks failing, only the release channel is considered. The release channel is which edition of Chrome you run: stable (the normal one), beta, dev or canary (the most experimental). Channel::CANARY and Channel::DEFAULT are always allowed, and Channel::DEV works on Linux. Builds that are not branded as Google Chrome always report Channel::DEFAULT, so test policies are always allowed on Chromium and its derivatives, and on Google Chrome Canary and Dev. In other words, the only remaining guard is a label that says "this is a normal build", and unbranded Chromium always wears that label.

Step 4: set the browser switcher policies

With arbitrary user policy available, the author sets four policies:

JavaScript
name: "BrowserSwitcherEnabled"
value: true

name: "BrowserSwitcherUrlList"
value: ["example.com"]

name: "AlternativeBrowserPath"
value: "/bin/bash"

name: "AlternativeBrowserParameters"
value: ["-c", "xcalc # ${url}"]

Line by line: BrowserSwitcherEnabled with value true turns the alternative browser switcher on. The browser switcher is a Chrome feature that hands certain sites over to a different browser; here it is being pointed at a program of the attacker's choosing. BrowserSwitcherUrlList with value ["example.com"] makes example.com a trigger, so visiting that site starts the handover. AlternativeBrowserPath with value /bin/bash points the "alternative browser" at Bash, the command interpreter on Linux and macOS; a command interpreter (or shell) is a program that reads typed commands and runs them. AlternativeBrowserParameters with value ["-c", "xcalc # ${url}"] supplies the arguments: -c tells Bash to run the command that follows, and xcalc is a small calculator program. The # ${url} is there so the page URL is substituted in as a comment rather than becoming its own argument; in a shell, everything after # on a line is ignored, so the URL cannot break the command.

Step 5: trigger the switcher

The extension navigates to example.com. That triggers the browser switcher, and Chrome runs:

Text
/bin/bash -c 'xcalc # https://example.com'

Line by line: /bin/bash is the shell being started. -c says the next piece of text is the command to run. The command is xcalc, the calculator, and everything after # is a comment, so the URL is present but ignored. The report describes this as a sandbox escape: a program of the attacker's choice runs on the computer.

The report notes that /bin/bash (or cmd.exe) is set as the alternative browser.

Limits and alternatives

On official Google Chrome builds in the stable channel, chrome://policy will not work for the reasons above. chrome://downloads can be used for the sandbox escape instead, though it requires an extra user gesture; the proof of concept for that route is attached as devtools_downloads.js. A user gesture is a real action by the person using the browser, such as a click, which the browser requires before allowing certain sensitive things.

On Chrome OS a full sandbox escape is not possible, but the DevTools API permissions bypass still works, so considerable damage can still be done. The author notes it may be possible to run arbitrary code on chrome://settings, which can steal passwords, or on chrome://file-manager, which can possibly inject something into Crostini's bashrc. Crostini is the feature that lets Chrome OS run Linux programs; bashrc is a startup file the Linux shell reads every time it starts, so writing into it means your code runs later without being asked again.

Reproduction case

  1. Open Chromium on Windows, Linux or MacOS.
  2. Download the files attached to the report and place them in the same folder.
  3. Load the attached files as a Chrome extension.
  4. Open DevTools on about:blank or any other unprivileged page.

Root cause

The permission model for DevTools extensions relies on the extension server blocking access when the inspected page's URL changes, but the check compares the URL rather than the origin. During a navigation there is a period where the origin already belongs to the new page while the URL still reflects the old one, and chrome.devtools.inspectedWindow.reload has no independent check that the extension is allowed to script the inspected page. A reload issued in that period therefore runs on the destination page.

The second half of the chain is a design weakness in the local test policy feature: the WebUI message listener for setLocalTestPolicies is registered unconditionally, and the two guards that should gate it both fail. The feature flag check always fails, and the preference check is defeated because pref_service is passed as nullptr. That leaves the release channel as the only gate, and unbranded Chromium builds always report Channel::DEFAULT.

Impact

An extension holding the devtools_page permission can run arbitrary JavaScript on any privileged page, including chrome:// pages, without the user granting anything beyond that permission. On Chromium and its derivatives, and on Google Chrome Canary and Dev, this escalates through chrome://policy to arbitrary user policy and then, via the browser switcher policies, to command execution on the host as the user running the browser. On official stable Google Chrome the chrome://policy route does not work, but chrome://downloads can be used for the sandbox escape instead, though it requires an extra user gesture. On Chrome OS a full sandbox escape is not possible, but the permissions bypass still works; the author notes it may be possible to run arbitrary code on chrome://settings or chrome://file-manager.

Fix

The report does not describe a fix. It points at the code involved: the missing check in chrome.devtools.inspectedWindow.reload, the URL-only comparison in the extension server, and the failing IsPolicyTestingEnabled checks.

Variants to test

  1. Other DevTools APIs that act on the inspected page. Call them in the same race window against a chrome:// navigation and see whether script runs on the destination page; a positive result is any execution on a privileged origin.
  2. Other privileged pages with WebUI message handlers that are registered unconditionally. Look for handlers that change browser state and try to reach them after winning the race; a positive result is a state change that survives a restart or affects other profiles.
  3. Other policy-driven features that launch external programs or load paths, beyond the browser switcher. Set them through local test policies on a Chromium build and check whether a process starts; a positive result is execution of the configured binary.
  4. The chrome://downloads route on stable Google Chrome. Reproduce the extra user gesture and check whether the sandbox escape still completes; a positive result is command execution on a branded stable build.
  5. The Chrome OS surfaces the author names, chrome://settings and chrome://file-manager. Confirm script execution there and check whether credential material or Crostini's bashrc can be reached; a positive result is access to either.

Glossary

  • API: a set of named actions one program offers to another, like a menu you order from.
  • Browser switcher: a Chrome feature that hands certain sites over to a different browser; here abused to launch an arbitrary program.
  • Bash: the command interpreter (shell) on Linux and macOS that reads and runs commands.
  • Bashrc: a startup file the Linux shell reads each time it starts, so writing to it makes code run later.
  • Channel (release channel): which edition of Chrome you run, such as stable, beta, dev or canary.
  • Chromium: the open-source browser that Google Chrome is built from.
  • Command interpreter (shell): a program that reads typed commands and runs them.
  • Crostini: the feature that lets Chrome OS run Linux programs.
  • CVE: a public identifier given to a known security vulnerability.
  • DevTools: the panel built into Chrome for inspecting and changing web pages.
  • DevTools extension server: the internal part of DevTools that tracks attached extensions and decides what each may do.
  • Extension: a small program added to Chrome to change its behaviour.
  • Feature flag: an on/off switch inside the browser's code that enables or disables a feature.
  • JavaScript: the programming language web pages run inside the browser.
  • JSON: a plain-text format for structured data that programs can read.
  • nullptr: a programming value meaning "nothing here", an empty slot where a real object was expected.
  • Origin: the strict identity of a page, made of scheme, host and port together.
  • Permission: a specific capability an extension is allowed to use, approved at install time.
  • Policy: a setting an administrator can impose on the browser.
  • Privileged page: one of Chrome's own internal pages, whose address starts with chrome://.
  • Race condition: a bug where the result depends on which of two things happens first.
  • Release channel: see Channel.
  • Sandbox: the cage the browser keeps web content in so a bad page cannot harm the computer.
  • Sandbox escape: getting out of that cage.
  • Shell: see Command interpreter.
  • Unpacked extension: an extension loaded straight from a folder on disk rather than installed from the store.
  • URL: the address of a page, such as https://example.com/page.
  • User gesture: a real action by the user, such as a click, that the browser requires before allowing certain sensitive things.
  • WebUI message listener: the part of an internal page that waits for messages from the page's own code and acts on them.

More by Allen Ding

View all

2 more disclosed reports, best first.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.