Skip to content
UI spoofing Advisory Intermediate CVE-2025-1922

Inappropriate Implementation in Selection (CVE-2025-1922)

The Android text selection magnifier can remain on screen after navigating away from an attacker-controlled page, showing stale content over the address bar or other sites. An attacker could obscure or spoof browser UI or another site's content.

Alesandro Ortiz Follow

Originally disclosed on Chrome VRP

Bounty$5,000 Low View original
  • Fix shipped in 3 months

SUMMARY

The Android text selection magnifier remains on screen with attacker-controlled content after navigating away from attacker page. This can result in browser UI or another site's content being obscured or spoofed.

It's a detailed report with proposed patch, but likely low/medium severity at best, so please enjoy your holiday breaks.

VULNERABILITY DETAILS

The Android text selection magnifier is a rectangular box that shows the page content around a selection or insertion cursor/caret. The magnifier is shown when a user taps and holds a text handle. Text handles are shown when a user selects text in page or input field, or when there is an insertion caret in input fields or other content-editable elements.

When navigating to another page, Chromium will close an open magnifier in these cases:

  • When a page load starts (but only after commit 3c58f9355 in October 2024, see Additional Context section)
  • When a page load ends (if TouchSelectionController (TSC) hasn't changed, i.e. in most same-site navigations)
  • When user lifts finger from text handle before page load ends

However, the magnifier will remain open with content from the previous page if:

  • Page load starts, then user opens magnifier, then page load ends while magnifier is open. However, this only occurs if a new TouchSelectionController instance is created on page load start, which reliably occurs in cross-site navigations (see Root Cause section).

When the page load ends, the magnifier content stops being updated. The content will be the last content rendered on the previous page, which is attacker controlled. The magnifier will render over any page content or most browser UI, including the address bar and permission prompts.

Therefore, an attacker can either obscure or spoof browser UI or another page's content. For example, an attacker can show text over the address bar, show text/images or obscure buttons in permission prompts, or show text/images over another site's page.

The magnifier will remain shown until the user switches away from the Chromium browser to another app or turns off their screen. Opening a new magnifier does NOT dismiss the existing magnifier, so this can be repeated multiple times to obscure/spoof a larger area.

VERSION

Chrome Version: 131.0.6778.105 Stable, 133.0.6889.0 Canary

Repros down to 69.0.3474.0 with #enable-site-per-process flag, 78.0.3877.0 without flags.

Operating System: Android 14, Android 12

BISECT

There's a couple of bisects. These bisects were made with the PoC that opens magnifier before page load starts (android-magnifier-minimal-no-delay.html).

  1. Without any overridden flags: https://crrev.com/ab7700c387f9167d763484cfa659ef7931103890

    Enable ProactivelySwapBrowsingInstance in fieldtrial_testing_config (August 2019)

    If there are other attacker-controllable conditions that force a RWHVA/TSC swap, then it may repro earlier without flags.

  2. With #enable-site-per-process enabled: https://crrev.com/2d7e42f08f486ca3d5e28176f5ea0e3fb5bde0e8 (June 2018)

    This commit added the Magnifier logic for Android.

ADDITIONAL CONTEXT

Prior to commit 3c58f9355 [1] (October 2024), the magnifier will also remain open if:

  • User opens magnifier, then page load starts, then page load ends while magnifier is open. Only if a new TouchSelectionController instance is created on page load start.

PoC and video are also provided for before commit 3c58f9355, see android-magnifier-minimal-no-delay.html. I verified the older behavior via bisect. Also verified separately by commenting out ClearSelection() call from onPageLoadStarted() in ToT local build.

After the commit, the onPageLoadStarted() [2] observer closes the magnifier by calling SelectionPopupController::ClearSelection() [3] when a navigation is started. This is why after the commit a user must open the magnifier after the navigation starts. Before the commit, there is no ClearSelection() call on page load start.

[1] https://crrev.com/3c58f935519ca251c7ab32a423b66bd055c957ad [dnt] Back gesture clears text selection Landed in 131.0.6766.0 on October 8th, and merged into 131.0.6778.39 Stable.

[2] onPageLoadStarted() https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/ChromeActionModeHandler.java;l=102;drc=a0108592277483168bcedfd90b182a8b8ca5c5de

[3] ClearSelection() https://source.chromium.org/chromium/chromium/src/+/main:content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java;l=1701;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

REPRODUCTION CASE

Minimal PoCs don't require any setup. Realistic PoCs use a signal server which requires some setup.

Minimal PoC

This PoC is for current versions, after commit 3c58f9355. The magnifier must be opened after the navigation starts but before the nav finishes.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal.html
  2. Tap an input field once, then touch and hold the text handle, then wait a few seconds for slow navigation to finish.

Observed:

  • For top input field: Magnifier remains open over address bar. Address bar is partially obscured by magnifier.
  • For center input field: Magnifier remains open over next page. The next page's content is partially obscured by magnifier.

Expected: Magnifier is dismissed when user stops holding text handle or when next page finishes loading.

Minimal PoC, before commit 3c58f9355

This PoC works only before commit 3c58f9355 (r1365650). The magnifier can be opened before the navigation starts, so attack is easier to setup and perform.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal-no-delay.html
  2. Tap an input field once, then touch and move the text handle, then wait a few moments for navigation to occur.

Observed/Expected: Same as previous Minimal PoC.

Setup for self-hosting realistic PoCs:

The realistic PoCs use a signal server to avoid longer-than-needed navigation delay after magnifier is opened. For best results, the signal server should use HTTPS.

Signal server requires attached signal-server.js + permission.html + spoof.html

(If initial page is HTTPS, then signal server also requires HTTPS to avoid fetch being blocked due to mixed content. For permission prompt PoC, signal server must be on HTTPS due to permissions API requiring secure context.)

Important: The initial page and signal server MUST be on different sites for reliable repro, due to TSC swap requirement. Different ports on same hostname work fine for this purpose.

Setup HTTPS for signal server:

  1. Generate cert (self-signed: openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365), then update signal-server.js to use the key pair in https.createServer() and disable the http.createServer() call.

Before running PoCs:

  1. Run signal server. If using self-signed/untrusted cert, visit https://signal-server-host:port/ once to accept unsafe connection warning.
  2. Update SIGNAL_SERVER variable in initiator pages to reference your signal server (instead of the https://aogarantiza.com:1337 signal server, which won't work for you)
  3. Host initiator page on different site than signal server (e.g. using npx http-server locally; can be on HTTP)

Address bar spoof PoC

Note: Ensure signal server is running and is on a different site than initiator page.

  1. Navigate to initiator page: android-magnifier-omnibox.html
  2. Tap or slide finger anywhere.
  3. Slide finger as instructed by page.

Observed: Magnifier remains open over address bar. Address bar is partially obscured by magnifier.

Expected: Magnifier is dismissed when user stops holding text handle or when next page finishes loading.

Permission prompt obscured button PoC

Note: Signal server must be on HTTPS. Ensure signal server is running and is on a different site than initiator page.

  1. Navigate to intiator page: android-magnifier-permission.html
  2. Tap or slide finger anywhere.
  3. Slide finger as instructed by page.
  4. Tap anywhere when instructed by page to open permission prompt.

Observed: Magnifier remains open over permission prompt. Permission prompt is partially obscured by magnifier.

Expected: Same as previous PoC.

ROOT CAUSE

Observations below based on logs.

In cases where the RenderWidgetHostViewAndroid (RWHVA) [1] and TouchSelectionController (TSC) [2] instances stay alive across navigations, the magnifier is closed as expected when navigation finishes. When new instances of RWHVA and TSC are created, the magnifier remains open after navigation finishes.

I've observed that RWHVA and TSC are swapped for all cross-site navigations, and for some same-site navigations. Therefore, a cross-site navigation is an easy way to reliably reach the trigger conditions.

When a navigation commits, the renderer calls LayerTreeHostImpl::GenerateCompositorFrame() [5] which sends RenderFrameMetadata (RFM) to the browser. The RFM contains selection data.

The RFM selection data is calculated by LayerTreeImpl::GetViewportSelection() [3] (called by LayerTreeHostImpl::MakeRenderFrameMetadata() [4]). When a page loads, the RFM will indicate an empty selection (i.e. no selection) even when there was a selection in the previous page. This is expected behavior since the new page does not have a selection.

The RFM with selection data goes through this code path:

  • RFM created: LayerTreeHostImpl::GenerateCompositorFrame() [5]
  • RenderFrameMetadataObserverImpl::OnRenderFrameSubmission() [6] (renderer)
  • RenderFrameMetadataProviderImpl::OnRenderFrameMetadataChanged() [7] (browser)
  • RenderWidgetHostViewAndroid::OnRenderFrameMetadataChangedBeforeActivation() [8]
  • RenderWidgetHostViewAndroid::UpdateTouchSelectionController() [9]
  • TouchSelectionControllerClientManagerAndroid::UpdateClientSelectionBounds() [10]
  • TouchSelectionController::OnSelectionBoundsChanged() [11]

There is a key difference in behavior in TSC::OnSelectionBoundsChanged() between the repro vs. non-repro scenarios.

  • Repro (unexpected): For a newly-created TSC, the TSC's internal state will be initialized to empty/no selection. If the RFM also has an empty selection, TSC::OnSelectionBoundsChanged() will return early due to start == start_ && end_ == end being true.
  • Non-repro (expected): The existing TSC will have selection data from the previous page. Since the selection has changed compared to the selection previously known to the TSC, the rest of the OnSelectionBoundsChanged() logic will run.

In non-repro (expected) cases, the code path continues from OnSelectionBoundsChanged()...

  • TouchSelectionController::OnSelectionBoundsChanged() [11] updates the internal selection state
  • TouchSelectionController::HideHandles() (start/end.HasHandle() are false)
  • TouchSelectionController::DeactivateInsertion()
  • TouchHandle::SetEnabled(false)
  • TouchHandle::EndDrag()
  • TouchSelectionController::OnDragEnd()
  • RenderWidgetHostViewAndroid::OnSelectionEvent(INSERTION_HANDLE_DRAG_STOPPED)
  • SelectionPopupController::OnSelectionEvent() (C++ -> Java) with SelectionEventType.INSERTION_HANDLE_DRAG_STOPPED
  • MagnifierAnimator::handleDragStopped()
  • MagnifierWrapper::dismiss() / MagnifierSurfaceControl::dismiss() which finally dismisses the Android magnifier.

The calls after TSC::OnSelectionBoundsChanged() are easier to follow, so please use the Code Search link [11] to find the functions mentioned above.

Given the above, the magnifier isn't cleared in the repro cases because:

  • RWHVA and TSC change on navigation start, and are initialized as having no selection. TSC only dismisses the Magnifier if it knew of a previous selection and the new state is no selection.
  • There are no other calls to MagnifierWrapper::dismiss()

[1] RenderWidgetHostViewAndroid https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_android.cc;drc=0f0c2e5c34d04fb5875b26061fc349152787dd2e

[2] TouchSelectionController https://source.chromium.org/chromium/chromium/src/+/main:ui/touch_selection/touch_selection_controller.cc;drc=5f8dea3b512f8d1769e0d5c83a1721beedd0b458

[3] LayerTreeImpl::GetViewportSelection() https://source.chromium.org/chromium/chromium/src/+/main:cc/trees/layer_tree_impl.cc;l=2878;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[4] LayerTreeHostImpl::MakeRenderFrameMetadata() https://source.chromium.org/chromium/chromium/src/+/main:cc/trees/layer_tree_host_impl.cc;l=2591;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[5] LayerTreeHotImpl::GenerateCompositorFrame() calls OnRenderFrameSubmission() https://source.chromium.org/chromium/chromium/src/+/main:cc/trees/layer_tree_host_impl.cc;l=3059;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[6] RenderFrameMetadataObserverImpl::OnRenderFrameSubmission() https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/widget/compositing/render_frame_metadata_observer_impl.cc;l=100;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[7] RenderFrameMetadataProviderImpl::OnRenderFrameMetadataChanged() https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_frame_metadata_provider_impl.cc;l=118;drc=54fec6df88aed90af1239ebbf49f5deced265e8d

[8] RenderWidgetHostViewAndroid::OnRenderFrameMetadataChangedBeforeActivation() https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_android.cc;l=879;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[9] RenderWidgetHostViewAndroid::UpdateTouchSelectionController() https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_android.cc;l=1936;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[10] TouchSelectionControllerClientManagerAndroid::UpdateClientSelectionBounds() https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/input/touch_selection_controller_client_manager_android.cc;l=64;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

[11] TouchSelectionController::OnSelectionBoundsChanged() https://source.chromium.org/chromium/chromium/src/+/main:ui/touch_selection/touch_selection_controller.cc;l=77;drc=616d60fca655937c2b730db94fd32d37ddff3bb5

PATCH

The proposed patch to fix the issue adds a onDidFinishNavigationInPrimaryMainFrame() observer in ChromeActionModeHandler that makes a call to SelectionPopupController::ClearSelection(). This follows the same pattern used to clear the selection on page load start via onPageLoadStarted() observer.

The patch also adds a MagnifierAnimator::handleDragStopped() call within SelectionPopupController::ClearSelection().

I scoped the fix to only Java code because existing code paths that lead to MagnifierAnimator::handleDragStopped() are short-circuited in multiple places in the C++ code, as shown in Root Cause section. Updating the C++ code path to make the Java call may cause unexpected behavior changes elsewhere, since the code path involves many layers and is shared with other scenarios, not just the page load finished scenario.

As far as I can tell, there are no unexpected behavior changes with this patch.

Behavior after applying patch is shown in videos named fixed-*.

Credit Information

Reporter credit: Alesandro Ortiz https://AlesandroOrtiz.com

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

The Android text selection magnifier is a rectangular box that shows the page content around a selection or insertion cursor/caret. It appears when a user taps and holds a text handle. Text handles are shown when a user selects text in a page or input field, or when there is an insertion caret in input fields or other content-editable elements.

This report concerns Chromium on Android. The bug is that the magnifier can remain on screen, showing attacker-controlled content, after the user navigates away from the attacker's page. The magnifier then renders over page content or most browser UI, including the address bar and permission prompts, so it can obscure or spoof that UI or another site's content. The researcher rates it low/medium severity at best.

Setup

No special setup is needed for the minimal proofs of concept. The realistic proofs of concept use a signal server, which requires some setup.

Versions where the issue was confirmed:

Item Value
Chrome Stable 131.0.6778.105
Chrome Canary 133.0.6889.0
Operating system Android 14, Android 12

Reproductions were also confirmed down to 69.0.3474.0 with the #enable-site-per-process flag, and to 78.0.3877.0 without flags.

For the realistic proofs of concept, the signal server needs signal-server.js, permission.html and spoof.html. The initial page and the signal server must be on different sites for a reliable reproduction, because of the TouchSelectionController (TSC) swap requirement described below. Different ports on the same hostname work fine for this purpose. If the initial page is HTTPS, the signal server must also be HTTPS to avoid the fetch being blocked as mixed content. For the permission prompt proof of concept, the signal server must be on HTTPS because the permissions API requires a secure context.

To set up HTTPS for the signal server, generate a certificate:

Bash
openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365

Then update signal-server.js to use the key pair in https.createServer() and disable the http.createServer() call.

Before running the proofs of concept:

  1. Run the signal server. If using a self-signed or untrusted certificate, visit https://signal-server-host:port/ once to accept the unsafe connection warning.
  2. Update the SIGNAL_SERVER variable in the initiator pages to reference your signal server instead of the https://aogarantiza.com:1337 signal server, which will not work for you.
  3. Host the initiator page on a different site than the signal server, for example using npx http-server locally; it can be on HTTP.

Finding it

The researcher noticed that the magnifier stays open with content from the previous page when a page load starts, the user opens the magnifier, and the page load then ends while the magnifier is open. This only happens if a new TouchSelectionController instance is created on page load start, which reliably occurs in cross-site navigations.

When the page load ends, the magnifier content stops being updated. The content shown is the last content rendered on the previous page, which is attacker controlled. The magnifier renders over any page content or most browser UI, including the address bar and permission prompts. An attacker can therefore obscure or spoof browser UI or another page's content: show text over the address bar, show text or images over, or obscure buttons in, permission prompts, or show text or images over another site's page.

The magnifier remains shown until the user switches away from the Chromium browser to another app or turns off the screen. Opening a new magnifier does not dismiss the existing one, so the effect can be repeated multiple times to obscure or spoof a larger area.

Chromium closes an open magnifier on navigation in these cases:

  • When a page load starts, but only after commit 3c58f9355 in October 2024.
  • When a page load ends, if the TSC has not changed, which covers most same-site navigations.
  • When the user lifts their finger from the text handle before the page load ends.

Prior to commit 3c58f9355, the magnifier would also remain open if the user opened the magnifier, then the page load started, then the page load ended while the magnifier was open, again only if a new TSC instance was created on page load start. The researcher verified this older behaviour by bisect, and separately by commenting out the ClearSelection() call from onPageLoadStarted() in a local ToT build.

Exploitation

Minimal PoC (current versions)

This proof of concept is for versions after commit 3c58f9355. The magnifier must be opened after the navigation starts but before the navigation finishes.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal.html.
  2. Tap an input field once, then touch and hold the text handle, then wait a few seconds for the slow navigation to finish.

Observed:

  • For the top input field, the magnifier remains open over the address bar, partially obscuring it.
  • For the centre input field, the magnifier remains open over the next page, partially obscuring its content.

Expected: the magnifier is dismissed when the user stops holding the text handle or when the next page finishes loading.

Minimal PoC (before commit 3c58f9355)

This proof of concept works only before commit 3c58f9355 (r1365650). The magnifier can be opened before the navigation starts, so the attack is easier to set up and perform.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal-no-delay.html.
  2. Tap an input field once, then touch and move the text handle, then wait a few moments for the navigation to occur.

Observed and expected are the same as for the previous minimal PoC.

The realistic proofs of concept use a signal server to avoid a longer-than-needed navigation delay after the magnifier is opened. For best results, the signal server should use HTTPS.

Address bar spoof PoC

Ensure the signal server is running and is on a different site than the initiator page.

  1. Navigate to the initiator page android-magnifier-omnibox.html.
  2. Tap or slide a finger anywhere.

Observed: the magnifier remains open over the address bar, partially obscuring it.

Permission prompt obscured button PoC

The signal server must be on HTTPS. Ensure it is running and is on a different site than the initiator page.

  1. Navigate to the initiator page android-magnifier-permission.html.
  2. Tap or slide a finger anywhere.
  3. Tap anywhere when instructed by the page to open the permission prompt.

Observed: the magnifier remains open over the permission prompt, partially obscuring it.

Expected: the same as for the previous PoC.

Root cause

The observations below are based on logs.

When the RenderWidgetHostViewAndroid (RWHVA) and TouchSelectionController (TSC) instances stay alive across navigations, the magnifier is closed as expected when navigation finishes. When new instances of RWHVA and TSC are created, the magnifier remains open after navigation finishes. The researcher observed that RWHVA and TSC are swapped for all cross-site navigations and for some same-site navigations, so a cross-site navigation is an easy way to reliably reach the trigger conditions.

When a navigation commits, the renderer calls LayerTreeHostImpl::GenerateCompositorFrame(), which sends RenderFrameMetadata (RFM) to the browser. The RFM contains selection data, calculated by LayerTreeImpl::GetViewportSelection() (called by LayerTreeHostImpl::MakeRenderFrameMetadata()). When a page loads, the RFM indicates an empty selection even when there was a selection on the previous page. This is expected, since the new page has no selection.

The RFM with selection data goes through this code path:

  • RFM created: LayerTreeHostImpl::GenerateCompositorFrame()
  • RenderFrameMetadataObserverImpl::OnRenderFrameSubmission() (renderer)
  • RenderFrameMetadataProviderImpl::OnRenderFrameMetadataChanged() (browser)
  • RenderWidgetHostViewAndroid::OnRenderFrameMetadataChangedBeforeActivation()
  • RenderWidgetHostViewAndroid::UpdateTouchSelectionController()
  • TouchSelectionControllerClientManagerAndroid::UpdateClientSelectionBounds()
  • TouchSelectionController::OnSelectionBoundsChanged()

There is a key difference in behaviour in TSC::OnSelectionBoundsChanged() between the repro and non-repro scenarios:

  • Repro (unexpected): for a newly created TSC, the internal state is initialised to empty/no selection. If the RFM also has an empty selection, TSC::OnSelectionBoundsChanged() returns early because start == start_ && end_ == end is true.
  • Non-repro (expected): the existing TSC has selection data from the previous page. Since the selection has changed compared to what the TSC previously knew, the rest of the OnSelectionBoundsChanged() logic runs.

In the non-repro (expected) cases, the code path continues from OnSelectionBoundsChanged():

  • TouchSelectionController::OnSelectionBoundsChanged() updates the internal selection state
  • TouchSelectionController::HideHandles() (start/end.HasHandle() are false)
  • TouchSelectionController::DeactivateInsertion()
  • TouchHandle::SetEnabled(false)
  • TouchHandle::EndDrag()
  • TouchSelectionController::OnDragEnd()
  • RenderWidgetHostViewAndroid::OnSelectionEvent(INSERTION_HANDLE_DRAG_STOPPED)
  • SelectionPopupController::OnSelectionEvent() (C++ to Java) with SelectionEventType.INSERTION_HANDLE_DRAG_STOPPED
  • MagnifierAnimator::handleDragStopped()
  • MagnifierWrapper::dismiss() / MagnifierSurfaceControl::dismiss(), which finally dismisses the Android magnifier

Given the above, the magnifier is not cleared in the repro cases because RWHVA and TSC change on navigation start and are initialised as having no selection: the TSC only dismisses the magnifier if it knew of a previous selection and the new state is no selection. There are no other calls to MagnifierWrapper::dismiss().

Commit 3c58f9355 ([dnt] Back gesture clears text selection) landed in 131.0.6766.0 on 8 October and was merged into 131.0.6778.39 Stable. After it, the onPageLoadStarted() observer closes the magnifier by calling SelectionPopupController::ClearSelection() when a navigation starts, which is why a user must now open the magnifier after the navigation starts. Before the commit there was no ClearSelection() call on page load start.

Impact

An attacker can obscure or spoof browser UI or another page's content. Examples given are showing text over the address bar, showing text or images over, or obscuring buttons in, permission prompts, and showing text or images over another site's page. The magnifier stays until the user switches away from the browser to another app or turns off the screen, and opening a new magnifier does not dismiss the existing one, so the effect can be repeated to cover a larger area. The researcher rates the issue low/medium severity at best.

Fix

The proposed patch adds an onDidFinishNavigationInPrimaryMainFrame() observer in ChromeActionModeHandler that calls SelectionPopupController::ClearSelection(), following the same pattern used to clear the selection on page load start via the onPageLoadStarted() observer. The patch also adds a MagnifierAnimator::handleDragStopped() call within SelectionPopupController::ClearSelection().

The fix is scoped to Java code only because the existing code paths that lead to MagnifierAnimator::handleDragStopped() are short-circuited in multiple places in the C++ code, as shown in the root cause section. Updating the C++ code path to make the Java call may cause unexpected behaviour changes elsewhere, since the path involves many layers and is shared with other scenarios, not just the page load finished scenario. As far as the researcher can tell, there are no unexpected behaviour changes with this patch. The behaviour after applying the patch is shown in videos named fixed-*.

A positive result is a stale magnifier rendering over the surface after a cross-site navigation.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

When you select text on a phone, Android shows a small rectangular box just above your finger. It is a magnifying glass, called the magnifier, and it lets you see the exact spot where your finger is, so you can place the cursor or drag the selection handles precisely. The box shows a zoomed-in copy of whatever is on the page underneath your finger.

This report is about a bug in Chromium, the open-source browser engine that Google Chrome is built on, running on Android phones. The researcher found that the magnifier can be made to stay on screen after the user leaves the attacker's page. Worse, the picture inside the magnifier is frozen: it keeps showing the last thing the attacker's page drew, and it is drawn on top of whatever comes next, including the browser's own address bar and permission pop-ups.

That means a malicious page can leave a small rectangle of its own choosing floating over the browser interface. It could show fake text over the address bar, cover up a button in a permission prompt, or draw text and images over another website. The researcher rates the issue low to medium severity at best.

A few words before we go further, because they come up constantly:

  • Chromium is the engine inside Chrome (and several other browsers). When this article says "the browser", it means Chromium on Android.
  • UI stands for user interface: everything you see and touch in the browser that is not the web page itself, such as the address bar, menus and pop-ups.
  • Spoofing means making something look like something it is not. A fake login box drawn by a criminal is spoofing; so is fake text drawn over a real address bar.
  • Obscuring means hiding something behind something else, so you cannot see or tap it.

Context

The magnifier is a rectangular box that shows the page content around a selection or around the insertion cursor, also called the caret (the blinking line where text will appear when you type). It appears when a user taps and holds a text handle. Text handles are the little draggable markers shown when you select text in a page or an input field, or when there is an insertion caret in an input field or another content-editable element (an area of a page where you can type, such as a comment box).

The bug: the magnifier can remain on screen, showing attacker-controlled content, after the user navigates away from the attacker's page. It then renders over page content or most browser UI, including the address bar and permission prompts, so it can obscure or spoof that UI or another site's content. The researcher rates it low/medium severity at best.

Why does the picture inside the box matter so much? Because the attacker decides what their page draws. If the browser keeps a frozen copy of that drawing on top of everything else, the attacker is effectively painting on the browser's own interface.

Setup

No special setup is needed for the minimal proofs of concept. A proof of concept (PoC) is a small demonstration that shows a bug is real, without doing any harm. The realistic proofs of concept use a signal server, which requires some setup.

A signal server here is a small helper web server the researcher runs. The attacker page and the helper talk to each other so the page knows exactly when to trigger the navigation, instead of relying on a timer. Think of it as a stagehand who tells the actor when to walk on.

Versions where the issue was confirmed:

Item Value
Chrome Stable 131.0.6778.105
Chrome Canary 133.0.6889.0
Operating system Android 14, Android 12

Stable is the normal Chrome everyone installs. Canary is a bleeding-edge test build released daily, used to catch bugs early. A version number like 131.0.6778.105 identifies one exact build.

Reproductions were also confirmed down to 69.0.3474.0 with the #enable-site-per-process flag, and to 78.0.3877.0 without flags. A flag is a hidden switch in the browser that turns an experimental feature on or off; #enable-site-per-process is one such switch. "Reproduced down to version X" means the researcher went back through older and older builds and found the bug still present there, which helps date the bug.

For the realistic proofs of concept, the signal server needs signal-server.js, permission.html and spoof.html. The initial page and the signal server must be on different sites for a reliable reproduction, because of the TouchSelectionController (TSC) swap requirement described below. A site is roughly a domain name: example.com and example.org are different sites. Different ports on the same hostname work fine for this purpose. A port is a numbered door on a computer that a service listens on; the same machine can serve different things on different doors.

If the initial page is HTTPS, the signal server must also be HTTPS to avoid the fetch being blocked as mixed content. HTTPS is the encrypted version of the web (the padlock in the address bar). Mixed content is when an HTTPS page tries to load something over plain HTTP; browsers block that because the unencrypted part could be tampered with. For the permission prompt proof of concept, the signal server must be on HTTPS because the permissions API requires a secure context. An API (application programming interface) is a defined set of commands one piece of software offers to another; the permissions API is the browser feature that lets a page ask for things like the camera. A secure context is a page the browser trusts enough to allow powerful features, which in practice means HTTPS.

To set up HTTPS for the signal server, generate a certificate:

Bash
openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365

Line by line:

  • openssl is a widely used command-line tool for cryptography.
  • req tells it to create a certificate request, which here is used to make a self-signed certificate.
  • -x509 produces a self-signed certificate: one that signs itself rather than being signed by a trusted authority. Browsers will warn about it, which is why the next steps mention accepting a warning.
  • -nodes means "no DES", i.e. do not encrypt the private key file with a passphrase, so the server can read it without a prompt.
  • -newkey rsa:4096 creates a brand-new RSA key of 4096 bits alongside the certificate. RSA is a public-key algorithm; the key length is a strength setting.
  • -keyout key.pem writes the private key to a file called key.pem. The private key is the secret half of the pair and must never be shared.
  • -out cert.pem writes the certificate itself to cert.pem. The certificate is the public half, the part a browser is shown.
  • -sha256 uses SHA-256 as the hashing algorithm for the signature. A hash is a fixed-length fingerprint of data.
  • -days 365 makes the certificate valid for 365 days.

Then update signal-server.js to use the key pair in https.createServer() and disable the http.createServer() call. In plain words: the script currently starts a plain-HTTP server; you change it to start an encrypted one using the two files you just made, and stop it from also starting the unencrypted one.

Before running the proofs of concept:

  1. Run the signal server. If using a self-signed or untrusted certificate, visit https://signal-server-host:port/ once to accept the unsafe connection warning. The browser shows this warning because nobody it trusts has vouched for the certificate; visiting once and accepting tells the browser to remember your choice.
  2. Update the SIGNAL_SERVER variable in the initiator pages to reference your signal server instead of the https://aogarantiza.com:1337 signal server, which will not work for you. A variable is a named slot in a program that holds a value; here it holds the address the page should contact. The initiator page is the attacker page that starts the whole sequence.
  3. Host the initiator page on a different site than the signal server, for example using npx http-server locally; it can be on HTTP. npx runs a Node.js package without installing it globally, and http-server is a tiny static web server. The different-site rule exists because of the TSC swap described below.

Finding it

The researcher noticed that the magnifier stays open with content from the previous page when a page load starts, the user opens the magnifier, and the page load then ends while the magnifier is open. This only happens if a new TouchSelectionController instance is created on page load start, which reliably occurs in cross-site navigations.

A class in programming is a blueprint, and an instance is one object built from that blueprint. The TouchSelectionController (TSC) is the part of the browser that manages the selection handles and the magnifier. "A new instance is created" means the browser throws away the old manager and builds a fresh one, which starts out knowing nothing about any previous selection. A cross-site navigation is moving from a page on one site to a page on a different site.

When the page load ends, the magnifier content stops being updated. The content shown is the last content rendered on the previous page, which is attacker controlled. The magnifier renders over any page content or most browser UI, including the address bar and permission prompts. An attacker can therefore obscure or spoof browser UI or another page's content: show text over the address bar, show text or images over, or obscure buttons in, permission prompts, or show text or images over another site's page.

A permission prompt is the pop-up asking whether a site may use your camera, microphone or location. Users are trained to trust it, which is exactly why covering its buttons is dangerous.

The magnifier remains shown until the user switches away from the Chromium browser to another app or turns off the screen. Opening a new magnifier does not dismiss the existing one, so the effect can be repeated multiple times to obscure or spoof a larger area. Think of a sticker you cannot peel off: each new one adds to the pile.

Chromium closes an open magnifier on navigation in these cases:

  • When a page load starts, but only after commit 3c58f9355 in October 2024. A commit here is a change to the browser's source code, identified by a long hexadecimal code; the code is a fingerprint for that change.
  • When a page load ends, if the TSC has not changed, which covers most same-site navigations.
  • When the user lifts their finger from the text handle before the page load ends.

Prior to commit 3c58f9355, the magnifier would also remain open if the user opened the magnifier, then the page load started, then the page load ended while the magnifier was open, again only if a new TSC instance was created on page load start. The researcher verified this older behaviour by bisect, and separately by commenting out the ClearSelection() call from onPageLoadStarted() in a local ToT build.

A bisect is a debugging technique: test a version in the middle of a range, see whether the bug is present, then keep halving the range until you find the exact change that introduced it. ToT means "tip of tree", the very latest development code. Commenting out means turning a line of code into a comment so it no longer runs, a quick way to test what happens without it. ClearSelection() is the function that clears the current text selection; onPageLoadStarted() is the hook that runs when a page load begins.

Exploitation

Minimal PoC (current versions)

This proof of concept is for versions after commit 3c58f9355. The magnifier must be opened after the navigation starts but before the navigation finishes.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal.html.
  2. Tap an input field once, then touch and hold the text handle, then wait a few seconds for the slow navigation to finish.

Why these steps? The page deliberately makes the navigation slow, so there is a window of time in which the user can open the magnifier after the load has started but before it ends. Tapping the field once places the caret and shows a handle; touching and holding the handle opens the magnifier.

Observed:

  • For the top input field, the magnifier remains open over the address bar, partially obscuring it.
  • For the centre input field, the magnifier remains open over the next page, partially obscuring its content.

Expected: the magnifier is dismissed when the user stops holding the text handle or when the next page finishes loading.

Minimal PoC (before commit 3c58f9355)

This proof of concept works only before commit 3c58f9355 (r1365650). The magnifier can be opened before the navigation starts, so the attack is easier to set up and perform.

  1. Navigate to https://alesandroortiz.com/security/chromium/android-magnifier-minimal-no-delay.html.
  2. Tap an input field once, then touch and move the text handle, then wait a few moments for the navigation to occur.

Observed and expected are the same as for the previous minimal PoC. The difference is timing: on older builds the attacker does not need the user to act during the load, which makes the trick far easier to pull off.

The realistic proofs of concept use a signal server to avoid a longer-than-needed navigation delay after the magnifier is opened. For best results, the signal server should use HTTPS.

Address bar spoof PoC

Ensure the signal server is running and is on a different site than the initiator page.

  1. Navigate to the initiator page android-magnifier-omnibox.html.
  2. Tap or slide a finger anywhere.

"Omnibox" is Chrome's internal name for the address bar. The page guides the finger because the exact gesture timing matters; the page can react to touches and tell the user what to do next.

Observed: the magnifier remains open over the address bar, partially obscuring it.

Permission prompt obscured button PoC

The signal server must be on HTTPS. Ensure it is running and is on a different site than the initiator page.

  1. Navigate to the initiator page android-magnifier-permission.html.
  2. Tap or slide a finger anywhere.
  3. Tap anywhere when instructed by the page to open the permission prompt.

Observed: the magnifier remains open over the permission prompt, partially obscuring it.

Expected: the same as for the previous PoC.

Root cause

The observations below are based on logs. A log is a running record of what a program did, used to trace events after the fact.

When the RenderWidgetHostViewAndroid (RWHVA) and TouchSelectionController (TSC) instances stay alive across navigations, the magnifier is closed as expected when navigation finishes. When new instances of RWHVA and TSC are created, the magnifier remains open after navigation finishes. The researcher observed that RWHVA and TSC are swapped for all cross-site navigations and for some same-site navigations, so a cross-site navigation is an easy way to reliably reach the trigger conditions.

The RWHVA is the browser-side object that displays one web page's rendered output on Android. "Swapped" means the old object is replaced by a fresh one. A fresh object has no memory of the old selection, and that missing memory is the heart of the bug.

When a navigation commits, the renderer calls LayerTreeHostImpl::GenerateCompositorFrame(), which sends RenderFrameMetadata (RFM) to the browser. The RFM contains selection data, calculated by LayerTreeImpl::GetViewportSelection() (called by LayerTreeHostImpl::MakeRenderFrameMetadata()). When a page loads, the RFM indicates an empty selection even when there was a selection on the previous page. This is expected, since the new page has no selection.

The renderer is the part of the browser that turns a web page into pixels; the browser process is the part that owns the window, the address bar and the user's input. They are separate programs that talk to each other. A frame is one complete picture the browser draws on screen, like one frame of a film. Metadata is data about data: here, a small package of facts about the frame, such as where the text selection is.

The RFM with selection data goes through this code path:

  • RFM created: LayerTreeHostImpl::GenerateCompositorFrame()
  • RenderFrameMetadataObserverImpl::OnRenderFrameSubmission() (renderer)
  • RenderFrameMetadataProviderImpl::OnRenderFrameMetadataChanged() (browser)
  • RenderWidgetHostViewAndroid::OnRenderFrameMetadataChangedBeforeActivation()
  • RenderWidgetHostViewAndroid::UpdateTouchSelectionController()
  • TouchSelectionControllerClientManagerAndroid::UpdateClientSelectionBounds()
  • TouchSelectionController::OnSelectionBoundsChanged()

Read this list as a relay race: each name is a function, and the arrow between them is a handover. The frame is generated, an observer in the renderer notices it, a provider in the browser passes the news along, the Android view updates its selection controller, and finally the controller is told the selection bounds changed.

There is a key difference in behaviour in TSC::OnSelectionBoundsChanged() between the repro and non-repro scenarios:

  • Repro (unexpected): for a newly created TSC, the internal state is initialised to empty/no selection. If the RFM also has an empty selection, TSC::OnSelectionBoundsChanged() returns early because start == start_ && end_ == end is true.
  • Non-repro (expected): the existing TSC has selection data from the previous page. Since the selection has changed compared to what the TSC previously knew, the rest of the OnSelectionBoundsChanged() logic runs.

In plain words: the function compares the new selection with the one it remembers. If they are identical, it assumes nothing happened and stops. A brand-new controller remembers "nothing selected", the new page also reports "nothing selected", so the two match and the function stops early. But stopping early skips the cleanup that would have dismissed the magnifier. start == start_ && end_ == end is a comparison: the incoming start and end positions equal the stored ones.

In the non-repro (expected) cases, the code path continues from OnSelectionBoundsChanged():

  • TouchSelectionController::OnSelectionBoundsChanged() updates the internal selection state
  • TouchSelectionController::HideHandles() (start/end.HasHandle() are false)
  • TouchSelectionController::DeactivateInsertion()
  • TouchHandle::SetEnabled(false)
  • TouchHandle::EndDrag()
  • TouchSelectionController::OnDragEnd()
  • RenderWidgetHostViewAndroid::OnSelectionEvent(INSERTION_HANDLE_DRAG_STOPPED)
  • SelectionPopupController::OnSelectionEvent() (C++ to Java) with SelectionEventType.INSERTION_HANDLE_DRAG_STOPPED
  • MagnifierAnimator::handleDragStopped()
  • MagnifierWrapper::dismiss() / MagnifierSurfaceControl::dismiss(), which finally dismisses the Android magnifier

This is the cleanup chain. The controller updates its state, hides the handles, deactivates the insertion caret, disables and ends the handle drag, reports a "drag stopped" event, and that event travels from the C++ layer into the Java layer of Android code, where the magnifier animator and wrapper finally dismiss the box. C++ and Java are two programming languages; Chromium's core is C++, while much of Chrome's Android interface is Java, so events cross that boundary.

Given the above, the magnifier is not cleared in the repro cases because RWHVA and TSC change on navigation start and are initialised as having no selection: the TSC only dismisses the magnifier if it knew of a previous selection and the new state is no selection. There are no other calls to MagnifierWrapper::dismiss().

Commit 3c58f9355 ([dnt] Back gesture clears text selection) landed in 131.0.6766.0 on 8 October and was merged into 131.0.6778.39 Stable. After it, the onPageLoadStarted() observer closes the magnifier by calling SelectionPopupController::ClearSelection() when a navigation starts, which is why a user must now open the magnifier after the navigation starts. Before the commit there was no ClearSelection() call on page load start. "Landed" means the change was accepted into the main codebase; "merged" means it was then copied into the stable release branch.

Impact

An attacker can obscure or spoof browser UI or another page's content. Examples given are showing text over the address bar, showing text or images over, or obscuring buttons in, permission prompts, and showing text or images over another site's page. The magnifier stays until the user switches away from the browser to another app or turns off the screen, and opening a new magnifier does not dismiss the existing one, so the effect can be repeated to cover a larger area. The researcher rates the issue low/medium severity at best.

The harm is deception: a fake picture in the wrong place, which could mislead a user into trusting a wrong address or tapping the wrong button.

Fix

The proposed patch adds an onDidFinishNavigationInPrimaryMainFrame() observer in ChromeActionModeHandler that calls SelectionPopupController::ClearSelection(), following the same pattern used to clear the selection on page load start via the onPageLoadStarted() observer. The patch also adds a MagnifierAnimator::handleDragStopped() call within SelectionPopupController::ClearSelection().

A patch is a small change to source code that fixes a problem. An observer is a piece of code that registers interest in an event and is called when it happens; here, "navigation finished in the main frame" is the event. The main frame is the top-level page, as opposed to embedded frames inside it. The fix reuses the pattern already used at page load start, now also at page load finish, and makes clearing the selection also stop the magnifier drag.

The fix is scoped to Java code only because the existing code paths that lead to MagnifierAnimator::handleDragStopped() are short-circuited in multiple places in the C++ code, as shown in the root cause section. Updating the C++ code path to make the Java call may cause unexpected behaviour changes elsewhere, since the path involves many layers and is shared with other scenarios, not just the page load finished scenario. As far as the researcher can tell, there are no unexpected behaviour changes with this patch. The behaviour after applying the patch is shown in videos named fixed-*.

"Short-circuited" means the code exits early before reaching the later steps, exactly like the early return described above. Touching that shared C++ path risks breaking other features that use it, so the researcher chose the narrower Java-side fix.

Glossary

  • API: a defined set of commands one piece of software offers to another, so they can work together without knowing each other's internals.
  • Bisect: a debugging method that halves a range of versions repeatedly to find the exact change that introduced a bug.
  • Browser process: the part of the browser that owns the window, address bar and user input, separate from the renderer.
  • C++: a compiled programming language used for Chromium's core engine.
  • Canary: a daily test build of Chrome, newer and less stable than the normal release.
  • Caret: the blinking line showing where typed text will appear; also called the insertion cursor.
  • Certificate: a file that proves a server's identity for HTTPS; it can be self-signed, meaning it vouches for itself and browsers warn about it.
  • Class: a blueprint in programming from which objects (instances) are created.
  • Commit: a recorded change to source code, identified by a long hexadecimal code.
  • Content-editable element: an area of a web page where the user can type, such as a comment box.
  • Cross-site navigation: moving from a page on one site to a page on a different site.
  • Flag: a hidden browser switch that enables or disables an experimental feature.
  • Frame: one complete picture the browser draws on screen.
  • Hash: a fixed-length fingerprint computed from data.
  • HTTPS: the encrypted version of the web, shown by a padlock in the address bar.
  • Instance: one object built from a class blueprint.
  • Java: a programming language used for much of Chrome's Android interface code.
  • Log: a running record of what a program did, used to trace events.
  • Magnifier: the small rectangular box on Android that zooms in on the text around your finger.
  • Main frame: the top-level web page, as opposed to frames embedded inside it.
  • Metadata: data about data; here, facts about a drawn frame such as the selection position.
  • Mixed content: an HTTPS page loading something over plain HTTP, which browsers block.
  • Observer: code that registers interest in an event and runs when that event happens.
  • Obscure: to hide something behind something else so it cannot be seen or tapped.
  • Omnibox: Chrome's internal name for the address bar.
  • Patch: a small change to source code that fixes a problem.
  • Permission prompt: the pop-up asking whether a site may use the camera, microphone or location.
  • Port: a numbered door on a computer that a network service listens on.
  • Proof of concept (PoC): a small demonstration showing a bug is real without causing harm.
  • Renderer: the part of the browser that turns a web page into pixels.
  • RSA: a public-key cryptographic algorithm; the key length (e.g. 4096 bits) is a strength setting.
  • Secure context: a page the browser trusts enough to allow powerful features, in practice HTTPS.
  • Self-signed certificate: a certificate that signs itself rather than being signed by a trusted authority.
  • SHA-256: a widely used hashing algorithm.
  • Short-circuit: to exit a function early before reaching later steps.
  • Signal server: a small helper server used by the proofs of concept to coordinate timing between pages.
  • Site: roughly a domain name; different domains are different sites.
  • Spoof: to make something look like something it is not.
  • Stable: the normal Chrome release everyone installs.
  • Text handle: the small draggable marker shown when text is selected or a caret is placed.
  • ToT (tip of tree): the very latest development code.
  • TouchSelectionController (TSC): the browser component that manages selection handles and the magnifier.
  • UI: user interface; everything in the browser that is not the web page itself.
  • Variable: a named slot in a program that holds a value.
  • X.509: the standard format for HTTPS certificates, selected by the -x509 option.

More by Alesandro Ortiz

View all

33 more disclosed reports, best first.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Clickjacking and UI spoofing

The lesson behind this report.

The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.