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

Race in DevTools (CVE-2024-6778)

A race condition in Chrome DevTools allows an extension with the devtools_page permission to execute arbitrary JavaScript on privileged pages. By crashing the inspected page while a reload command is pending, the injected script is queued and later runs on a chrome:// page, potentially leading to sandbox escape.

Allen Ding Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 2 months

As requested, I am submitted this as a separate issue. The original bug report (with the full chain leading to a sandbox escape) is located at https://issues.chromium.org/issues/338248595

VULNERABILITY DETAILS

  1. The user opens devtools on any unprivileged page, which will load our devtools extension as an iframe and give access to the chrome.devtools API
  2. The extension navigates the inspected page to example.org, then it evaluates location.href = "about:blank" inside the page. This resets the page's origin.
  3. The extension runs chrome.devtools.inspectedWindow.reload and puts a debugger statement in the injectedScript argument.
  4. The extension runs chrome.devtools.inspectedWindow.reload again with the JS payload in the injectedScript argument. This crashes the inspected page.
  5. The extension navigates the crashed page to a chrome:// page, which will cause the previously queued up JS to execute on the privileged page.

EXPLANATION

An extension with the devtools_page permission in its manifest.json file can use the chrome.devtools.inspectedWindow.reload API, which reloads the inspected page and injects a content script. It is possible to use this API to run arbitrary JS on any page, even if it is supposed to be disallowed.

Normally, pending devtools commands are discarded after a page crash. However, Page.reload method calls are whitelisted and will not be removed. Essentially this is due to an incomplete fix for crbug.com/40053357. If the page crashes while it is being reloaded by the extension, then the JS will be queued to run after the page is reloaded another time. Thus, we can just navigate the inspected page to any privileged page of our choosing (with chrome.tabs.update), and our custom JS will run on the page we navigate to.

A crash can be caused with the debugger statement in the content script, or with [...new Array(2**31)]. Using the debugger statement causes a crash since it puts navigation_commit_state_ into an unexpected state. This happens when RenderFrameImpl::SynchronouslyCommitAboutBlankForBug778318 is run, which modifies _navigation_commit_state to a different value. This also means that if the debugger statement is used, the page must be on the about:blank URL for the crash to occur.

Resetting the inspected page's origin must occur since we do not want to crash our own extension process. Note that using the debugger statement isn't the only way to cause a crash here. You can also use [...new Array(2**31)], but this will take a a few seconds longer to run. As long as the page crashes while the reload command is still pending, the exploit will work.

BISECT

The mechanism which queues up devtools messages after a crash was added 9 years ago, on commit a8622c18940eac1db5c75685d0c09c7eedecf833 (position 332838).

I confirmed that this is the commit which introduced this bug, since I was able to reproduce it on version 45.0.2423.0 (position 332839), but not on position 332834.

PATCH

Removing the exception for Page.reload commands in DevToolsSession::ClearPendingMessages is enough to fix this bug. I have tested this to work by compiling and running Chromium with the patch applied. I've attached the diff for this as fix-devtools-reload-bug.patch.

VERSION

Chrome Version: 124.0.6367.201 stable

Operating System: Debian 12

REPRODUCTION

  1. Download the files attached to this report, and place them in the same folder.
  2. Load the attached files as a Chrome extension.
  3. Open devtools on about:blank or any other unprivileged page.
  4. The extension will navigate to chrome://settings and show an alert.

A video is attached which demonstrates this process.

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.

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

How it worked

Root cause

Likely, the DevToolsSession::ClearPendingMessages function does not clear pending Page.reload commands after a page crash, allowing injected scripts to persist and execute on a subsequent page navigation.

Impact

An attacker could execute arbitrary JavaScript on privileged chrome:// pages, potentially leading to sandbox escape and full system compromise.

What the attacker needed

Victim installs a malicious Chrome extension; Victim opens DevTools on a page

The fix

The exception for Page.reload commands in DevToolsSession::ClearPendingMessages should be removed to ensure pending commands are cleared after a crash.

How it was found

  1. Open DevTools on an unprivileged page, loading the malicious extension as an iframe.
  2. The extension navigates the inspected page to example.org and then sets location.href to about:blank to reset the origin.
  3. The extension calls chrome.devtools.inspectedWindow.reload with a debugger statement in the injectedScript argument.
  4. The extension calls chrome.devtools.inspectedWindow.reload again with the JS payload, causing the inspected page to crash.
  5. The extension navigates the crashed page to a chrome:// page, causing the queued JS to execute on the privileged page.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

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

A browser extension can use a special developer tools feature to inject code into web pages. Normally, this is limited to the page being inspected. However, due to a timing flaw, if the page crashes at the right moment, the injected code can be made to run on a sensitive browser page instead, which could let an attacker take control of the browser.

What is Race condition?

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

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.