Use after free in Browser (CVE-2026-95298)
A model quality log entry could be destroyed on a background thread during profile teardown, causing its destructor to dereference a UI-thread-bound weak pointer and mutate an unsynchronised vector. This could lead to a browser-process use-after-free or heap corruption.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 4 months
Project Fortify, 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 potential thread safety issue exists where a ModelQualityLogEntry can be deleted off the UI thread on a ThreadPool sequence during profile teardown. Its destructor performs cross-sequence dereferencing of a UI-thread-bound WeakPtr and modifies an unsynchronized std::vector on a background thread. This can result in a potential browser-process Use-After-Free (UAF) or heap corruption.
Affected files:
chrome/browser/contextual_tasks/contextual_tasks_context_service.cccomponents/optimization_guide/core/model_quality/model_quality_log_entry.cccomponents/optimization_guide/core/model_quality/model_quality_logs_uploader_service.ccchrome/browser/contextual_tasks/contextual_tasks_context_model_handler.cccomponents/optimization_guide/core/inference/model_handler.h
Estimated timestamp from git blame: 2026-04-16
Description
A potential security issue exists in the interaction between ContextualTasksContextService and the ModelHandler infrastructure. During profile or browser teardown, a callback chain containing a std::unique_ptr<ModelQualityLogEntry> can be silently discarded and destroyed on a background BEST_EFFORT ThreadPool sequence instead of the UI thread.
When ModelQualityLogEntry is destroyed off the UI thread, its destructor (components/optimization_guide/core/model_quality/model_quality_log_entry.cc:37) executes non-thread-safe operations:
- It dereferences and invokes methods on
uploader_(abase::WeakPtr<ModelQualityLogsUploaderService>bound to the UI thread), violating sequence safety constraints and potentially leading to a Use-After-Free (UAF) if the uploader is concurrently destroyed on the UI thread. - It calls
SetMqlsLogForWebUIwhich performs an unsynchronizedpush_backinto themqls_logs_for_web_ui_vector (components/optimization_guide/core/model_quality/model_quality_logs_uploader_service.cc:287), risking concurrent mutation and heap corruption.
Potential Mechanism of Off-Thread Destruction
ContextualTasksContextService::OnQueryEmbeddingReady(chrome/browser/contextual_tasks/contextual_tasks_context_service.cc:482) instantiates aModelQualityLogEntryon the UI thread.- This log entry is moved into a callback chain passed to
model_handler_->BatchExecuteModelWithSignals. - The executor (
TFLiteModelExecutor) posts an asynchronousOpenModelFiletask to a background ThreadPool runner (model_loading_task_runner_). The reply callback (transitively owning the log entry) is parked waiting for completion. - Concurrently, the user closes the profile. KeyedService teardown on the UI thread calls
~ModelHandler, which invokesmodel_task_runner_->DeleteSoon(model_executor_). - Because the task runner is sequenced, the
DeleteSoontask runs before theOpenModelFilereply task. This destroys the executor and invalidates its execution-threadWeakPtr. - When the reply task is eventually dequeued, its receiver
WeakPtris invalid. The callback is canceled, causing itsBindState(and thus theModelQualityLogEntry) to be destroyed synchronously on the background ThreadPool sequence instead of returning to the UI thread.
Potential Steps to Reproduce
Note: Our tooling agent does not currently have the capability to execute code or run a live proof of concept; therefore, these are suggested and potential steps based on code analysis.
- Enable the
ContextualTasksContextfeature (which has active platform testing configs). - Initiate a query that prompts contextual search processing, invoking
BatchExecuteModelWithSignals. - While the background model loading task (
OpenModelFile) is executing on the ThreadPool, close the profile or browser window to trigger service teardown. - Observe potential browser process instability or memory corruption assertions in debug builds due to
~ModelQualityLogEntryexecuting off-sequence.
Suggested Fix
Ensure that the ModelQualityLogEntry is always deleted on the thread where its bound WeakPtr and uploader service live (the UI thread).
One robust fix is to wrap the callback or the log entry destructor using a helper that enforces UI-thread deletion, such as wrapping the pointer in a custom deleter that posts destruction to the UI thread if executed off-sequence:
struct UIThreadDeleter {
void operator()(optimization_guide::ModelQualityLogEntry* ptr) const {
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
delete ptr;
} else {
content::GetUIThreadTaskRunner({})->DeleteSoon(FROM_HERE, ptr);
}
}
};
Alternatively, ensure that the callbacks passed to ModelHandler that own UI-thread-bound resources are safely bound using base::BindPostTask or destroyed via custom helpers that handle off-sequence cancellation gracefully.
Evaluated with Chrome root at commit: e9507a33bb4148ee071aaaf8a7e9ad68770359bf
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.
Raised in root component due to access or custom field issues on 1516765
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 a callback owning a UI-thread-bound object was cancelled on a background sequence, so the object's destructor ran off the UI thread and performed non-thread-safe operations.
Impact
This could cause a browser-process use-after-free or heap corruption, though the report is based on code analysis and no live proof of concept was executed.
What the attacker needed
ContextualTasksContext feature enabled; A query that triggers model execution; Profile or browser teardown during model loading
The fix
The log entry should always be deleted on the UI thread, for example by using a custom deleter that posts destruction to the UI thread when executed off-sequence.
How it was found
- Enable the ContextualTasksContext feature.
- Start a query that triggers contextual search processing and the batch model execution.
- While the background model loading task is running, close the profile or browser window.
- Observe potential browser process instability or memory corruption assertions in debug builds.
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.
When you close a browser profile, background tasks may still be running. A log object meant to be cleaned up on the main thread could instead be deleted on a background thread, where it touches data that is not safe to touch from there. This can crash the browser or corrupt memory.
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.