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

Use after free in Search (CVE-2026-78937)

A use-after-free flaw in Chrome for Android's search engine settings allows a malicious webpage to trigger a dangling pointer dereference, potentially leading to arbitrary memory read in the browser process. An attacker could exploit this by registering multiple OpenSearch engines and manipulating their visit order to cause a cached Java wrapper to reference freed C++ memory.

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 without the Chrome Security team.

Overview: A potential Use-After-Free (UAF) exists in the browser process on Chrome for Android when updating search engines via OpenSearch. The SearchEngineAdapter Java UI cache retains a raw JNI pointer to a TemplateURL that can be freed when a duplicate engine is added in the background, leading to a UAF read that bypasses MiraclePtr during UI refreshes.

Affected files:

  • chrome/browser/search_engines/android/java/src/org/chromium/chrome/browser/search_engines/settings/SearchEngineAdapter.java
  • components/search_engines/android/template_url_android.cc
  • components/search_engines/template_url_service.cc
  • components/search_engines/android/java/src/org/chromium/components/search_engines/TemplateUrl.java

Estimated timestamp from git blame: 2026-01-20

Summary

On Android, the SearchEngineAdapter (used for the 'Settings → Search engine' list) maintains a cache of TemplateUrl Java wrappers to represent recent and prepopulated search engines. Each Java wrapper holds a raw C++ pointer (long mTemplateUrlPtr) to its underlying TemplateURL object in the browser process.

When a TemplateURL is destroyed in the C++ backend—such as when it is automatically replaced by a newer OpenSearch Description Document (OSDD) engine with the same keyword—the Java observer is notified asynchronously. However, the update logic in SearchEngineAdapter performs a comparison between the new search engine list and the old cached list before updating its cache. This comparison invokes JNI methods on the cached wrappers, resulting in a Use-After-Free (UAF) dereference of the freed C++ TemplateURL pointer.

Because the reference is stored as a raw long on the Java heap, this vulnerability bypasses MiraclePtr (BackupRefPtr) protections.

Potential Exploitation Steps

The following sequence outlines how an attacker could potentially trigger this vulnerability:

  1. The attacker crafts a web page that registers 4 distinct OSDD engines by injecting <link rel="search" type="application/opensearchdescription+xml" href="osdd1.xml"> tags.
  2. In the renderer, ChromeRenderFrameObserver detects these tags and sends a Mojo message to the browser process, which downloads and adds the engines (E1, E2, E3, E4) to TemplateURLService.
  3. The attacker's webpage triggers background navigations to the search endpoints of E1, E2, E3, and E4. The Chrome History service updates their last_visited timestamps. The attacker spaces these so the visit recency is ordered: E4 > E3 > E2 > E1.
  4. The victim is persuaded to open Chrome Settings and navigate to the "Search engine" section. The Java SearchEngineAdapter initializes and calls refreshData().
  5. refreshData() retrieves the engines, sorts them by last_visited, and keeps at most MAX_RECENT_ENGINE_NUM (3). It retains E4, E3, and E2, while E1 is filtered out. The Java TemplateUrl wrappers for E4, E3, and E2 (holding raw C++ pointers) are cached in mRecentSearchEngines.
  6. While the Settings page remains open, the attacker's web page injects a 5th OSDD file (E5) configured with the same search keyword as E2.
  7. TemplateURLService::Add(E5) is called. It uses a Scoper to temporarily suppress observer notifications and calls RemoveDuplicateReplaceableEnginesOf(E5).
  8. RemoveDuplicateReplaceableEnginesOf finds the conflicting engine E2. Because E5 was created more recently, E5 is deemed "better".
  9. TemplateURLService::Remove(E2) is called, which destroys the std::unique_ptr<TemplateURL>. The C++ memory is freed. The BRP refcount reaches 0 because the only remaining reference is the raw long in the Java heap.
  10. The Scoper goes out of scope, triggering OnTemplateURLServiceChanged notifications.
  11. SearchEngineAdapter.onTemplateURLServiceChanged() calls refreshData(). It retrieves the new list: E1, E3, E4, and E5.
  12. E5 is filtered out because it has never been visited (last_visited is 0). The new list of recent engines is exactly 3: E4, E3, and E1.
  13. refreshData() calls didSearchEnginesChange(newList). Because the old list had 3 engines and the new list has 3 engines, it bypasses the early return and proceeds to an element-wise comparison.
  14. It calls containsTemplateUrl(mRecentSearchEngines, E1). This iterates over the old list, which contains the stale wrapper for E2.
  15. The comparison invokes E2.getIsPrepopulated() and E2.getKeyword(). These calls cross the JNI boundary and cast the dangling long back to a TemplateURL*, dereferencing the freed memory.
  16. base::android::ConvertUTF16ToJavaString reads the underlying UTF-16 character data using the string_view derived from the attacker-controlled memory layout, resulting in an arbitrary memory read in the Browser process.

Suggested Fix

To prevent this UAF and safely manage the lifecycle of the C++ object across the JNI boundary, the design should be updated so that Java does not hold raw pointers to memory it doesn't own.

Potential fixes include:

  1. Use base::android::ScopedJavaGlobalRef: Have the C++ TemplateURL object own a global reference to its Java counterpart. When the C++ object is destroyed, it can explicitly invalidate or clear the pointer inside the Java wrapper, preventing subsequent JNI calls from dereferencing a stale pointer.
  2. Pass Data by Value: Instead of caching wrappers with raw pointers, pass the required display data (keyword, short name, prepopulated ID) to Java by value when getTemplateUrls is called. The Java side would then compare these value objects rather than invoking native methods during the UI refresh loop.

Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b


Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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

The Java SearchEngineAdapter caches raw pointers to C++ TemplateURL objects without proper ownership tracking, so when the C++ object is freed, the Java side still holds a dangling pointer that is dereferenced during UI refresh comparisons.

Impact

A malicious webpage could cause a use-after-free read in the browser process, potentially leading to arbitrary memory read or a crash, though the report does not demonstrate full exploitation.

What the attacker needed

Victim uses Chrome for Android; victim visits attacker's webpage; victim opens search engine settings; attacker can register OpenSearch engines

The fix

The design should be updated so that Java does not hold raw pointers to memory it doesn't own, for example by using ScopedJavaGlobalRef or passing data by value.

How it was found

  1. The attacker crafts a web page that registers 4 distinct OSDD engines by injecting link tags.
  2. The attacker's webpage triggers background navigations to the search endpoints of E1, E2, E3, and E4, spacing them so visit recency is ordered E4 > E3 > E2 > E1.
  3. The victim opens Chrome Settings and navigates to the 'Search engine' section, causing SearchEngineAdapter to cache the top 3 recent engines (E4, E3, E2).
  4. While the Settings page remains open, the attacker's web page injects a 5th OSDD file (E5) with the same search keyword as E2.
  5. TemplateURLService::Add(E5) removes the duplicate E2, freeing its C++ memory, and then notifies observers.
  6. SearchEngineAdapter.onTemplateURLServiceChanged() calls refreshData(), which compares the new list against the old cached list, dereferencing the freed E2 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.

This report describes a memory safety bug in Chrome on Android. When you open the search engine settings, the app keeps a list of search engines in memory. If a malicious website adds a new search engine that replaces an existing one, the old engine's memory is freed, but the settings screen still holds a pointer to it. Later, when the screen refreshes, it tries to read the freed memory, which could crash the browser or leak data.

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.