Use after free in Network (CVE-2026-79064)
A use-after-free exists in WiFiServiceMac on macOS because an Objective-C block captures a raw this pointer, bypassing MiraclePtr. An attacker with the networkingPrivate extension permission could stall the task runner and trigger a notification to free the object before the notification task runs, potentially leading to arbitrary code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Flapjack, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A Use-After-Free (UAF) vulnerability exists in WiFiServiceMac on macOS due to an Objective-C block capturing a raw this pointer, bypassing MiraclePtr protections. An attacker with the networkingPrivate extension permission can reliably trigger this by delaying task execution on a worker thread, leading to arbitrary code execution in the browser process.
Affected files:
components/wifi/wifi_service_mac.mm
Estimated timestamp from git blame: 2014-01-29
Summary
A potential Use-After-Free (UAF) vulnerability exists in the WiFiServiceMac class in components/wifi/wifi_service_mac.mm. The issue arises from the unsafe capture of the raw this pointer within an Objective-C block used as an NSNotificationCenter observer. Because the block captures this as a raw C++ pointer, it entirely bypasses MiraclePtr protections. By manipulating task queues, an attacker can reliably turn this into a deterministic UAF leading to Remote Code Execution (RCE) in the browser process.
Technical Details
In WiFiServiceMac::SetEventObservers, a block is registered to handle notifications for macOS CoreWLAN SSID changes:
void (^ns_observer)(NSNotification* notification) = ^(
NSNotification* notification) {
DVLOG(1) << "Received CoreWLAN notification that the SSID changed";
task_runner_->PostTask(
FROM_HERE, base::BindOnce(&WiFiServiceMac::OnWlanObserverNotification,
base::Unretained(this)));
};
wlan_observer_ = [NSNotificationCenter.defaultCenter
addObserverForName:@"com.apple.coreWLAN.notification.ssid.legacy"
object:nil
queue:nil
usingBlock:ns_observer];
In Objective-C++, referencing a member variable (such as task_runner_) inside a block implicitly captures the this pointer by value. Because this is a raw C++ pointer, the block does not safely track the lifetime of the WiFiServiceMac instance.
NetworkingPrivateServiceClient manages WiFiServiceMac and executes all interactions, including destruction, on a single SequencedTaskRunner (g_sequenced_task_runner). When WiFiServiceMac is destroyed, its destructor calls UnInitialize(), which unregisters the observer using removeObserver:.
However, removeObserver: does not block blocks that are already executing on other threads. If a notification is fired concurrently from an OS background thread while WiFiServiceMac is being destroyed, the block will still execute. The block will post OnWlanObserverNotification (bound with base::Unretained(this)) to the sequenced task runner.
Exploit Scenario (Suggested Steps)
Because both the destruction task and the notification task are posted to the same SequencedTaskRunner, an attacker can achieve 100% reliability:
- A compromised extension with
networkingPrivatepermission spams API calls (e.g.,getNetworks) to flood and stall theg_sequenced_task_runner. - The attacker triggers Profile destruction (e.g., closing the extension), queueing the
WiFiServiceMacdestruction task on the stalled runner. - The attacker immediately triggers a WiFi SSID change (e.g., via
startConnect), causing macOS to broadcast a notification. - The
ns_observerblock executes synchronously on an OS thread. It postsOnWlanObserverNotification(usingbase::Unretained(this)) to the stalledg_sequenced_task_runner. - Because the runner is stalled, the notification task is queued strictly behind the destruction task.
- The worker thread catches up. It executes the destruction task first, freeing the
WiFiServiceMacobject. - The worker thread then executes the
OnWlanObserverNotificationtask on the freedthispointer. - Inside
OnWlanObserverNotification, the code calls[interface_ ssid].interface_is read from the freed memory. If the attacker has sprayed the heap, this results in anobjc_msgSendcall to an attacker-controlled pointer, yielding RCE in the browser process.
Suggested Fix
To fix this issue, avoid capturing the raw this pointer in the Objective-C block. Instead, capture a base::WeakPtr<WiFiServiceMac> and check it before posting the task.
base::WeakPtr<WiFiServiceMac> weak_this = weak_factory_.GetWeakPtr();
scoped_refptr<base::SequencedTaskRunner> task_runner = task_runner_;
void (^ns_observer)(NSNotification* notification) = ^(
NSNotification* notification) {
task_runner->PostTask(
FROM_HERE, base::BindOnce(
[](base::WeakPtr<WiFiServiceMac> weak_self) {
if (weak_self)
weak_self->OnWlanObserverNotification();
}, weak_this));
};
Note that WeakPtr must be checked on the thread it was created on (the worker thread), hence why it should be passed to the posted task rather than checked inside the block (which runs on an OS thread).
Evaluated with Chrome root at commit: 2155cb00003ec35716a76ed3246eae995f87b7ff
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 Objective-C block captures the raw this pointer instead of a weak reference, so the posted task can run after the object is destroyed.
Impact
Could lead to arbitrary code execution in the browser process if the attacker sprays the heap, but requires the networkingPrivate extension permission.
What the attacker needed
NetworkingPrivate extension permission; ability to trigger Profile destruction; ability to trigger WiFi SSID change
The fix
The issue should be fixed by capturing a base::WeakPtr<WiFiServiceMac> in the block and checking it before posting the task.
How it was found
- A compromised extension with networkingPrivate permission spams API calls to stall the sequenced task runner.
- The attacker triggers Profile destruction, queueing the WiFiServiceMac destruction task on the stalled runner.
- The attacker triggers a WiFi SSID change, causing macOS to broadcast a notification.
- The observer block posts OnWlanObserverNotification with base::Unretained(this) to the stalled runner.
- The worker thread executes the destruction task first, freeing the object.
- The worker thread then executes the notification task on the freed this pointer.
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 use-after-free is when a program frees memory but then keeps using it, like deleting a file and still trying to open it. Here, a notification handler holds a raw pointer to an object that can be destroyed before the handler runs, so the handler touches freed memory. An attacker who can control timing could make the program use that freed memory in a dangerous way.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.