Critical chrome UAF 🔧 Commit mapped

Overview

Critical
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
ImpactUse after free in Lens
DescriptionUse after free in Lens
ComponentLens
Bug ClassUAF
Tracker401029609
Fix commit2690d69b56b7 (chromium/src) +12/-2
CISA KEVNot listed
CreditedSungKwon Lee of Enki Whitehat
Disclosed2025-03-19

Files Changed

  • chrome/browser/ui/lens/lens_permission_bubble_controller.cc
From 2690d69b56b764bfb1997cfb0715ac22b5976648 Mon Sep 17 00:00:00 2001
From: Nihar Majmudar <[email protected]>
Date: Fri, 07 Mar 2025 10:53:29 -0800
Subject: [PATCH] [LensOverlay] Check if controller exists in OnPermissionDialogAccept.

There's a chance LensPermissionBubbleController gets destroyed before
the OnPermissionDialogAccepted callback finishes. Check if the
controller still exists at this point.

This risk occurs after SetBoolean() is called on the pref service
since that then invokes a set of callbacks that could eventually lead
to CloseUISync() being called (more thorough RCA in bug).

Change-Id: I3d1842c3531fad474200a27ef054a30b753ccd61
Bug: 401029609
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6333695
Reviewed-by: Duncan Mercer <[email protected]>
Commit-Queue: Nihar Majmudar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429619}
---

diff --git a/chrome/browser/ui/lens/lens_permission_bubble_controller.cc b/chrome/browser/ui/lens/lens_permission_bubble_controller.cc
index 314f74f..73c8a3cb 100644
--- a/chrome/browser/ui/lens/lens_permission_bubble_controller.cc
+++ b/chrome/browser/ui/lens/lens_permission_bubble_controller.cc
@@ -164,11 +164,21 @@
 void LensPermissionBubbleController::OnPermissionDialogAccept() {
   RecordPermissionUserAction(LensPermissionUserAction::kAcceptButtonPressed,
                              invocation_source_);
+  base::WeakPtr<LensPermissionBubbleController>
+      lens_permission_bubble_controller = weak_ptr_factory_.GetWeakPtr();
   pref_service_->SetBoolean(prefs::kLensSharingPageScreenshotEnabled, true);
-  if (lens::features::IsLensOverlayContextualSearchboxEnabled()) {
+  // TODO(crbug.com/401029609): Rethink permission bubble lifetime.
+  // Must check WeakPtr in case CloseUISync() is called in
+  // LensOverlayController. This happens if the LensOverlayController cannot
+  // successfully take a screenshot of the page. If CloseUISync() is called,
+  // LensPermissionBubbleController gets reset before the following.
+  if (lens_permission_bubble_controller.get() &&
+      lens::features::IsLensOverlayContextualSearchboxEnabled()) {
     pref_service_->SetBoolean(prefs::kLensSharingPageContentEnabled, true);
   }
-  dialog_widget_ = nullptr;
+  if (lens_permission_bubble_controller.get()) {
+    dialog_widget_ = nullptr;
+  }
 }
 
 void LensPermissionBubbleController::OnPermissionDialogCancel() {
Loading diff…

Original Bug Report

The reporter's bug is still restricted on the tracker. Chrome de-restricts security bugs ~30–90 days after the fix ships; a later run will backfill it here.