Skip to content
Memory corruption Advisory Advanced CVE-2024-3158

Use after free in Bookmarks (CVE-2024-3158)

A use-after-free vulnerability exists in Chrome's bookmark price tracking feature, where a callback holds a raw pointer to a WebContents object that can be freed before the callback runs. An attacker could potentially exploit this to cause a crash or possibly execute arbitrary code.

undoingfish Follow

Originally disclosed on Chrome VRP

Bounty$3,000 High View original
  • Fix shipped in 17 days

Chrome Version: 124.0.6363.0 (Developer Build) OS: Win10

Steps to reproduce the problem: (1) apply repro.patch and compile chrome in asan version, download the extension file attached. (2) run chrome.exe --load-extension=path_to_extension (3) navigate to an website that can trigger the price_tracking service. eg: https://issues.chromium.org/issues?q=type:vulnerability%20-status:obsolete (4) click the icon in the navigation bar to add this website as a bookmark. (5) crash occurs.

Problem Description: In CreatePriceTrackingEmailCallback, it binds a callback with raw pointer of web_contents [1]:

base::OnceCallback<void()> CreatePriceTrackingEmailCallback( Profile* profile, views::View* anchor_view, content::WebContents* web_contents, const bookmarks::BookmarkNode* bookmark) { ...... base::OnceCallback<void()> show_dialog_callback = base::BindOnce( [](content::WebContents* web_contents, Profile* profile, views::View* anchor) { if (!web_contents || !profile || !anchor) { return; } PriceTrackingEmailDialogCoordinator(anchor).Show(web_contents, profile, base::DoNothing()); }, // TODO(crbug.com/1380714): Remove UnsafeDanglingUntriaged base::UnsafeDanglingUntriaged(web_contents), profile, anchor_view); // [1]

return base::BindOnce( [](Profile* profile, const bookmarks::BookmarkNode* node, base::OnceCallback<void()> show_dialog) { commerce::IsBookmarkPriceTracked( commerce::ShoppingServiceFactory::GetForBrowserContext(profile), BookmarkModelFactory::GetForBrowserContext(profile), node, base::BindOnce( [](base::OnceCallback<void()> show_dialog, bool is_tracked) { if (is_tracked) { std::move(show_dialog).Run(); // [2]
} }, std::move(show_dialog))); }, profile, bookmark, std::move(show_dialog_callback)); }

And the callback will be posted to an task and finally runs in [2]. Before the callback runs, we can free the web_contents by close the tab with extension.

The repro.patch file is just to make it easier for us to reproduce this issue.

[1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc;l=151 [2] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc;l=162

The original report as published on the Chromium issue tracker, by undoingfish. 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. 5 min read.

Context

This is a use-after-free in Google Chrome's bookmarks UI, tracked as CVE-2024-3158 and reported through the Chrome VRP by the researcher undoingfish. The affected component is Bookmarks, and the crash is reached through the price tracking feature: when a page is bookmarked, Chrome checks whether the bookmark is price-tracked and, if it is, shows a price tracking email dialog. The bug sits in the code that wires that check to the dialog.

The report is an advisory-style write-up: a reproducible crash on a developer build, a code excerpt showing the lifetime problem, and a short explanation of the race. There is no remote attack chain described, only a local reproduction with a crafted extension.

Setup

The researcher used:

  • Chrome version: 124.0.6363.0 (Developer Build)
  • OS: Win10
  • An AddressSanitizer (ASan) build of Chrome, compiled after applying a repro.patch file
  • An extension file, attached to the report, loaded from disk

The repro.patch file is described as existing only to make the issue easier to reproduce. The report does not detail what the patch changes.

Finding it

The researcher points at CreatePriceTrackingEmailCallback in chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc. That function builds a callback chain: an inner callback that shows the price tracking email dialog, and an outer callback that asks the commerce service whether the bookmark is price-tracked and, if so, runs the inner callback.

The inner callback captures content::WebContents* web_contents as a raw pointer, wrapped in base::UnsafeDanglingUntriaged. The comment above it reads:

Text
// TODO(crbug.com/1380714): Remove `UnsafeDanglingUntriaged`

That annotation is the tell: the pointer is known to be potentially dangling, and the code is opting out of the dangling-pointer checks rather than fixing the lifetime. The researcher then traced when the captured pointer is actually dereferenced.

Exploitation

Step 1: build and prepare

Apply repro.patch and compile Chrome in an ASan version, then download the attached extension file. The patch is only there to make reproduction easier; the report does not describe its contents.

Step 2: load the extension

Text
chrome.exe --load-extension=path_to_extension

This starts Chrome with the extension loaded from the given path. The report says the tab is closed with the extension, but does not describe how the extension does it.

Step 3: navigate to a page that triggers the price tracking service

The example given is:

Text
https://issues.chromium.org/issues?q=type:vulnerability%20-status:obsolete

Any website that can trigger the price_tracking service works. This step puts the browser in the state where bookmarking the page will go through the price tracking path.

Step 4: bookmark the page

Click the icon in the navigation bar to add the current website as a bookmark. This invokes the bookmark bubble logic, which calls CreatePriceTrackingEmailCallback and posts the callback chain to a task.

Step 5: close the tab before the callback runs

With the extension, close the tab. The callback has not run yet, so the WebContents it captured can be freed first. When the posted task finally runs, it dereferences the freed WebContents: the crash occurs.

Root cause

The vulnerable function binds a callback with a raw pointer to web_contents:

Text
base::OnceCallback<void()> CreatePriceTrackingEmailCallback(
    Profile* profile,
    views::View* anchor_view,
    content::WebContents* web_contents,
    const bookmarks::BookmarkNode* bookmark) {
......
  base::OnceCallback<void()> show_dialog_callback = base::BindOnce(
      [](content::WebContents* web_contents, Profile* profile,
         views::View* anchor) {
        if (!web_contents || !profile || !anchor) {
          return;
        }
        PriceTrackingEmailDialogCoordinator(anchor).Show(web_contents, profile,
                                                         base::DoNothing());
      },
      // TODO(crbug.com/1380714): Remove `UnsafeDanglingUntriaged`
      base::UnsafeDanglingUntriaged(web_contents), profile, anchor_view);           // [1]

  return base::BindOnce(
      [](Profile* profile, const bookmarks::BookmarkNode* node,
         base::OnceCallback<void()> show_dialog) {
        commerce::IsBookmarkPriceTracked(
            commerce::ShoppingServiceFactory::GetForBrowserContext(profile),
            BookmarkModelFactory::GetForBrowserContext(profile), node,
            base::BindOnce(
                [](base::OnceCallback<void()> show_dialog, bool is_tracked) {
                  if (is_tracked) {
                    std::move(show_dialog).Run();                                             // [2]
                  }
                },
                std::move(show_dialog)));
      },
      profile, bookmark, std::move(show_dialog_callback));
}

The callback is posted to a task and finally runs at [2]. Between posting and running, the tab can be closed, which frees the WebContents. The null check inside the lambda does not help: the pointer is not null, it is dangling, so the check passes and PriceTrackingEmailDialogCoordinator(...).Show(web_contents, ...) is called with freed memory.

The base::UnsafeDanglingUntriaged wrapper marks the pointer as untriaged and unsafe, opting out of the dangling-pointer check. The report cites the two relevant lines in the Chromium source:

Impact

The platform records this as a use-after-free in Bookmarks, rated high severity, with a bounty of 3000.00 USD. The demonstrated effect is a crash in the ASan developer build when a bookmarked page goes through the price tracking path and the tab is closed before the posted callback runs.

Fix

The code itself points at the intended direction: the TODO(crbug.com/1380714) asks for UnsafeDanglingUntriaged to be removed, which means the raw WebContents pointer should not be captured across the asynchronous task. A safe fix would hold a weak reference (for example a base::WeakPtr<content::WebContents>) and bail out if it is no longer valid when the callback runs, rather than relying on a null check on a raw pointer.

Variants to test

  1. Other callbacks that capture WebContents* or views::View* raw pointers and are posted to a task. Positive result: closing the tab or destroying the view before the task runs produces an ASan use-after-free report.
  2. Other uses of base::UnsafeDanglingUntriaged in the codebase. Positive result: a path where the annotated pointer outlives its object and is dereferenced after the task boundary.
  3. UI flows that show a dialog after an asynchronous service check (commerce, permissions, payments). Positive result: the dialog coordinator receives a freed WebContents when the tab is closed during the check.
  4. Extension-driven tab closing during pending browser UI tasks. Positive result: a reproducible crash with the extension loaded and the tab closed at the right moment, as in this report.

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

What happened, in plain words

Google Chrome has a feature called price tracking. When you bookmark a shopping page, Chrome can offer to email you when the price of that item changes. To decide whether to show that offer, Chrome asks a background service whether the bookmark is already being price-tracked, and then, if the answer is yes, it opens a small dialog asking for your email.

That sequence has a timing problem. Chrome does not open the dialog immediately. It puts the job on a queue (a "task") and comes back to it a moment later. While the job waits in the queue, it is holding on to a pointer, which is a memory address, to the browser tab it belongs to. If you close that tab before the queued job runs, the tab's memory is freed. The queued job then runs anyway and uses the address of memory that no longer exists. That is the bug class called use after free: the program uses a piece of memory after it has been given back.

This report, tracked as CVE-2024-3158 and reported through the Chrome VRP by the researcher undoingfish, shows a reproducible crash of this kind in Chrome's bookmarks interface. The affected component is Bookmarks. The researcher reproduced it on a developer build of Chrome with a small extension that closes the tab at the right moment. The report is an advisory-style write-up: a crash recipe, a code excerpt showing the lifetime problem, and a short explanation of the race. It does not describe a remote attack chain, only a local reproduction with a crafted extension.

A few words before we start, because the rest of the article uses them constantly:

  • A pointer is a number that says where something lives in the computer's memory, like a house address. The program does not carry the house around; it carries the address and goes there when it needs the thing.
  • Freeing memory means telling the operating system "I am done with this block, you can reuse it". The address still exists as a number, but whatever is at that address is no longer yours.
  • A callback is a piece of code you hand to someone else and say "run this later, when the time is right". It is like leaving a note with a colleague: the note runs when they get to it, not when you wrote it.
  • A task (or "posted task") is a job placed on a queue inside the browser. The browser works through the queue one job at a time. Between placing a job and running it, other things happen, including things the user does, like closing a tab.
  • ASan (AddressSanitizer) is a debugging tool built into a special version of the program. It watches memory use and shouts loudly when code touches memory that has been freed. Researchers compile Chrome with ASan so that a use-after-free turns into a clear, immediate error instead of silent corruption.

Context

This is a use-after-free in Google Chrome's bookmarks UI, tracked as CVE-2024-3158 and reported through the Chrome VRP by the researcher undoingfish. The affected component is Bookmarks, and the crash is reached through the price tracking feature: when a page is bookmarked, Chrome checks whether the bookmark is price-tracked and, if it is, shows a price tracking email dialog. The bug sits in the code that wires that check to the dialog.

The report is an advisory-style write-up: a reproducible crash on a developer build, a code excerpt showing the lifetime problem, and a short explanation of the race. There is no remote attack chain described, only a local reproduction with a crafted extension.

Setup

The researcher used:

  • Chrome version: 124.0.6363.0 (Developer Build)
  • OS: Win10
  • An AddressSanitizer (ASan) build of Chrome, compiled after applying a repro.patch file
  • An extension file, attached to the report, loaded from disk

The repro.patch file is described as existing only to make the issue easier to reproduce. The report does not detail what the patch changes.

Why each piece matters: a developer build is a version of Chrome built from source rather than downloaded as a finished product, so the researcher can add patches and compile with debugging tools. ASan is the tool that turns the use-after-free into a visible crash report. The extension is used to close the tab before the queued job runs. The patch is a convenience, not part of the bug.

Finding it

The researcher points at CreatePriceTrackingEmailCallback in chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc. That function builds a callback chain: an inner callback that shows the price tracking email dialog, and an outer callback that asks the commerce service whether the bookmark is price-tracked and, if so, runs the inner callback.

The inner callback captures content::WebContents* web_contents as a raw pointer, wrapped in base::UnsafeDanglingUntriaged. The comment above it reads:

Text
// TODO(crbug.com/1380714): Remove `UnsafeDanglingUntriaged`

That annotation is the tell: the pointer is known to be potentially dangling, and the code is opting out of the dangling-pointer checks rather than fixing the lifetime. The researcher then traced when the captured pointer is actually dereferenced.

A raw pointer is a plain address with no safety net: nothing tracks whether the thing at that address still exists. A dangling pointer is a raw pointer whose target has been freed. Chrome has tooling that tries to detect dangling pointers, and base::UnsafeDanglingUntriaged is a marker that says "do not check this one, we have not triaged it yet". The TODO comment is a note to future developers to remove that marker once the lifetime is fixed. In other words, the code itself admits the pointer might dangle.

Exploitation

Step 1: build and prepare

Apply repro.patch and compile Chrome in an ASan version, then download the attached extension file.

Why: you cannot reproduce a memory-safety bug reliably in a normal release build, because the freed memory may still contain the old data and nothing complains. ASan makes the moment of misuse loud and precise.

Step 2: load the extension

Text
chrome.exe --load-extension=path_to_extension

This starts Chrome with the extension loaded from the given path. The extension is what allows the tab to be closed at the moment that matters, as described below.

Line by line: chrome.exe is the Chrome program on Windows. --load-extension= is a command-line switch that tells Chrome to load an extension from a folder on disk instead of from the web store. path_to_extension is a placeholder for the folder where the attached extension was unpacked.

Step 3: navigate to a page that triggers the price tracking service

The example given is:

Text
https://issues.chromium.org/issues?q=type:vulnerability%20-status:obsolete

Any website that can trigger the price_tracking service works. This step puts the browser in the state where bookmarking the page will go through the price tracking path.

Why: the bug only lives on the price tracking code path. If you bookmark a page that the commerce service does not consider price-trackable, Chrome never builds the callback chain that contains the bug. The example URL is given as a website that can trigger the price tracking service.

Step 4: bookmark the page

Click the icon in the navigation bar to add the current website as a bookmark. This invokes the bookmark bubble logic, which calls CreatePriceTrackingEmailCallback and posts the callback chain to a task.

Why: this is the action that builds the vulnerable callback and puts it on the queue. At this point the tab is still alive, the pointer is still valid, and nothing is wrong yet. The problem is what happens next.

Step 5: close the tab before the callback runs

With the extension, close the tab. The callback has not run yet, so the WebContents it captured can be freed first. When the posted task finally runs, it dereferences the freed WebContents: the crash occurs.

Why: this is the race. The queued job holds an address to the tab. Closing the tab frees that memory. The queued job then runs and follows the stale address.

Root cause

The vulnerable function binds a callback with a raw pointer to web_contents:

Text
base::OnceCallback<void()> CreatePriceTrackingEmailCallback(
    Profile* profile,
    views::View* anchor_view,
    content::WebContents* web_contents,
    const bookmarks::BookmarkNode* bookmark) {
......
  base::OnceCallback<void()> show_dialog_callback = base::BindOnce(
      [](content::WebContents* web_contents, Profile* profile,
         views::View* anchor) {
        if (!web_contents || !profile || !anchor) {
          return;
        }
        PriceTrackingEmailDialogCoordinator(anchor).Show(web_contents, profile,
                                                         base::DoNothing());
      },
      // TODO(crbug.com/1380714): Remove `UnsafeDanglingUntriaged`
      base::UnsafeDanglingUntriaged(web_contents), profile, anchor_view);           // [1]

  return base::BindOnce(
      [](Profile* profile, const bookmarks::BookmarkNode* node,
         base::OnceCallback<void()> show_dialog) {
        commerce::IsBookmarkPriceTracked(
            commerce::ShoppingServiceFactory::GetForBrowserContext(profile),
            BookmarkModelFactory::GetForBrowserContext(profile), node,
            base::BindOnce(
                [](base::OnceCallback<void()> show_dialog, bool is_tracked) {
                  if (is_tracked) {
                    std::move(show_dialog).Run();                                             // [2]
                  }
                },
                std::move(show_dialog)));
      },
      profile, bookmark, std::move(show_dialog_callback));
}

The callback is posted to a task and finally runs at [2]. Between posting and running, the tab can be closed, which frees the WebContents. The null check inside the lambda does not help: the pointer is not null, it is dangling, so the check passes and PriceTrackingEmailDialogCoordinator(...).Show(web_contents, ...) is called with freed memory.

The base::UnsafeDanglingUntriaged wrapper is the reason the usual dangling-pointer instrumentation did not catch this earlier: it explicitly marks the pointer as untriaged and unsafe, suppressing the check. The report cites the two relevant lines in the Chromium source:

Walking through the code in plain words:

  1. CreatePriceTrackingEmailCallback is a function that takes four things: a Profile (the browser profile, which holds settings and services), a views::View* anchor_view (the piece of UI the dialog should point at), a content::WebContents* web_contents (the tab itself), and a bookmarks::BookmarkNode* bookmark (the bookmark that was just created).
  2. Inside, it builds show_dialog_callback with base::BindOnce. Binding means "take this function and these arguments, and give me back a packaged job I can run later". The packaged job is the inner lambda, the small anonymous function that opens the dialog.
  3. The inner lambda first checks if (!web_contents || !profile || !anchor). This is a null check: it asks "is any of these addresses zero?". A zero address means "nothing here". This check is meant as a safety net, but it only catches null, not freed.
  4. If the check passes, it calls PriceTrackingEmailDialogCoordinator(anchor).Show(web_contents, profile, base::DoNothing()), which opens the price tracking email dialog for that tab.
  5. The arguments handed to base::BindOnce include base::UnsafeDanglingUntriaged(web_contents). That wrapper is the marker that tells Chrome's dangling-pointer tooling to skip this pointer. The // [1] marker points at the source line.
  6. The function then returns a second packaged job built with another base::BindOnce. This outer job asks commerce::IsBookmarkPriceTracked(...) whether the bookmark is price-tracked. When the answer comes back, the inner lambda at // [2] runs: if is_tracked is true, it runs show_dialog, which is the inner callback from step 2.
  7. The key point: the outer job is asynchronous. It is posted to a task and runs later. The inner job, holding the raw web_contents pointer, travels with it. If the tab is closed in between, the pointer is stale, the null check still passes because the address is not zero, and Show is called with freed memory.

Impact

The platform records this as a use-after-free in Bookmarks, rated high severity, with a bounty of 3000.00 USD. The demonstrated effect is a crash of the browser process when a bookmarked page goes through the price tracking path and the tab is closed before the posted callback runs.

In plain terms: the researcher showed a way to crash the ASan developer build of Chrome. A crash is a denial of service, not by itself a way to read data or run code. The report does not claim more than the crash.

Fix

The code itself points at the intended direction: the TODO(crbug.com/1380714) asks for UnsafeDanglingUntriaged to be removed, which means the raw WebContents pointer should not be captured across the asynchronous task. A safe fix would hold a weak reference (for example a base::WeakPtr<content::WebContents>) and bail out if it is no longer valid when the callback runs, rather than relying on a null check on a raw pointer.

A weak reference is like a library reservation slip rather than the book itself: it lets you ask "is this still here?" before using it, and it becomes invalid automatically when the object is destroyed. A raw pointer cannot answer that question; it just points. That is why the null check is not enough and why the fix has to change what is captured, not just add another check.

Variants to test

  1. Other callbacks that capture WebContents* or views::View* raw pointers and are posted to a task. Positive result: closing the tab or destroying the view before the task runs produces an ASan use-after-free report.
  2. Other uses of base::UnsafeDanglingUntriaged in the codebase. Positive result: a path where the annotated pointer outlives its object and is dereferenced after the task boundary.
  3. UI flows that show a dialog after an asynchronous service check (commerce, permissions, payments). Positive result: the dialog coordinator receives a freed WebContents when the tab is closed during the check.
  4. Extension-driven tab closing during pending browser UI tasks. Positive result: a reproducible crash with the extension loaded and the tab closed at the right moment, as in this report.

Why these variants: the same shape of mistake, a raw pointer captured across a delay, can appear anywhere the browser queues work and then touches UI. Each variant is a way to look for the same pattern elsewhere, and each has a clear signal that you found it: an ASan report, or a crash that reproduces with the extension loaded.

Glossary

  • AddressSanitizer (ASan): a debugging tool built into a special build of a program that detects memory misuse, such as using memory after it has been freed, and reports it immediately.
  • Asynchronous: work that is started now but finishes later, so other things can happen in between.
  • Bookmark: a saved link to a web page, stored in the browser so you can return to it.
  • Bookmark bubble: the small pop-up Chrome shows when you bookmark a page, offering options related to that bookmark.
  • Callback: a piece of code handed to another part of the program to be run later, when a condition is met.
  • CVE: a public identifier for a known security vulnerability, so people can refer to it unambiguously.
  • Chrome VRP: Google Chrome's Vulnerability Reward Program, which pays researchers for reporting security bugs.
  • Commerce service: the part of Chrome that handles shopping-related features, including price tracking.
  • Dangling pointer: a pointer whose target has been freed, so the address no longer refers to valid data.
  • Developer build: a version of Chrome compiled from source by the researcher, rather than the normal released product.
  • Extension: a small add-on program that runs inside the browser and can automate actions, such as closing a tab.
  • Free (memory): to release a block of memory back to the system so it can be reused; the old address becomes invalid.
  • Lambda: an unnamed, inline function written directly where it is used.
  • Null check: a test that an address is not zero, meaning "something is there". It does not tell you whether that something is still alive.
  • Pointer: a value that holds the memory address of something, like a house address rather than the house.
  • Price tracking: a Chrome feature that watches the price of a bookmarked product and can email you when it changes.
  • Profile: the browser profile, the collection of settings, bookmarks and services tied to a user.
  • Race condition: a bug that depends on the timing of two events, where the wrong order produces a failure.
  • Raw pointer: a plain memory address with no automatic safety tracking.
  • Task (posted task): a job placed on the browser's internal queue to be run later.
  • Use after free: a bug where a program uses memory after it has been freed, which can crash the program or, in worse cases, corrupt data.
  • Weak reference: a reference that does not keep an object alive and can be checked to see whether the object still exists.
  • WebContents: Chrome's internal object representing a single tab's web page content.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.