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

Use after free in Downloads (CVE-2024-3834)

The DownloadInternalsUIMessageHandler on iOS registers itself as an observer of the download service logger but never removes itself when destroyed, leaving a dangling pointer. When the logger later sends a notification, it calls a method on the freed object, causing a use-after-free that can crash the browser.

ChaobinZhang Follow

Originally disclosed on Chrome VRP

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

VULNERABILITY DETAILS

Bitset: https://chromium-review.googlesource.com/c/chromium/src/+/3072886

DownloadInternalsUIMessageHandler::RegisterMessages add self as observer into the logger of background download service.

C++
class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
                                          public download::Logger::Observer {
 private:
  // WebUIIOSMessageHandler implementation.
  void RegisterMessages() override {
    // redacted ...

    if (download_service_)
      download_service_->GetLogger()->AddObserver(this); // <-- Add self as observer
  }
}

https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc;l=65;drc=d236ab1a0320384b0267eec9b6765c666944984d

However, there is not RemoveObserver in ~DownloadInternalsUIMessageHandler(), so the observer will not be removed even though the object of DownloadInternalsUIMessageHandler is freed. The lifetime of DownloadInternalsUIMessageHandler object is bound with WebUI for chrome://download-internals on iOS. New tab with url: chrome://download-internals and then close it will result in a dangling observer in unchecked observers_ of download::LoggerImpl.

C++
namespace download {

class LoggerImpl : public Logger, public LogSink {
 // redacted ...
 private:
  base::ObserverList<Observer>::Unchecked observers_;   // <-- Observers is unchecked, can not prevent UAF if observer has been freed but not removed.
};

}  // namespace download

https://source.chromium.org/chromium/chromium/src/+/main:components/download/internal/background_service/logger_impl.h;l=58;drc=8ba1bad80dc22235693a0dd41fe55c0fd2dbdabd

So when the notification happened after the object of |DownloadInternalsUIMessageHandler| is freed, UAF will be triggered.

C++
class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
                                          public download::Logger::Observer {
  // download::Logger::Observer implementation.
  void OnServiceDownloadChanged(
      const base::Value::Dict& service_download) override {
    web_ui()->FireWebUIListener("service-download-changed", service_download);  // <-- UAF in web_ui()
  }
}

https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc;l=87;drc=d236ab1a0320384b0267eec9b6765c666944984d

Fix suggestion:

Diff
diff --git a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
index 9e35041dc4046..fecfe5d876062 100644
--- a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
+++ b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
@@ -34,7 +34,11 @@ class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
   DownloadInternalsUIMessageHandler(const DownloadInternalsUIMessageHandler&) =
       delete;
   void operator=(const DownloadInternalsUIMessageHandler&) = delete;
-  ~DownloadInternalsUIMessageHandler() override = default;
+
+  ~DownloadInternalsUIMessageHandler() override {
+    if (download_service_)
+      download_service_->GetLogger()->RemoveObserver(this);
+  }
 
  private:
   // WebUIIOSMessageHandler implementation.

VERSION

  • Chrome Version: 122.0.6261.62 (Official Build) stable (64 bit)
  • Operating System: iOS

REPRODUCTION CASE

  1. Open chrome://download-internals/ and close it
  2. Open new tab with chrome://download-internals/, input any valid URL and click Download button

Another:

  1. Run command nc -l 8000 on linux.
  2. Open chrome://download-internals on iOS, input http://<your-ip>:8000/poc and click Download, close the tab.
  3. Ctrl + C to kill nc on linux, chrome on iOS crashed.

There is a POC video in attachements.

FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION

  • Type of crash: browser
  • Crash ID: crash/c818bdbca3b2d430

CREDIT INFORMATION

Reporter credit: ChaobinZhang

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

Context

This is a use-after-free in the iOS implementation of Chrome's chrome://download-internals page, tracked as CVE-2024-3834 and reported through the Chrome VRP by ChaobinZhang. The page is a WebUI that exposes the state of the background download service to the user. Internally, the page's message handler subscribes to the download service's logger so that it can push updates into the page as they happen.

The bug is a lifetime problem: the handler registers itself as an observer of the logger but never unregisters, so once the WebUI is torn down the logger keeps a pointer to freed memory and later dereferences it.

