Closed Bug 1681103 (CVE-2021-23989) Opened 5 years ago Closed 5 years ago

Firefox Lite Full Address Bar Spoofing w/ Secure Padlock by Open Copied Link on the Address Bar

Categories

(Emerging Markets Graveyard :: Security: Firefox Lite, defect)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: sourc7, Assigned: st3fan)

References

Details

(Keywords: csectype-spoof, reporter-external, sec-moderate, Whiteboard: [reporter-external] [client-bounty-form] [verif?])

Attachments

(4 files, 4 obsolete files)

Attached file testcase.html

It is possible to spoof Firefox Lite full address bar with secure padlock, by typing or pasting URL on website with empty response body (https://www.google.com/csi) or closed port (https://www.google.com:82) to the address bar.

While Firefox Lite loads the content, the target website URL stays on the address bar, so we can spoof current content using unbeforeunload event.

Browser tested:

Firefox Lite 2.5.2 (20647)
WebView version: 86.0.4240.198 (released on Nov 11th, 2020)

Steps to Reproduce:

  1. Visit attached testcase.html
  2. Tap "Copy URL"
  3. Tap on the address bar
  4. Tap "Open Copied Link"
  5. Address bar show: https://www.google.com/csi?response_type=auth&client_id=...
  6. Spoofed content show: Sign in to continue to Google Drive

Mitigation:

Currently I can't reproduce this on another WebView browser:

They do mitigate this spoof vulnerability by only displaying website on the address bar when it successfully loaded.

Flags: sec-bounty?
Group: firefox-core-security → mobile-core-security
Component: Security → Security: Firefox Lite
Product: Firefox → Emerging Markets
Type: task → defect

"moderate" because of the user-interaction req'd (you can't navigate into this situation), but excellent spoof.

Summary: Firefox Lite Full Address Bar Spoofing w/ Secure Padlock by Open Copied Link on the Address Bar → Firefox Lite Full Address Bar Spoofing with Secure Padlock
Attachment #9194804 - Attachment is obsolete: true

(In reply to Irvan Kurniawan (:sourc7) from comment #6)

... I think the perfectspoof.html should be reported as a separate bug, but I've mistakenly posted the detail on this bug. Is this ok :dveditz?

You're right: it's a separate (and worse!) issue. Created bug 1684986 to cover the new issue. I've also tagged comment 3 and following "offtopic" to hide them (so they don't derail any discussions about the original problem in this bug) but no disrespect is intended. It's a very good discovery and report.

Summary: Firefox Lite Full Address Bar Spoofing with Secure Padlock → Firefox Lite Full Address Bar Spoofing w/ Secure Padlock by Open Copied Link on the Address Bar

Thanks Daniel for the correction, firstly I think the bug has same underlying code, but after deep digging into mozilla-tw/FirefoxLite code it was a different issue.

This bug is verified.

I've been reading through the code but it is not immediately obvious where this should be fixed. Ivan, I'm curious if you have any ideas. We will investigate more tomorrow.

Flags: needinfo?(susah.yak)

(In reply to Stefan Arentz | :st3fan | ⏰ EST | he/him from comment #10)

This bug is verified.

I've been reading through the code but it is not immediately obvious where this should be fixed. Ivan, I'm curious if you have any ideas. We will investigate more tomorrow.

Thanks Stefan, the bug is at BrowserFragment.kt at updateURL() call on following function:

the loadUrl code:

override fun loadUrl(
    url: String,
    openNewTab: Boolean,
    isFromExternal: Boolean,
    onViewReadyCallback: Runnable?
) {
    updateURL(url)

and onUrlChanged code:

 override fun onUrlChanged(session: Session, url: String?) {
            chromeViewModel.onFocusedUrlChanged(url)
            if (!isForegroundSession(session)) {
                return
            }
            updateURL(url)
            shoppingSearchPromptMessageViewModel.checkShoppingSearchPromptVisibility(url)
        }

After tap "Open Copied Link", the updateURL() is called earlier to set the address bar to copied link's URL. So when user supplied url with empty response body, the WebViewClient is not navigating (stay on current page), but the address bar already set on that URL.

In this case we can follow Firefox for Android behavior, when the tab on the website is active (not in the new tab page) after tapping "Fill in links from clipboard", the address bar is not updated, because Firefox doesn't or failed to navigate to that URL.

I'll take a look if we can refactor the code to follow Firefox for Android behavior.

Flags: needinfo?(susah.yak)
Attached patch addressbarspoof.patch (obsolete) — Splinter Review

Finally I able to refactor the code to follow Firefox for Android behavior, now it works like below:

When user entered URL on the address bar -> update the progress bar -> when page successfully loaded -> update the address bar.

Attached patch addressbarspoof.patch (obsolete) — Splinter Review

It turns out after removing webViewClient.notifyCurrentURL(url) it no longer pass the URL to BrowserFragment.kt onUrlChanged function; therefore on this updated patch I remove the unused condition check.

Attachment #9202009 - Attachment is obsolete: true

Irvan, thank you so much for going beyond just reporting this issue. I'm going to review your patch and schedule a new release soon after.

(In reply to Irvan Kurniawan (:sourc7) from comment #13)

Created attachment 9202017 [details] [diff] [review]
addressbarspoof.patch

It turns out after removing webViewClient.notifyCurrentURL(url) it no longer pass the URL to BrowserFragment.kt onUrlChanged function; therefore on this updated patch I remove the unused condition check.

Thanks Stefan, surprisingly on some websites the onUrlChanged still receive the spoof URL, so I reverted to the previous patch.

Now I firmly sure this one solves the spoof issue.

Attachment #9202017 - Attachment is obsolete: true

However I found a way to bypass the patch, on Firefox Lite it also update the address bar from WebViewClient onReceivedTitle callback. By adding document.title="newtitle" on beforeunload the address bar will also set to spoof URL.

Hereby I attach the additional patch to address the issue, it removes updateURL on WebViewClient onReceivedTitle callback, I also refactor address bar update code sequence on WebViewClient onPageStarted so the address bar will be updated quickly (same as using onReceivedTitle hack workaround).

Flags: sec-bounty? → sec-bounty+

Irvan, apologies for the silence. We plan to ship this fix very soon. I am working on getting the patches in shape to get it out asap.

Verified as fixed on the latest FF Lite 2.6.1(20652) WebView 89.0.4389.90 (provided by Stefan) with Google Pixel 4 XL (Android 11) and Samsung Galaxy S7 (Android 7).
Note that following the steps from the description everything works as expected.

This is shipping today to 25%. We'll keep an eye on it and then go to 100% later this week.

Alias: CVE-2021-23989
Assignee: nobody → sarentz
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

Since this shipped, I am marking this as ASSIGNED/RESOLVED. Will soon publish the CVE in the Github project.

Group: mobile-core-security → core-security-release

(In reply to Stefan Arentz | :st3fan | ⏰ EST | he/him from comment #20)

Since this shipped, I am marking this as ASSIGNED/RESOLVED. Will soon publish the CVE in the Github project.

Thank you Stefan for the update, I also confirmed this has been fixed on Firefox Lite 2.6.1(20652) (on Play Store) with WebView version: 89.0.4389.105.

Status: RESOLVED → VERIFIED
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: