Skip to content
Memory corruption Advisory Advanced CVE-2026-17685

Use after free in Autofill (CVE-2026-17685)

A use-after-free vulnerability exists in the password generation agent because synchronous JavaScript execution during iteration over a heap-allocated vector can destroy the underlying GenerationItemInfo structure. An attacker could potentially trigger this by manipulating focus and input events to free the vector while it is still being iterated, leading to memory corruption.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 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 Use-After-Free (UAF) vulnerability exists in PasswordGenerationAgent due to synchronous JavaScript execution during iteration over a heap-allocated vector of elements. By triggering a re-entrant focus/text change during password generation, the underlying GenerationItemInfo structure can be destroyed and freed. Resuming the iteration or accessing the elements afterwards results in a use-after-free scenario.

Affected files:

  • components/autofill/content/renderer/password_generation_agent.cc

Estimated timestamp from git blame: 2018-11-06

Root Cause Analysis

In components/autofill/content/renderer/password_generation_agent.cc, the method PasswordGenerationAgent::GeneratedPasswordAccepted performs an iteration over current_generation_item_->password_elements_ (which is a heap-allocated std::vector<blink::WebInputElement> owned by current_generation_item_):

C++
  for (blink::WebInputElement& password_element :
       current_generation_item_->password_elements_) {
    ScopedUpdatingOtherPasswordFields auto_reset_update_confirmation_password(
        this);
    password_element.SetAutofillValue(blink::WebString::FromUtf16(password));
    // ...

When password_element.SetAutofillValue is called, it can dispatch synchronous events (e.g., keydown/keyup and subsequent DOM events) into the document, allowing untrusted attacker-controlled JavaScript to execute synchronously mid-iteration.

During this synchronous execution window, the attacker can:

  1. Clear the password element's value, reducing its length below kMinimumLengthForEditedPassword (4).
  2. Shift focus back to the element, triggering focus/suggestion state updates. This invokes PasswordNoLongerGenerated(), resetting current_generation_item_->password_is_generated_ to false.
  3. Shift focus to another password generation-eligible field. This triggers ShowPasswordGenerationSuggestions() for the new field, invoking MaybeCreateCurrentGenerationItem().

Since current_generation_item_->password_is_generated_ is now false, the re-entrancy guard in MaybeCreateCurrentGenerationItem() is bypassed:

C++
  if (current_generation_item_ &&
      (current_generation_item_->generation_element_ == generation_element ||
       current_generation_item_->password_is_generated_))
    return;

This causes the agent to reassign the current_generation_item_ unique pointer:

C++
  current_generation_item_ = std::make_unique<GenerationItemInfo>(...);

Reassigning the unique pointer immediately destroys the old GenerationItemInfo, deallocating the underlying std::vector<blink::WebInputElement>. When control returns from JavaScript to the C++ loop in GeneratedPasswordAccepted, the range-for loop's internal iterators/references point to deallocated memory, resulting in a Use-After-Free.

A secondary, identical instance also potentially occurs in CopyElementValueToOtherInputElements() via text-change mirroring, where elements is passed as a reference to current_generation_item_->password_elements_.


Potential Trigger Steps

Note: Since our testing environment is purely static and we cannot run code, the following sequence represents a potential proof-of-concept flow:

  1. Create a page with two password fields pwA (Form 1) and pwB (Form 2), both eligible for password generation.
  2. Bind an input event listener to pwA in JavaScript.
  3. Accept the generated password suggestion on pwA, triggering GeneratedPasswordAccepted().
  4. In the first loop iteration, SetAutofillValue() is called on pwA. This triggers the synchronous input event listener.
  5. Inside the event listener, the script sets pwA.value = '' and focuses a helper element, then refocuses pwA.
  6. This synchronously dispatches a focus change. AutofillAgent handles the focus and calls ShowPasswordGenerationSuggestions(pwA).
  7. Seeing the value is empty, the agent calls PasswordNoLongerGenerated(), setting password_is_generated_ to false.
  8. The script now shifts focus to pwB.
  9. This triggers ShowPasswordGenerationSuggestions(pwB). Since the re-entrancy guard checks are bypassed, current_generation_item_ is reassigned and the old allocation is freed.
  10. The JavaScript execution completes, and the native stack resumes iteration over the now-deallocated password_elements_ vector.

MiraclePtr / Mitigation Discussion

The dangling iterators and elements are stored within a standard std::vector heap allocation on PartitionAlloc. Because the Use-After-Free occurs on the container's backing buffer itself (and raw iterators used in the range-for loop expansion), this is not mitigated by MiraclePtr.


Suggested Fix

The safest and most robust fix is to use a base::WeakPtr to track the lifetime of GenerationItemInfo and return early if the item is destroyed or replaced during synchronous event dispatch.

In components/autofill/content/renderer/password_generation_agent.cc:

C++
void PasswordGenerationAgent::GeneratedPasswordAccepted(
    const std::u16string& password) {
  if (!current_generation_item_) {
    return;
  }
  // ...
  base::WeakPtr<GenerationItemInfo> generation_item =
      current_generation_item_->weak_ptr_factory_.GetWeakPtr();

  for (size_t i = 0; i < generation_item->password_elements_.size(); ++i) {
    ScopedUpdatingOtherPasswordFields auto_reset_update_confirmation_password(
        this);
    
    // We copy the element to a local variable to be safe
    blink::WebInputElement password_element = generation_item->password_elements_[i];
    password_element.SetAutofillValue(blink::WebString::FromUtf16(password));

    // Check if the generation item was replaced or destroyed during synchronous JS
    if (!generation_item) {
      return;
    }
    
    if (!render_frame()) {
      return;
    }
    if (password_element.Value().IsEmpty()) {
      return;
    }
    password_agent_->TrackAutofilledElement(password_element);
  }
  // ...

This pattern should also be applied to other loops in password_generation_agent.cc that invoke SetAutofillValue or dispatch synchronous events, including CopyElementValueToOtherInputElements and the subsequent UpdateStateForTextChange loop.

Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 code iterates over a heap-allocated vector owned by a unique pointer, and synchronous JavaScript execution during the loop can reassign that pointer, freeing the vector while iterators still reference it.

Impact

This could lead to memory corruption, potentially allowing an attacker to execute arbitrary code or cause a denial of service, though the report does not demonstrate a full exploit.

What the attacker needed

Victim visits a malicious page; page has two password fields; user accepts password suggestion

The fix

The fix should use a base::WeakPtr to track the lifetime of GenerationItemInfo and return early if it is destroyed during synchronous event dispatch, and apply this pattern to other similar loops.

How it was found

  1. Create a page with two password fields, both eligible for password generation.
  2. Bind an input event listener to the first password field.
  3. Accept the generated password suggestion on the first field, triggering GeneratedPasswordAccepted().
  4. In the event listener, clear the first field's value and shift focus to a helper element, then back to the first field.
  5. Shift focus to the second password field, causing the current generation item to be replaced and the old one freed.
  6. The native loop resumes iterating over the freed vector.

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 a program frees memory but keeps using it, that's a use-after-free. Here, the browser's password generator loops over a list of password fields, and during that loop, a malicious webpage can run JavaScript that causes the list to be deleted. The loop then continues using the deleted list, which can crash the browser or potentially be exploited.

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.

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.