Setup

  • Target: Google Chrome on iOS.
  • Version tested: 122.0.6261.62 (Official Build) stable (64 bit).
  • Operating system: iOS.
  • No account or special role is needed; the page is reachable from the address bar.
  • For the second reproduction, a Linux host on the same network running nc is used to serve a download that can be stalled and then killed.

The relevant code lives in ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc and components/download/internal/background_service/logger_impl.h.

Finding it

The researcher looked at how DownloadInternalsUIMessageHandler wires itself into the download service. In RegisterMessages the handler adds itself as an observer of the background download service's logger:

What stood out is the absence of the matching call in the destructor: ~DownloadInternalsUIMessageHandler() does not call RemoveObserver. The lifetime of the handler object is bound to the WebUI for chrome://download-internals on iOS, so closing the tab frees the handler while the logger still holds it.

The logger stores its observers in an unchecked observer list:

Because the list is Unchecked, it does not verify that an observer is still alive before notifying it. A dangling entry therefore becomes a use-after-free as soon as the logger fires a notification.

The dereference happens in the observer callback, which reaches back into the freed handler's web_ui():

C++
class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
                                          public download::Logger::Observer {
  // download::Logger::Observer implementation.
  void OnServiceDownloadChanged(
      const base::Value::Dict& service_download) override {
    web_ui()->FireWebUIListener("service-download-changed", service_download);  // <-- UAF in web_ui()
  }
}

So the sequence is: open chrome://download-internals, close it (handler freed, observer left behind), then cause the download service to emit a notification. The logger walks its observer list, calls OnServiceDownloadChanged on the freed object, and web_ui() touches freed memory.

Exploitation

Step 1: leave a dangling observer

Open chrome://download-internals/ and close it. The WebUI is destroyed and DownloadInternalsUIMessageHandler is freed, but the logger's observers_ list still contains the pointer.

Step 2: trigger a notification

Open a new tab with chrome://download-internals/, enter any valid URL and click the Download button. The download service changes state and notifies its observers, including the stale one, which produces the use-after-free.

Step 3: a more deterministic variant

A second reproduction makes the timing controllable by stalling a download and then killing the server:

  1. Run the following on a Linux host:
Bash
nc -l 8000
  1. On iOS, open chrome://download-internals, enter http://<your-ip>:8000/poc and click Download, then close the tab.
  2. Press Ctrl + C on the Linux host to kill nc. Chrome on iOS crashes.

The report gives these steps and states that Chrome on iOS crashed. The report notes that a POC video was attached, but it is not reproduced here.

Crash details

  • Type of crash: browser
  • Crash ID: crash/c818bdbca3b2d430

Root cause

The handler registers as a download::Logger::Observer in RegisterMessages but never removes itself in its destructor. The observer list is a base::ObserverList<Observer>::Unchecked, which by design does not guard against observers that have been destroyed without being removed. The two facts combine into a use-after-free: the logger holds a raw pointer to a freed DownloadInternalsUIMessageHandler, and the next notification calls OnServiceDownloadChanged on it, which dereferences web_ui().

The list is unchecked, so it cannot prevent a use-after-free when an observer is freed but not removed; the destructor did not remove it.

Impact

The crash is in the browser process, so the immediate effect is a browser crash triggered by visiting and closing chrome://download-internals and then causing a download service notification. The report frames the issue as a use-after-free in the browser; it does not describe a path to code execution or any other impact beyond the crash.

Fix

The suggested fix adds a destructor that removes the handler from the logger:

Diff
diff --git a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
index 9e35041dc4046..fecfe5d876062 100644
--- a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
+++ b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
@@ -34,7 +34,11 @@ class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
   DownloadInternalsUIMessageHandler(const DownloadInternalsUIMessageHandler&) =
       delete;
   void operator=(const DownloadInternalsUIMessageHandler&) = delete;
-  ~DownloadInternalsUIMessageHandler() override = default;
+
+  ~DownloadInternalsUIMessageHandler() override {
+    if (download_service_)
+      download_service_->GetLogger()->RemoveObserver(this);
+  }

  private:
   // WebUIIOSMessageHandler implementation.

This keeps the observer list consistent with the handler's lifetime, so no notification can reach a freed object.

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

Chrome has a hidden page called chrome://download-internals. It is a diagnostic page: it shows what Chrome's background download service is doing. On iOS, the code behind that page signs itself up to receive updates from the download service, so the page can refresh while you look at it. The problem is that when you close the page, the code never signs itself back out. The download service keeps a note pointing at the page's code, even though that code has been deleted from memory. The next time the download service sends an update, it follows the note to memory that no longer exists and the browser crashes. This kind of bug is called a use-after-free: using something after it has been freed.

The bug was reported through the Chrome VRP (Chrome's Vulnerability Reward Program) by ChaobinZhang, tracked as CVE-2024-3834, rated high severity, with a bounty of 3000.00 USD, and disclosed on 2024-04-16.

Context

This is a use-after-free in the iOS implementation of Chrome's chrome://download-internals page, tracked as CVE-2024-3834 and reported through the Chrome VRP by ChaobinZhang. The page is a WebUI that exposes the state of the background download service to the user. Internally, the page's message handler subscribes to the download service's logger so that it can push updates into the page as they happen.

A few of those words need unpacking before the rest makes sense.

  • WebUI: Chrome's built-in pages, the ones that start with chrome:// instead of https://. They are not websites on the internet; they are drawn by Chrome itself from local code. chrome://download-internals is one of them.
  • Message handler: the piece of code that sits between a WebUI page and the rest of the browser. The page asks it for information, and it pushes information back to the page.
  • Background download service: the part of Chrome that manages downloads even when no download screen is open. It keeps track of each download's state (queued, in progress, failed, finished) and announces changes.
  • Logger: a component of that service whose job is to record and broadcast what the service is doing. Anything that wants to hear those announcements signs up with the logger.
  • Observer: the name for something that has signed up to hear announcements. Think of a newsletter: you subscribe, and the sender keeps your address on a list. An observer is a subscriber, and the logger is the sender holding the list.
  • Use-after-free: a memory safety bug. A program deletes an object (frees its memory), but some other part of the program still holds its address and later reads or writes there. It is like cancelling your gym membership, having the gym keep your locker key on file anyway, and one day handing that key to a new member's locker. The result is unpredictable, and in Chrome it usually means a crash.

The bug is a lifetime problem: the handler registers itself as an observer of the logger but never unregisters, so once the WebUI is torn down the logger keeps a pointer to freed memory and later dereferences it.

Setup

  • Target: Google Chrome on iOS.
  • Version tested: 122.0.6261.62 (Official Build) stable (64 bit).
  • Operating system: iOS.
  • No account or special role is needed; the page is reachable from the address bar.
  • For the second reproduction, a Linux host on the same network running nc is used to serve a download that can be stalled and then killed.

nc (short for netcat) is a small command-line tool that can open a network connection and listen on a port. Here it listens on port 8000 and is killed with Ctrl + C to make the download fail.

The relevant code lives in ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc and components/download/internal/background_service/logger_impl.h.

Finding it

The researcher looked at how DownloadInternalsUIMessageHandler wires itself into the download service. In RegisterMessages the handler adds itself as an observer of the background download service's logger:

Line by line:

  1. class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler, public download::Logger::Observer declares the handler class. The two public ... parts mean it inherits from two parents: it is a WebUI message handler, and it is also a logger observer. In plain terms, it is both the page's assistant and a newsletter subscriber.
  2. void RegisterMessages() override is the function Chrome calls when the page is being set up. override means it is replacing a function defined by the parent class.
  3. if (download_service_) checks that the download service exists before touching it. The underscore suffix is a naming convention for member variables.
  4. download_service_->GetLogger()->AddObserver(this); is the subscription. It asks the download service for its logger, then calls AddObserver on it, passing this, meaning "add me to your list". From this moment the logger holds a pointer to this handler.

What stood out is the absence of the matching call in the destructor: ~DownloadInternalsUIMessageHandler() does not call RemoveObserver. A destructor is the function that runs when an object is being deleted; it is the natural place to undo whatever the setup function did. The lifetime of the handler object is bound to the WebUI for chrome://download-internals on iOS, so closing the tab frees the handler while the logger still holds it.

The logger stores its observers in an unchecked observer list:

Line by line:

  1. namespace download { opens a named scope so these names do not clash with other parts of Chrome.
  2. class LoggerImpl : public Logger, public LogSink { declares the actual logger implementation, inheriting from Logger and LogSink.
  3. base::ObserverList<Observer>::Unchecked observers_; is the list of subscribers. ObserverList is a Chrome utility for keeping a list of observers. The Unchecked variant means the list does not check whether each observer is still alive before calling it. A checked list would notice a dead subscriber; this one does not.
  4. The comment spells out the consequence: if an observer has been freed but not removed, the unchecked list cannot prevent a use-after-free.

Because the list is Unchecked, it does not verify that an observer is still alive before notifying it. A dangling entry therefore becomes a use-after-free as soon as the logger fires a notification. "Dangling" here means a pointer that still exists but points at something that has been destroyed, like an old phone number that has been reassigned to someone else.

The dereference happens in the observer callback, which reaches back into the freed handler's web_ui():

C++
class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
                                          public download::Logger::Observer {
  // download::Logger::Observer implementation.
  void OnServiceDownloadChanged(
      const base::Value::Dict& service_download) override {
    web_ui()->FireWebUIListener("service-download-changed", service_download);  // <-- UAF in web_ui()
  }
}

Line by line:

  1. The class declaration is the same handler as before.
  2. void OnServiceDownloadChanged(const base::Value::Dict& service_download) override is the function the logger calls when a download changes. It receives the new state as a dictionary of values.
  3. web_ui()->FireWebUIListener("service-download-changed", service_download); is where the damage happens. web_ui() fetches the page object that this handler belongs to, and FireWebUIListener sends an event named service-download-changed to the page with the new data. If the handler has already been freed, web_ui() is reading from freed memory, which is the use-after-free.

So the sequence is: open chrome://download-internals, close it (handler freed, observer left behind), then cause the download service to emit a notification. The logger walks its observer list, calls OnServiceDownloadChanged on the freed object, and web_ui() touches freed memory.

Exploitation

Step 1: leave a dangling observer

Open chrome://download-internals/ and close it. The WebUI is destroyed and DownloadInternalsUIMessageHandler is freed, but the logger's observers_ list still contains the pointer.

This step is done first because it is the one that creates the bad state. Nothing crashes yet; the crash needs a second event. The goal is simply to leave the logger holding a stale entry.

Step 2: trigger a notification

Open a new tab with chrome://download-internals/, enter any valid URL and click the Download button. The download service changes state and notifies its observers, including the stale one, which produces the use-after-free.

This step is the trigger. Starting a download makes the service announce a change, and the announcement goes to every subscriber on the list, including the dead one from step 1.

Step 3: a more deterministic variant

The first reproduction opens and closes the page, then starts a download in a new tab. A second reproduction makes the timing controllable by stalling a download and then killing the server:

  1. Run the following on a Linux host:
Bash
nc -l 8000
  1. On iOS, open chrome://download-internals, enter http://<your-ip>:8000/poc and click Download, then close the tab.
  2. Press Ctrl + C on the Linux host to kill nc. Chrome on iOS crashes.

Line by line:

  1. nc -l 8000 starts netcat in listen mode (-l) on port 8000. It accepts a connection and then waits, never sending a response. That is the stall.
  2. On the phone, the URL http://<your-ip>:8000/poc points at that listener. <your-ip> is a placeholder for the Linux machine's address on the local network. Clicking Download makes Chrome connect and wait for data that never comes. Closing the tab then frees the handler while the download is still pending.
  3. Ctrl + C stops netcat. The connection drops, the download service notices the change, and it notifies its observers. The stale observer is still on the list, so the browser crashes.

The report gives these steps and states that Chrome on iOS crashed. The report notes that a POC video was attached, but it is not reproduced here.

Crash details

  • Type of crash: browser
  • Crash ID: crash/c818bdbca3b2d430

"Type of crash: browser" means the whole browser process went down, not just a single tab's rendering process. The crash ID is the identifier Chrome's crash reporting uses to group reports of the same failure.

Root cause

The handler registers as a download::Logger::Observer in RegisterMessages but never removes itself in its destructor. The observer list is a base::ObserverList<Observer>::Unchecked, which by design does not guard against observers that have been destroyed without being removed. The two facts combine into a use-after-free: the logger holds a raw pointer to a freed DownloadInternalsUIMessageHandler, and the next notification calls OnServiceDownloadChanged on it, which dereferences web_ui().

The list is unchecked, so it cannot prevent a use-after-free when an observer is freed but not removed; the destructor did not remove it. In newsletter terms: the sender was never told you moved, and the mailing list was the kind that does not check whether an address still works before sending.

Impact

The crash is in the browser process, so the immediate effect is a browser crash triggered by visiting and closing chrome://download-internals and then causing a download service notification. The report frames the issue as a use-after-free in the browser; it does not describe a path to code execution or any other impact beyond the crash.

Fix

The suggested fix adds a destructor that removes the handler from the logger:

Diff
diff --git a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
index 9e35041dc4046..fecfe5d876062 100644
--- a/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
+++ b/ios/chrome/browser/webui/ui_bundled/download_internals_ui.cc
@@ -34,7 +34,11 @@ class DownloadInternalsUIMessageHandler : public web::WebUIIOSMessageHandler,
   DownloadInternalsUIMessageHandler(const DownloadInternalsUIMessageHandler&) =
       delete;
   void operator=(const DownloadInternalsUIMessageHandler&) = delete;
-  ~DownloadInternalsUIMessageHandler() override = default;
+
+  ~DownloadInternalsUIMessageHandler() override {
+    if (download_service_)
+      download_service_->GetLogger()->RemoveObserver(this);
+  }

  private:
   // WebUIIOSMessageHandler implementation.

Line by line:

  1. The diff --git line and the index line are bookkeeping: which file changed and which two versions of it are being compared.
  2. The --- and +++ lines name the old and new versions of the file, both download_internals_ui.cc.
  3. @@ -34,7 +34,11 @@ says the change starts around line 34: seven lines of context in the old file, eleven in the new one.
  4. The two lines about the copy constructor and assignment operator, both set to delete, are unchanged context. They stop the handler from being copied, which matters because a copied observer would be a second subscriber with its own lifetime.
  5. The line starting with - is the old destructor: ~DownloadInternalsUIMessageHandler() override = default; means "use the compiler's default destructor, which does nothing". That is the bug.
  6. The lines starting with + are the new destructor. It checks if (download_service_), then calls download_service_->GetLogger()->RemoveObserver(this);, the exact opposite of the AddObserver call in RegisterMessages. Now when the handler is deleted, it takes itself off the list first.
  7. The remaining lines are unchanged context showing the start of the private: section.

This keeps the observer list consistent with the handler's lifetime, so no notification can reach a freed object.

Variants to test

Glossary

  • API: an agreed way for one piece of software to talk to another; here, the functions a page's code calls to ask the browser for information.
  • Background download service: the part of Chrome that manages downloads and tracks their state, even when no download screen is open.
  • Bounty: a payment made by a company to a researcher who reports a valid security bug.
  • Browser process: the main Chrome process that coordinates tabs and built-in pages; a crash there takes the whole browser down.
  • Checked observer list: an observer list that verifies an observer is still alive before notifying it.
  • Chrome VRP: Chrome's Vulnerability Reward Program, which receives and pays for security reports.
  • Crash ID: the identifier Chrome's crash reporting uses to group reports of the same failure.
  • CVE: a public identifier assigned to a known security vulnerability so people can refer to it unambiguously.
  • Dangling pointer: a stored address that still exists but points at memory that has already been freed.
  • Destructor: the function that runs when an object is deleted, normally used to undo whatever setup did.
  • Dictionary: a data structure holding named values, like a form with labelled fields.
  • Download-internals: the built-in Chrome page at chrome://download-internals that displays the state of the background download service.
  • High severity: a rating level indicating a serious bug, below critical but above medium and low.
  • Logger: the component of the download service that records activity and broadcasts changes to subscribers.
  • Message handler: the code that connects a built-in Chrome page to the rest of the browser.
  • nc (netcat): a command-line tool that can open network connections and listen on ports; used here as a server that accepts a request and never answers.
  • Observer: something that has signed up to receive announcements from another component.
  • Observer list: the collection a sender keeps of all its subscribers.
  • Port: a numbered channel on a machine that network connections use; 8000 is the one used here.
  • Raw pointer: a plain memory address held by a program, with no automatic check that the memory is still valid.
  • RemoveObserver: the call that takes a subscriber off an observer list.
  • Unchecked observer list: an observer list that does not verify an observer is still alive before notifying it.
  • Use-after-free: a bug where a program uses memory after it has been freed, often causing a crash.
  • WebUI: Chrome's built-in pages, addressed with chrome:// instead of https://, drawn by Chrome itself from local code.
  • WebUI listener: an event a built-in page can subscribe to so it updates when something changes.

More by ChaobinZhang

View all

1 more disclosed report, 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.

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.