Use after free in Password Manager (CVE-2025-14372)
A heap use-after-free exists in Chrome's password change login-state checker: a callback invoked during page-content processing can delete the checker object, after which the same function keeps using its members. An attacker could potentially exploit this to escape the browser sandbox without a compromised renderer, though the report only demonstrates it with a patched build.
Originally disclosed on Chrome VRP
- Fix shipped in 27 days
Steps to reproduce the problem
- apply the change.txt to the newest Chromium and compile chrome with ASAN
- start a server at poc.html's folder : python -m SimpleHTTPServer 8605
- ./chrome --user-data-dir=/tmp/noexist --password-change-url="http://127.0.0.1:8605/" http://127.0.0.1:8605/poc.html
- After the popup shown, click the "Change it for me", and UAF occurs
Note that this UAF could be used to escape sandbox WITHOUT a compromised render. All the patch I provided is to simulate an easier way to trigger this UAF in Chromium
Problem Description
Vulnerability Analysis
login_state_checker_[1] is an unique_ptr with a callback OnLoginStateCheckResult[2]. This callback will reset the login_state_checker_, which means the login_state_checker_ will be DELETED after the callback is invoked.
[1]
if (base::FeatureList::IsEnabled(
password_manager::features::kCheckLoginStateBeforePasswordChange)) {
login_state_checker_ = std::make_unique<LoginStateChecker>(
originator_.get(), logs_uploader_.get(),
ChromePasswordManagerClient::FromWebContents(originator_),
base::BindRepeating(
&PasswordChangeDelegateImpl::OnLoginStateCheckResult,
weak_ptr_factory_.GetWeakPtr()));
}
[2]
void PasswordChangeDelegateImpl::OnLoginStateCheckResult(bool is_logged_in) {
if (is_logged_in) {
// User is logged in, start password change process.
ProceedToChangePassword();
return;
}
blocking_challenge_detected_ = true;
if (!login_state_checker_->ReachedAttemptsLimit()) { //@audit: Only when ReachedAttemptsLimit is true, then `login_state_checker_` could be reset
// Update the UI to encourage user to complete sign in.
UpdateState(State::kLoginFormDetected);
return;
}
// Maximum number of retries reached, convert to terminal state.
UpdateState(State::kChangePasswordFormNotFound);
login_state_checker_.reset();
}
However, in the LoginStateChecker Class, there is a LoginStateChecker::OnExecutionResponseCallback[3] function which will access the class member after the callback is invoked in the function LoginStateChecker::OnPageContentReceived[4]. This will lead to UAF.
[3]
void LoginStateChecker::OnExecutionResponseCallback(
optimization_guide::OptimizationGuideModelExecutionResult execution_result,
std::unique_ptr<
optimization_guide::proto::PasswordChangeSubmissionLoggingData>
logging_data) {
[...]
if (cached_page_content_.has_value() && !is_logged_in &&
!ReachedAttemptsLimit()) {
OnPageContentReceived(std::move(cached_page_content_)); //@audit: OnPageContentReceived will invoke the callback and delete |this|
// Clear the page content to ensure that this check doesn't pass next time,
// which would lead to a request with empty page content.
cached_page_content_ = std::nullopt; //@audit: use after free
}
result_check_callback_.Run(is_logged_in); //@audit: user after free
}
[4]
void LoginStateChecker::OnPageContentReceived(
std::optional<optimization_guide::AIPageContentResult> content) {
CHECK(content);
if (is_request_in_flight_) {
cached_page_content_ = std::move(content);
return;
}
is_request_in_flight_ = true;
optimization_guide::proto::PasswordChangeRequest request;
request.set_step(kLoginCheckStep);
*request.mutable_page_context()->mutable_annotated_page_content() =
std::move(content->proto);
LogMessage(client_,
SavePasswordProgressLogger::STRING_LOGIN_STATE_CHECK_REQUEST_SENT);
optimization_guide::ExecuteModelWithLogging( //@audit: this function will directly call the OnExecutionResponseCallback, whihc will call the `callback`
GetOptimizationService(),
optimization_guide::ModelBasedCapabilityKey::kPasswordChangeSubmission,
request, /*execution_timeout=*/std::nullopt,
base::BindOnce(&LoginStateChecker::OnExecutionResponseCallback,
weak_ptr_factory_.GetWeakPtr()));
}
[1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/password_manager/password_change_delegate_impl.cc;l=386 [2] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/password_manager/password_change_delegate_impl.cc;l=407 [3] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/password_manager/password_change/login_state_checker.cc;l=217-223 [4] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/password_manager/password_change/login_state_checker.cc;l=142
Bisect This UAF is introduced in this commit: https://source.chromium.org/chromium/chromium/src/+/b5d8d41f2047b2afd062112ea8b39958792a655a According to the commit, this UAF affects Chrome Stable 142.0.7444.59.
Additional Comments
Info about change.txt
All the patch in change.txt is only used to simulate a more easier environment to trigger the UAF.
-
Since the vulnerable function is invoked when the password is detected as "LEAK", so I patch some code to simulate this situation in
components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc -
chrome/browser/password_manager/password_change/login_state_checker.hchange thekMaxLoginChecksto2to trigger this issue more quickly. -
components/optimization_guide/core/model_execution/model_execution_features_controller.ccis patched to enable theoptimization_guide::UserVisibleFeatureKey::kPasswordChangeSubmissionfeature. -
chrome/browser/password_manager/chrome_password_change_service.ccis patched to support IP format website(Otherwise you need a doamin name). -
chrome/browser/password_manager/password_change/login_state_checker.ccpatch the checks forresponseto trigger the call toOnPageContentReceivedfunction. It also simulate the situation that the first Attempt is not logged in(which will trigger the call toOnPageContentReceived), and second Attempt will reach theReachedAttemptsLimitand run the callback to delete this.
Summary
Security: Heap-use-after-free in LoginStateChecker::OnExecutionResponseCallback
Custom Questions
Type of crash:
browser
Crash state:
Please see the attached asan.txt for ASAN logs.
Reporter credit:
Krace
Additional Data
Category: Security
Chrome Channel: Stable
Regression: N/A \
Context
Chrome's Password Manager can offer to change a password for the user when it detects that the stored credential has been leaked. The password change flow is driven by PasswordChangeDelegateImpl, which owns a login_state_checker_ member, a std::unique_ptr<LoginStateChecker>. The checker asks an optimisation guide model whether the user is currently logged in to the site.
The checker asks an optimisation guide model to analyse the page content and report whether the user is logged in. The result comes back through a callback, PasswordChangeDelegateImpl::OnLoginStateCheckResult, which is bound to the delegate when the checker is created. The bug reported here is a heap use-after-free in LoginStateChecker::OnExecutionResponseCallback, where the checker accesses its own members after a callback has already deleted it.
The report notes that this use-after-free could be used to escape the sandbox without a compromised renderer. The patch supplied with the report exists only to make the bug easier to trigger in Chromium.
Setup
The researcher compiled the newest Chromium with ASAN after applying change.txt. The patch is a simulation aid, not part of the vulnerability. It makes the following changes:
- In
components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc, code is patched to simulate the password being detected as "LEAK", since the vulnerable function is only invoked in that situation. - In
chrome/browser/password_manager/password_change/login_state_checker.h,kMaxLoginChecksis changed to2so the issue triggers more quickly. - In
components/optimization_guide/core/model_execution/model_execution_features_controller.cc, theoptimization_guide::UserVisibleFeatureKey::kPasswordChangeSubmissionfeature is enabled. - In
chrome/browser/password_manager/chrome_password_change_service.cc, support for IP-format websites is added, since otherwise a domain name is required. - In
chrome/browser/password_manager/password_change/login_state_checker.cc, the checks onresponseare patched to trigger the call toOnPageContentReceived. It also simulates the first attempt not being logged in, which triggers the call toOnPageContentReceived, and the second attempt reachingReachedAttemptsLimit, which runs the callback that deletes the checker.
The test page is served from the folder containing poc.html with a simple HTTP server on port 8605, and Chrome is launched with a fresh user data directory and a password change URL pointing at that server.
Finding it
The researcher traced the ownership of login_state_checker_ and the callback it registers. The checker is created with a callback bound to PasswordChangeDelegateImpl::OnLoginStateCheckResult:
if (base::FeatureList::IsEnabled(
password_manager::features::kCheckLoginStateBeforePasswordChange)) {
login_state_checker_ = std::make_unique<LoginStateChecker>(
originator_.get(), logs_uploader_.get(),
ChromePasswordManagerClient::FromWebContents(originator_),
base::BindRepeating(
&PasswordChangeDelegateImpl::OnLoginStateCheckResult,
weak_ptr_factory_.GetWeakPtr()));
}
That callback can reset the login_state_checker_, which means the checker is deleted once the callback runs:
void PasswordChangeDelegateImpl::OnLoginStateCheckResult(bool is_logged_in) {
if (is_logged_in) {
// User is logged in, start password change process.
ProceedToChangePassword();
return;
}
blocking_challenge_detected_ = true;
if (!login_state_checker_->ReachedAttemptsLimit()) { //@audit: Only when ReachedAttemptsLimit is true, then `login_state_checker_` could be reset
// Update the UI to encourage user to complete sign in.
UpdateState(State::kLoginFormDetected);
return;
}
// Maximum number of retries reached, convert to terminal state.
UpdateState(State::kChangePasswordFormNotFound);
login_state_checker_.reset();
}
The reset only happens when ReachedAttemptsLimit() is true. The problem is that the checker itself invokes this callback from inside one of its own member functions and then keeps using its members afterwards.
Exploitation
Step 1: apply the patch and build with ASAN
The researcher applies change.txt to the newest Chromium and compiles Chrome with ASAN. The patch is only there to make the vulnerable path reachable more easily, as described in Setup.
Step 2: serve the proof of concept
Start a server in the folder containing poc.html:
python -m SimpleHTTPServer 8605
Step 3: launch Chrome against the page
./chrome --user-data-dir=/tmp/noexist --password-change-url="http://[redacted]:8605/" http://[redacted]:8605/poc.html
Step 4: trigger the popup and click
After the popup is shown, click "Change it for me". The use-after-free occurs at that point.
Root cause
The checker sends the page content to the optimisation guide model and binds LoginStateChecker::OnExecutionResponseCallback as the response handler:
void LoginStateChecker::OnPageContentReceived(
std::optional<optimization_guide::AIPageContentResult> content) {
CHECK(content);
if (is_request_in_flight_) {
cached_page_content_ = std::move(content);
return;
}
is_request_in_flight_ = true;
optimization_guide::proto::PasswordChangeRequest request;
request.set_step(kLoginCheckStep);
*request.mutable_page_context()->mutable_annotated_page_content() =
std::move(content->proto);
LogMessage(client_,
SavePasswordProgressLogger::STRING_LOGIN_STATE_CHECK_REQUEST_SENT);
optimization_guide::ExecuteModelWithLogging( //@audit: this function will directly call the OnExecutionResponseCallback, whihc will call the `callback`
GetOptimizationService(),
optimization_guide::ModelBasedCapabilityKey::kPasswordChangeSubmission,
request, /*execution_timeout=*/std::nullopt,
base::BindOnce(&LoginStateChecker::OnExecutionResponseCallback,
weak_ptr_factory_.GetWeakPtr()));
}
In the response callback, if there is cached page content, the user is not logged in and the attempts limit has not been reached, the callback calls OnPageContentReceived again. That second call invokes the delegate's callback, which, once the attempts limit is reached, resets login_state_checker_ and deletes the checker. Control then returns to OnExecutionResponseCallback, which continues to touch its own members:
void LoginStateChecker::OnExecutionResponseCallback(
optimization_guide::OptimizationGuideModelExecutionResult execution_result,
std::unique_ptr<
optimization_guide::proto::PasswordChangeSubmissionLoggingData>
logging_data) {
[...]
if (cached_page_content_.has_value() && !is_logged_in &&
!ReachedAttemptsLimit()) {
OnPageContentReceived(std::move(cached_page_content_)); //@audit: OnPageContentReceived will invoke the callback and delete |this|
// Clear the page content to ensure that this check doesn't pass next time,
// which would lead to a request with empty page content.
cached_page_content_ = std::nullopt; //@audit: use after free
}
result_check_callback_.Run(is_logged_in); //@audit: user after free
}
Both the assignment to cached_page_content_ and the later result_check_callback_.Run(is_logged_in) happen after the object has been freed.
The report states that the use-after-free was introduced in commit [redacted], and that according to the commit it affects Chrome Stable 142.0.7444.59.
Impact
The crash is a heap use-after-free in LoginStateChecker::OnExecutionResponseCallback; the report lists the crash type as browser. The researcher notes that this use-after-free could be used to escape the sandbox without a compromised renderer. The report does not describe a concrete exploit chain beyond that statement.
Fix
The report does not describe the fix that was applied. The supplied change.txt is explicitly a simulation aid for triggering the bug, not a fix.
Variants to test
- Look for other callbacks bound with
base::BindRepeatingorbase::BindOncethat can synchronously reset the owning object through aunique_ptr. A positive result is a member access after the reset in the same call chain, visible in ASAN as a heap-use-after-free. - Check other
weak_ptr_factory_-based callbacks where the object is deleted synchronously inside the callback rather than posted to a later task. A positive result is a callback that runs after its owner has been freed. - Examine other optimisation guide model execution paths that re-enter their own response handler, for example through cached content. A positive result is a second invocation of the response handler that reaches a state-changing branch and frees the object.
- Test the same pattern in other password manager flows that use attempt limits and reset their checker on reaching the limit. A positive result is a use-after-free when the limit is reached during a nested call.
What happened, in plain words
Chrome has a built-in feature called the Password Manager. It stores the passwords you use on websites and can fill them in for you. One of its newer abilities is to offer to change a password for you when it notices that the saved password has appeared in a known data leak. A data leak is when a company's database of user accounts gets exposed, and the passwords in it become public knowledge. If your password is in such a leak, anyone could try it on your account, so changing it is a good idea.
When Chrome offers to change a leaked password, it runs a small guided process. Part of that process needs to know one thing first: are you currently signed in to the website? Before it starts, Chrome checks whether you are currently signed in to the website.
To make that check, Chrome sends the content of the current web page to an internal analysis service (an "optimisation guide model") and asks it to decide whether the page shows you as logged in. The answer comes back later, through a piece of code called a callback. A callback is simply a function you hand to someone else and say: run this when you have the answer. Think of leaving your phone number at a repair shop: you carry on with your day, and they call you when the job is done.
The bug in this report is that the object doing the checking (the LoginStateChecker) can be deleted by that very callback, and then carries on using its own memory as if it were still alive. Reading or writing memory that has already been given back is called a use-after-free. It is like writing a letter to a house that has already been demolished: the address still exists on paper, but nothing valid is there any more.
The report also notes that this use-after-free could be used to escape the sandbox without a compromised renderer. The sandbox is the security boundary Chrome puts around the part of the browser that renders web pages, so that a malicious page cannot reach the rest of your computer. A renderer is the separate process that draws a page. Escaping the sandbox normally requires first taking over the renderer; the researcher says this bug could allow the escape without that first step. The patch supplied with the report exists only to make the bug easier to trigger in Chromium, not to fix it.
Setup
The researcher compiled the newest Chromium with ASAN after applying change.txt. ASAN stands for AddressSanitizer. It is a debugging tool built into the compiler that watches memory while a program runs and shouts loudly when the program touches memory it should not, including memory that has already been freed. Building Chromium with ASAN means compiling the whole browser with that watchdog switched on.
The patch is a simulation aid, not part of the vulnerability. It makes the following changes:
- In
components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc, code is patched to simulate the password being detected as "LEAK", since the vulnerable function is only invoked in that situation. In other words, the researcher does not want to wait for a real leak to be discovered; the patch pretends one has been found so the password change offer appears. - In
chrome/browser/password_manager/password_change/login_state_checker.h,kMaxLoginChecksis changed to2so the issue triggers more quickly. This constant is the number of times Chrome will check whether you are logged in before giving up. Lowering it to two means the give-up path is reached after very few attempts instead of many. - In
components/optimization_guide/core/model_execution/model_execution_features_controller.cc, theoptimization_guide::UserVisibleFeatureKey::kPasswordChangeSubmissionfeature is enabled. Chrome ships many features behind on/off switches called feature flags. This patch flips the switch that allows the password change submission feature to run. - In
chrome/browser/password_manager/chrome_password_change_service.cc, support for IP-format websites is added, since otherwise a domain name is required. An IP address is the numeric address of a computer on a network, like[redacted], which always means "this computer". A domain name is the human-friendly name likeexample.com. The test server runs on a bare IP address, so the patch lets Chrome accept that. - In
chrome/browser/password_manager/password_change/login_state_checker.cc, the checks onresponseare patched to trigger the call toOnPageContentReceived. It also simulates the first attempt not being logged in, which triggers the call toOnPageContentReceived, and the second attempt reachingReachedAttemptsLimit, which runs the callback that deletes the checker. This is the heart of the simulation: the patch arranges the exact sequence of "not logged in" answers that leads to the deletion.
The test page is served from the folder containing poc.html with a simple HTTP server on port 8605, and Chrome is launched with a fresh user data directory and a password change URL pointing at that server. A port is a numbered door on a computer; a web server listens on one so that browsers know where to connect. A user data directory is the folder where Chrome keeps your profile: bookmarks, history, saved passwords. Pointing Chrome at a fresh one means the test starts from a clean slate with no leftovers from earlier runs.
Finding it
The researcher traced the ownership of login_state_checker_ and the callback it registers. Ownership here means: which piece of code is responsible for creating an object and for destroying it when it is no longer needed. In C++, a std::unique_ptr is a smart pointer that expresses exactly that: it holds the only reference to an object and automatically deletes the object when the pointer itself goes away or is reset. The checker is created with a callback bound to PasswordChangeDelegateImpl::OnLoginStateCheckResult:
if (base::FeatureList::IsEnabled(
password_manager::features::kCheckLoginStateBeforePasswordChange)) {
login_state_checker_ = std::make_unique<LoginStateChecker>(
originator_.get(), logs_uploader_.get(),
ChromePasswordManagerClient::FromWebContents(originator_),
base::BindRepeating(
&PasswordChangeDelegateImpl::OnLoginStateCheckResult,
weak_ptr_factory_.GetWeakPtr()));
}
Line by line:
if (base::FeatureList::IsEnabled(...))asks whether a particular feature flag is switched on. The flag iskCheckLoginStateBeforePasswordChange, which controls whether Chrome checks your login state before starting a password change. If the flag is off, none of the code inside the block runs.login_state_checker_ = std::make_unique<LoginStateChecker>(...)creates a newLoginStateCheckerobject and stores it in the member variablelogin_state_checker_. Because it is aunique_ptr, this member is now the sole owner of the checker and will delete it when told to.- The arguments passed to the constructor are the things the checker needs to do its job:
originator_.get()(the web page that started the flow),logs_uploader_.get()(something that uploads diagnostic logs), andChromePasswordManagerClient::FromWebContents(originator_)(the password manager client attached to that page). base::BindRepeating(&PasswordChangeDelegateImpl::OnLoginStateCheckResult, weak_ptr_factory_.GetWeakPtr())builds the callback.BindRepeatingmeans the callback can be called more than once. The function to call isOnLoginStateCheckResult, and the extra argument is a weak pointer to the delegate. A weak pointer does not keep the object alive; it only lets the callback check whether the object still exists before using it.
That callback can reset the login_state_checker_, which means the checker is deleted once the callback runs:
void PasswordChangeDelegateImpl::OnLoginStateCheckResult(bool is_logged_in) {
if (is_logged_in) {
// User is logged in, start password change process.
ProceedToChangePassword();
return;
}
blocking_challenge_detected_ = true;
if (!login_state_checker_->ReachedAttemptsLimit()) { //@audit: Only when ReachedAttemptsLimit is true, then `login_state_checker_` could be reset
// Update the UI to encourage user to complete sign in.
UpdateState(State::kLoginFormDetected);
return;
}
// Maximum number of retries reached, convert to terminal state.
UpdateState(State::kChangePasswordFormNotFound);
login_state_checker_.reset();
}
Line by line:
void PasswordChangeDelegateImpl::OnLoginStateCheckResult(bool is_logged_in)is the callback itself. It receives one answer:is_logged_in, true or false.if (is_logged_in)handles the happy case. If you are logged in,ProceedToChangePassword()starts the actual password change, andreturnends the function.blocking_challenge_detected_ = true;records that something is blocking the flow, in this case that you are not logged in.if (!login_state_checker_->ReachedAttemptsLimit())asks the checker whether it has already used up its allowed number of checks. The!means "not". If the limit has not been reached, Chrome updates the screen to encourage you to sign in (UpdateState(State::kLoginFormDetected)) and returns. Crucially, the checker is not deleted in this branch.- If the limit has been reached, the code falls through to
UpdateState(State::kChangePasswordFormNotFound), which moves the flow to a final state, and thenlogin_state_checker_.reset();. Resetting aunique_ptrdeletes the object it owns. This is the deletion that causes the trouble.
The reset only happens when ReachedAttemptsLimit() is true. The problem is that the checker itself invokes this callback from inside one of its own member functions and then keeps using its members afterwards. In everyday terms: the checker makes a phone call that ends with someone demolishing its own office, and then carries on writing at its desk.
Exploitation
Step 1: apply the patch and build with ASAN
The researcher applies change.txt to the newest Chromium and compiles Chrome with ASAN. The patch is only there to make the vulnerable path reachable more easily, as described in Setup.
Step 2: serve the proof of concept
Start a server in the folder containing poc.html:
python -m SimpleHTTPServer 8605
Line by line:
pythonruns the Python interpreter, a general-purpose programming language that ships with a small built-in web server.-m SimpleHTTPServertells Python to run the module namedSimpleHTTPServer, which serves the files in the current folder over HTTP. HTTP is the protocol browsers use to fetch web pages.8605is the port number. The server will listen on port 8605, and any browser askinghttp://[redacted]:8605/will be handed files from that folder.
This step exists so that the proof-of-concept page and the password change URL both live on a server the researcher controls, on the local machine.
Step 3: launch Chrome against the page
./chrome --user-data-dir=/tmp/noexist --password-change-url="http://[redacted]:8605/" http://[redacted]:8605/poc.html
Line by line:
./chromeruns the Chrome binary that was just built, from the current directory.--user-data-dir=/tmp/noexistgives Chrome a fresh profile folder at/tmp/noexist. Because the folder does not exist yet, Chrome starts with no saved passwords, no history and no settings from previous runs, so the test is repeatable.--password-change-url="http://[redacted]:8605/"points the password change flow at the local server.http://[redacted]:8605/poc.htmlis the page Chrome opens on startup. It is the proof-of-concept page served by the Python server.
Step 4: trigger the popup and click
After the popup is shown, click "Change it for me". The use-after-free occurs at that point. The use-after-free occurs at that point.
Root cause
The checker sends the page content to the optimisation guide model and binds LoginStateChecker::OnExecutionResponseCallback as the response handler:
void LoginStateChecker::OnPageContentReceived(
std::optional<optimization_guide::AIPageContentResult> content) {
CHECK(content);
if (is_request_in_flight_) {
cached_page_content_ = std::move(content);
return;
}
is_request_in_flight_ = true;
optimization_guide::proto::PasswordChangeRequest request;
request.set_step(kLoginCheckStep);
*request.mutable_page_context()->mutable_annotated_page_content() =
std::move(content->proto);
LogMessage(client_,
SavePasswordProgressLogger::STRING_LOGIN_STATE_CHECK_REQUEST_SENT);
optimization_guide::ExecuteModelWithLogging( //@audit: this function will directly call the OnExecutionResponseCallback, whihc will call the `callback`
GetOptimizationService(),
optimization_guide::ModelBasedCapabilityKey::kPasswordChangeSubmission,
request, /*execution_timeout=*/std::nullopt,
base::BindOnce(&LoginStateChecker::OnExecutionResponseCallback,
weak_ptr_factory_.GetWeakPtr()));
}
Line by line:
void LoginStateChecker::OnPageContentReceived(std::optional<optimization_guide::AIPageContentResult> content)is the function that receives the page content.std::optionalmeans the value might be present or might be empty.CHECK(content);is an assertion: ifcontentis empty, the program aborts immediately. It documents that this function expects real content.if (is_request_in_flight_)checks whether a request to the model is already on its way. If so, the new content is stored incached_page_content_withstd::move(content)and the function returns.std::movehands the value over without copying it. This caching is what makes the later re-entry possible.is_request_in_flight_ = true;marks that a request is now in progress.optimization_guide::proto::PasswordChangeRequest request;creates the request message that will be sent to the model. A proto (protocol buffer) is a structured data format used to exchange messages between programs.request.set_step(kLoginCheckStep);labels the request as a login check step.*request.mutable_page_context()->mutable_annotated_page_content() = std::move(content->proto);puts the page content into the request, moving it in rather than copying.LogMessage(client_, SavePasswordProgressLogger::STRING_LOGIN_STATE_CHECK_REQUEST_SENT);writes a diagnostic log line saying the login state check request was sent.optimization_guide::ExecuteModelWithLogging(...)sends the request to the model. The arguments are the optimisation service, the capability keykPasswordChangeSubmission(which model feature is being used), the request itself,std::nulloptfor the execution timeout (meaning no explicit timeout), and finally the callback built withbase::BindOnce(&LoginStateChecker::OnExecutionResponseCallback, weak_ptr_factory_.GetWeakPtr()).BindOncemeans this callback runs only once. The comment in the code notes that this function will directly callOnExecutionResponseCallback, which will call the delegate's callback.
In the response callback, if there is cached page content, the user is not logged in and the attempts limit has not been reached, the callback calls OnPageContentReceived again. That second call invokes the delegate's callback, which, once the attempts limit is reached, resets login_state_checker_ and deletes the checker. Control then returns to OnExecutionResponseCallback, which continues to touch its own members:
void LoginStateChecker::OnExecutionResponseCallback(
optimization_guide::OptimizationGuideModelExecutionResult execution_result,
std::unique_ptr<
optimization_guide::proto::PasswordChangeSubmissionLoggingData>
logging_data) {
[...]
if (cached_page_content_.has_value() && !is_logged_in &&
!ReachedAttemptsLimit()) {
OnPageContentReceived(std::move(cached_page_content_)); //@audit: OnPageContentReceived will invoke the callback and delete |this|
// Clear the page content to ensure that this check doesn't pass next time,
// which would lead to a request with empty page content.
cached_page_content_ = std::nullopt; //@audit: use after free
}
result_check_callback_.Run(is_logged_in); //@audit: user after free
}
Line by line:
void LoginStateChecker::OnExecutionResponseCallback(...)is the function that runs when the model has produced an answer. It receives the execution result and some logging data.[...]marks code the report leaves out, where the answer is interpreted andis_logged_inis worked out.if (cached_page_content_.has_value() && !is_logged_in && !ReachedAttemptsLimit())is the dangerous branch. It is taken only when three things are true at once: there is cached page content, the user is not logged in, and the attempts limit has not been reached.OnPageContentReceived(std::move(cached_page_content_));sends the cached content back into the function above. That call eventually invokes the delegate's callback. If this is the attempt that reaches the limit, the delegate resetslogin_state_checker_and the checker is deleted. The comment in the code says exactly this:OnPageContentReceivedwill invoke the callback and deletethis.cached_page_content_ = std::nullopt;then writes to a member of the object that has just been deleted. This is the first use after free. The comment explains the intent: clear the page content so the check does not pass next time, which would lead to a request with empty page content.result_check_callback_.Run(is_logged_in);runs the delegate's callback again, again on the freed object. This is the second use after free.
Both the assignment to cached_page_content_ and the later result_check_callback_.Run(is_logged_in) happen after the object has been freed. Synchronously means "right now, before anything else happens", as opposed to later on a separate task. A weak pointer can tell you an object is gone, but it cannot stop the object being deleted while you are still inside a function that belongs to it.
The report states that the use-after-free was introduced in commit [redacted], and that according to the commit it affects Chrome Stable 142.0.7444.59. A commit is a recorded change to the source code; a bisect is the process of narrowing down which change introduced a bug by testing versions in between.
Impact
The crash is a heap use-after-free in LoginStateChecker::OnExecutionResponseCallback; the report lists the crash type as browser. The heap is the area of memory a program uses for objects it creates while running; a heap use-after-free means one of those objects was freed and then touched again. The researcher notes that this use-after-free could be used to escape the sandbox without a compromised renderer. The report does not describe a concrete exploit chain beyond that statement.
Fix
The report does not describe the fix that was applied. The supplied change.txt is explicitly a simulation aid for triggering the bug, not a fix.
Variants to test
- Look for other callbacks bound with
base::BindRepeatingorbase::BindOncethat can synchronously reset the owning object through aunique_ptr. A positive result is a member access after the reset in the same call chain, visible in ASAN as a heap-use-after-free. - Check other
weak_ptr_factory_-based callbacks where the object is deleted synchronously inside the callback rather than posted to a later task. A positive result is a callback that runs after its owner has been freed. - Examine other optimisation guide model execution paths that re-enter their own response handler, for example through cached content. A positive result is a second invocation of the response handler that reaches a state-changing branch and frees the object.
- Test the same pattern in other password manager flows that use attempt limits and reset their checker on reaching the limit. A positive result is a use-after-free when the limit is reached during a nested call.
Glossary
- ASAN (AddressSanitizer): a debugging tool built into a compiler that detects invalid memory access, such as reading memory that has already been freed, while a program runs.
- API: an interface that lets one piece of software ask another to do something, without needing to know how it works inside.
- Bisect: the process of narrowing down which code change introduced a bug by testing versions between a known good and a known bad one.
- Callback: a function you give to another piece of code, to be run later when a result is ready.
- Chromium: the open-source browser project that Chrome is built from.
- Commit: a recorded change to a source code repository.
- Domain name: the human-readable name of a website, such as
example.com. - Feature flag: an on/off switch in the code that enables or disables a feature without rebuilding the program.
- Heap: the area of memory a program uses for objects it creates while running.
- HTTP: the protocol browsers use to request and receive web pages.
- IP address: the numeric address of a computer on a network, such as
[redacted], which means the local machine. - Optimisation guide model: an internal Chrome service that analyses content, here used to decide whether a page shows the user as logged in.
- Port: a numbered door on a computer that a network service listens on.
- Proto (protocol buffer): a structured data format used to exchange messages between programs.
- Renderer: the separate process in a browser that draws and runs web pages.
- Sandbox: the security boundary that isolates the renderer so a malicious page cannot reach the rest of the computer.
- Synchronous: happening immediately, in the same call chain, before control returns to the caller.
- Unique pointer (
std::unique_ptr): a C++ smart pointer that owns an object exclusively and deletes it when reset or destroyed. - Use-after-free: a bug where a program accesses memory that has already been freed, which can crash it or, in the worst case, be exploited.
- User data directory: the folder where a browser keeps a user's profile, including saved passwords and history.
- Weak pointer: a pointer that refers to an object without keeping it alive, and can be checked to see whether the object still exists.