Inappropriate implementation in FedCM (CVE-2024-6999)
The FedCM dialog displays the string '://' when the initiator origin is opaque, instead of a proper origin. An attacker could use this to spoof the origin shown in the dialog, especially when combined with other issues, and potentially obtain credentials.
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
SUMMARY
The FedCM prompts (either bubble or modal) will show :// if the initiator origin is opaque.
This can result in origin spoofing, especially when combined with other issues.
Showing the FedCM prompt does not require user interaction.
A compromised renderer can open popups without user interaction, so the PoCs dependent on popups can be performed with minimal user interaction.
The FedCM prompt has two dialog types [1]: bubble and modal. Both types are affected since they use the same logic to get the displayed origin string.
VULNERABILITY DETAILS
The FedCM dialog uses webid::FormatUrlForDisplay() [1] to get the origin string to display. There are no checks for opaque origins in this function nor most of its callers, so opaque origins result in the string :// being returned and displayed to users.
webid::FormatUrlForDisplay() is called by FederatedAuthRequestImpl::FormatOriginForDisplay() [2], which is called by either GetTopFrameOriginForDisplay() [3] or GetIframeOriginForDisplay() [4].
GetTopFrameOriginForDisplay() does not check if the origin is opaque.
GetIframeOriginForDisplay() would return an error if the iframe origin is opaque, however, the code is currently hardcoded to skip this logic and always return std::nullopt.
GetTopFrameOriginForDisplay() is used when showing dialogs, such as ShowAccountsDialog() [5]. References of GetTopFrameOriginForDisplay() [4] also show it's used for error dialogs, loading dialogs, and other states.
GetTopFrameOriginForDisplay() is passed the origin from GetEmbeddingOrigin() [6], which always returns the main frame's last committed origin.
The origin isn't checked for opaqueness anywhere in the code path above.
POTENTIAL SOLUTION
Check for origin opaqueness at one or more points in the code path shown above, and adjacent paths. If origin is opaque, return an error (assuming FedCM should be unsupported in opaque origins, as are other sensitive UIs that display origins).
VERSION
Chrome Version: 126.0.6478.3 Canary, 124.0.6367.208 Stable.
Operating System: Windows 10 Version 22H2 (Build 19045.4170)
BISECT
Starts reproducing on commit https://chromium.googlesource.com/chromium/src/+/ea6193f7caf0dab0216461b2e05ae5769d777274
Landed in 109.0.5361.0 in October 2022: https://chromiumdash.appspot.com/commit/79d9b185bf4115c2bc6cbe919655f7a4cb940f24
Verified repro down to 109.0.5361.0.
Prior to the commit above, the hostname (aogarantiza.com) is shown, which I don't think is correct either given the page's origin is opaque. That behavior probably exists since the introduction of FedCM.
REPRODUCTION CASE
Setup:
- Run a simulated IDP server:
node server-single-account.js(attached)
In real scenarios, an attacker would use a legit IDP since they would want real credentials.
Scenario 1: Using bubble dialog (mode: widget)
- Navigate to https://aogarantiza.com/chromium/fedcm-opaque.php
- Login using FedCM dialog
Scenario 2: Using modal dialog (mode: button)
Note: This requires an origin trial for FedCM button mode, which I registered for aogarantiza.com with 3P support.
- Navigate to https://aogarantiza.com/chromium/fedcm-opaque.php?mode=button
- Click anywhere once
- Login using FedCM dialog
Scenario 3: Using popup to show prompt over another origin
- Navigate to https://alesandroortiz.com/security/chromium/fedcm-opaque-open.html
- Click anywhere once
- Login using FedCM dialog
For all scenarios:
Observed: Origin of initiator is shown as ://. Page is able to obtain credentials after successful login.
Expected: FedCM dialog is not shown.
CREDIT INFORMATION
Reporter credit: Alesandro Ortiz https://AlesandroOrtiz.com
Context
FedCM (Federated Credential Management) is the browser API that lets a relying party site ask the browser to show a federated login prompt for an identity provider. When a site calls the API, Chrome renders a dialog that names the origin of the page that initiated the request, so the user can see who is asking for their credentials before approving the login.
The dialog comes in two types: a bubble and a modal. Both types share the same logic for producing the origin string that is displayed. That shared logic is where the problem sits: when the initiator origin is opaque, the dialog shows the literal string :// instead of a hostname.
This was reported against Chrome and tracked as CVE-2024-6999, an inappropriate implementation in FedCM. The reporter was Alesandro Ortiz, the report came through the Chrome VRP, the severity was medium, and the bounty was 2000.00 USD. It was disclosed on 2024-07-23.
Setup
The affected versions were Chrome 126.0.6478.3 Canary and 124.0.6367.208 Stable, on Windows 10 Version 22H2 (Build 19045.4170).
For reproduction, the report uses a simulated identity provider server, started with:
node server-single-account.js
The script is attached to the report rather than reproduced in it. The report notes that in a real scenario an attacker would use a legitimate identity provider, since the goal is to obtain real credentials.
Scenario 2 needs an origin trial for FedCM button mode, which the reporter registered for aogarantiza.com with third-party support. Scenario 3 uses a separate page on alesandroortiz.com that opens a popup.
Finding it
The reporter observed that the FedCM prompt, in either the bubble or the modal form, displays :// when the initiator origin is opaque. An opaque origin is one with no usable tuple of scheme, host and port, for example the origin of a sandboxed document or of a page reached in a way that strips its origin. Such an origin has no hostname to show, and the display code does not handle that case.
The result is origin spoofing: the user is shown a meaningless string where a site identity should be, and the report notes this is especially relevant when combined with other issues.
Two properties make the issue easier to reach than it might first appear. Showing the FedCM prompt does not require user interaction, and a compromised renderer can open popups without user interaction, so the proof-of-concept scenarios that depend on popups can be performed with minimal user interaction.
Exploitation
Step 1: start the identity provider
Run the simulated IDP server:
node server-single-account.js
This starts the simulated identity provider server used by the test pages. The report does not include the script's contents.
Step 2: scenario 1, bubble dialog
- Navigate to
https://aogarantiza.com/chromium/fedcm-opaque.php. - Log in using the FedCM dialog.
This scenario uses the bubble dialog.
Step 3: scenario 2, modal dialog
- Navigate to
https://aogarantiza.com/chromium/fedcm-opaque.php?mode=button. - Click anywhere once.
- Log in using the FedCM dialog.
This scenario uses the modal dialog and requires the origin trial described above.
Step 4: scenario 3, popup over another origin
- Navigate to
https://alesandroortiz.com/security/chromium/fedcm-opaque-open.html. - Click anywhere once.
- Log in using the FedCM dialog.
This scenario uses a popup to show the prompt.
Observed and expected result
For all three scenarios the observed behaviour is the same: the origin of the initiator is shown as ://, and the page is able to obtain credentials after a successful login. The expected behaviour is that the FedCM dialog is not shown at all.
Root cause
The dialog obtains its origin string from webid::FormatUrlForDisplay(). Neither that function nor most of its callers check for opaque origins, so an opaque origin produces the string ://, which is then displayed to the user.
The call chain is as follows. webid::FormatUrlForDisplay() is called by FederatedAuthRequestImpl::FormatOriginForDisplay(), which is in turn called by either GetTopFrameOriginForDisplay() or GetIframeOriginForDisplay().
GetTopFrameOriginForDisplay() does not check whether the origin is opaque. GetIframeOriginForDisplay() would return an error if the iframe origin were opaque, but the code is currently hardcoded to skip that logic and always return std::nullopt.
GetTopFrameOriginForDisplay() is used when showing dialogs such as ShowAccountsDialog(), and its other references show it is also used for error dialogs, loading dialogs and other states. It is passed the origin from GetEmbeddingOrigin(), which always returns the main frame's last committed origin. Nowhere along this path is the origin checked for opaqueness.
A bisect places the start of reproduction at commit [redacted], which landed in 109.0.5361.0 in October 2022. The reporter verified the repro down to 109.0.5361.0. Before that commit, the hostname (aogarantiza.com) is shown, which the reporter does not consider correct either, given that the page's origin is opaque; that behaviour probably dates from the introduction of FedCM.
Impact
An attacker who can get a FedCM prompt shown from an opaque origin gets a dialog that displays :// in place of a site identity, and the page can still obtain credentials after a successful login. Because the prompt needs no user interaction to appear, and a compromised renderer can open popups without user interaction, the popup-based variant needs only minimal user interaction. The report frames the main risk as origin spoofing, particularly in combination with other issues, and notes that a real attack would use a legitimate identity provider to obtain real credentials.
Fix
The report's proposed solution is to check for origin opaqueness at one or more points in the code path described above, and in adjacent paths. If the origin is opaque, the code should return an error, on the assumption that FedCM should be unsupported in opaque origins, as are other sensitive UIs that display origins.
The report does not describe the change that was actually made.
Variants to test
- Other FedCM dialog states. The report says
GetTopFrameOriginForDisplay()also feeds error dialogs, loading dialogs and other states. Trigger each state from an opaque origin and check whether://appears in any of them. - Iframe initiators.
GetIframeOriginForDisplay()contains an opaqueness check that is hardcoded to be skipped. Test FedCM initiated from an iframe with an opaque origin and see whether the prompt appears and what origin string it shows. - Popup initiators. Repeat scenario 3 with a popup opened from a page whose origin is opaque, and confirm whether the prompt is shown over the opener and whether credentials can be obtained.
- Both dialog types. Run each candidate against
mode: widgetandmode: button, since the two dialog types share the display logic but are rendered differently. - Adjacent origin-display UIs. The report's reasoning is that sensitive UIs displaying origins should reject opaque origins. Check other Chrome surfaces that display an initiator origin for the same
://output.
A positive result in any of these is a prompt that is displayed at all from an opaque origin, or an origin string that is empty, malformed or misleading, followed by successful credential retrieval.
What happened, in plain words
When you sign in to a website with your Google account (or another big account provider), you sometimes see a small Chrome window pop up asking whether you want to continue. That window is meant to tell you which website is asking for your login details, so you can decide whether to trust it. This feature is called FedCM, short for Federated Credential Management.
The problem described here is that, in certain situations, that little window showed the meaningless text :// instead of a website name. A user looking at :// has no idea who is asking for their credentials. The report calls this origin spoofing, because the place where a site identity should appear is filled with something that tells you nothing, and that can be combined with other tricks to mislead people.
The bug was reported against Google Chrome by Alesandro Ortiz through the Chrome VRP (the programme Google runs for people who report security bugs). It was rated medium severity, a bounty of 2000.00 USD was paid, and it was disclosed on 2024-07-23. It was tracked as CVE-2024-6999, an inappropriate implementation in FedCM.
Some background you need first
Before the details make sense, here are a few ideas explained from scratch.
What an API is. An API is a set of rules that lets one piece of software ask another piece of software to do something. Think of a restaurant menu: you do not walk into the kitchen, you pick an item from the menu and the kitchen handles the rest. In a browser, a web API is a menu of actions a website can ask the browser to perform, such as showing a login prompt.
What FedCM is. FedCM is a browser API. A website (called the relying party) can ask the browser to show a login prompt for an identity provider, which is the company that holds your account, such as Google. When the site calls the API, Chrome draws a dialog that names the origin of the page that started the request, so you can see who is asking before you approve.
What an origin is. An origin is the combination of scheme, host and port that identifies where a page came from. In everyday terms it is the address on the envelope: https://example.com is an origin. The scheme is https, the host is example.com, and the port is usually implied. Browsers use the origin to decide which pages are allowed to talk to each other.
What an opaque origin is. An opaque origin is an origin that has no usable scheme, host and port. It is like an envelope with the address torn off. Browsers create opaque origins in situations where a page should not be treated as belonging to any named site, for example a sandboxed document or a page reached in a way that strips its origin. Because there is no hostname, there is nothing sensible to display.
What a dialog is here. The FedCM prompt comes in two types: a bubble and a modal. The FedCM prompt comes in two types: a bubble and a modal. Both types share the same logic for producing the origin string that is displayed, and that shared logic is where the problem sits.
What a renderer is. Chrome splits its work between processes. The renderer is the part that draws the page and runs its code. If an attacker manages to compromise the renderer, they control what that page does, and the report notes that a compromised renderer can open popups without user interaction.
What a popup is. A popup is a new browser window opened by a page. Normally browsers require a click before allowing one, but the report says a compromised renderer can open popups without user interaction.
What an origin trial is. An origin trial is a way for a website to switch on an experimental browser feature before it is available to everyone. The reporter registered one for aogarantiza.com with third-party support so that the button mode of FedCM could be tested.
What a bisect is. A bisect is a way of finding which code change introduced a bug. You test old and new versions, narrow down the range, and repeat until you land on the single commit that first shows the problem. A commit is a saved change to the code.
Setup
The affected versions were Chrome 126.0.6478.3 Canary and 124.0.6367.208 Stable, on Windows 10 Version 22H2 (Build 19045.4170). Canary is the early test build of Chrome; Stable is the normal build most people use.
For reproduction, the report uses a simulated identity provider server, started with:
node server-single-account.js
Line by line: node runs JavaScript outside a browser, using the Node.js runtime. server-single-account.js is the name of a script file that starts a small web server pretending to be an identity provider with a single account. The script is attached to the report rather than reproduced in it, so its contents are not shown here.
The report notes that in a real scenario an attacker would use a legitimate identity provider, since the goal is to obtain real credentials. In other words, the fake server is only for testing; a real attacker would point at a real login service so that the credentials captured are genuine.
Scenario 2 needs an origin trial for FedCM button mode, which the reporter registered for aogarantiza.com with third-party support. Scenario 3 uses a separate page on alesandroortiz.com that opens a popup.
Finding it
The reporter observed that the FedCM prompt, in either the bubble or the modal form, displays :// when the initiator origin is opaque. The initiator is the page that started the request. An opaque origin, as explained above, has no hostname to show, and the display code does not handle that case.
The result is origin spoofing: the user is shown a meaningless string where a site identity should be, and the report notes this is especially relevant when combined with other issues. Think of a passport with the photo replaced by a smudge: it is not a fake identity, but it is not a real one either, and it can be used to confuse whoever is checking.
Two properties make the issue easier to reach than it might first appear. Showing the FedCM prompt does not require user interaction, and a compromised renderer can open popups without user interaction, so the proof-of-concept scenarios that depend on popups can be performed with minimal user interaction. A proof of concept (PoC) is a small demonstration that proves the bug is real.
Exploitation
Step 1: start the identity provider
Run the simulated IDP server:
node server-single-account.js
This starts the simulated identity provider server used by the test pages. An endpoint is a specific address on a server that accepts a particular kind of request, like a counter in a shop that handles one type of transaction. The report does not include the script's contents.
Step 2: scenario 1, bubble dialog
- Navigate to
https://aogarantiza.com/chromium/fedcm-opaque.php. - Log in using the FedCM dialog.
This scenario uses the bubble dialog. The mode is a setting that tells the page which style of prompt to request.
Step 3: scenario 2, modal dialog
- Navigate to
https://aogarantiza.com/chromium/fedcm-opaque.php?mode=button. - Click anywhere once.
- Log in using the FedCM dialog.
This scenario uses the modal dialog and requires the origin trial described above. The ?mode=button part of the address is a query string, a way of passing a setting in the URL itself.
Step 4: scenario 3, popup over another origin
- Navigate to
https://alesandroortiz.com/security/chromium/fedcm-opaque-open.html. - Click anywhere once.
- Log in using the FedCM dialog.
This scenario uses a popup to show the prompt.
Observed and expected result
For all three scenarios the observed behaviour is the same: the origin of the initiator is shown as ://, and the page is able to obtain credentials after a successful login. The expected behaviour is that the FedCM dialog is not shown at all. In other words, the browser should refuse to display a prompt it cannot label honestly.
Root cause
The dialog obtains its origin string from webid::FormatUrlForDisplay(). This is a function, a named block of code that does one job: turn a URL into a short string suitable for showing to a person. Neither that function nor most of its callers check for opaque origins, so an opaque origin produces the string ://, which is then displayed to the user. A caller is simply the code that asks the function to do its job.
The call chain is as follows. webid::FormatUrlForDisplay() is called by FederatedAuthRequestImpl::FormatOriginForDisplay(), which is in turn called by either GetTopFrameOriginForDisplay() or GetIframeOriginForDisplay(). A call chain is the sequence of functions that call one another, like a chain of people passing a message along.
GetTopFrameOriginForDisplay() does not check whether the origin is opaque. GetIframeOriginForDisplay() would return an error if the iframe origin were opaque, but the code is currently hardcoded to skip that logic and always return std::nullopt. An iframe is a page embedded inside another page. std::nullopt is a C++ value meaning no value at all, so the check is effectively switched off.
GetTopFrameOriginForDisplay() is used when showing dialogs such as ShowAccountsDialog(), and its other references show it is also used for error dialogs, loading dialogs and other states. It is passed the origin from GetEmbeddingOrigin(), which always returns the main frame's last committed origin. The main frame is the top-level page, and the last committed origin is the one the browser most recently accepted for it. Nowhere along this path is the origin checked for opaqueness.
A bisect places the start of reproduction at commit [redacted], which landed in 109.0.5361.0 in October 2022. The reporter verified the repro down to 109.0.5361.0. Before that commit, the hostname (aogarantiza.com) is shown, which the reporter does not consider correct either, given that the page's origin is opaque; that behaviour probably dates from the introduction of FedCM. Showing a hostname for a page that has no real origin is still misleading, just in a different way.
Impact
An attacker who can get a FedCM prompt shown from an opaque origin gets a dialog that displays :// in place of a site identity, and the page can still obtain credentials after a successful login. Because the prompt needs no user interaction to appear, and a compromised renderer can open popups without user interaction, the popup-based variant needs only minimal user interaction. The report frames the main risk as origin spoofing, particularly in combination with other issues, and notes that a real attack would use a legitimate identity provider to obtain real credentials.
Fix
The report's proposed solution is to check for origin opaqueness at one or more points in the code path described above, and in adjacent paths. If the origin is opaque, the code should return an error, on the assumption that FedCM should be unsupported in opaque origins, as are other sensitive UIs that display origins. A UI here means user interface, the parts of the browser a person sees and interacts with.
The report does not describe the change that was actually made.
Variants to test
These are other places worth checking, based on the same reasoning.
- Other FedCM dialog states. The report says
GetTopFrameOriginForDisplay()also feeds error dialogs, loading dialogs and other states. Trigger each state from an opaque origin and check whether://appears in any of them. - Iframe initiators.
GetIframeOriginForDisplay()contains an opaqueness check that is hardcoded to be skipped. Test FedCM initiated from an iframe with an opaque origin and see whether the prompt appears and what origin string it shows. - Popup initiators. Repeat scenario 3 with a popup opened from a page whose origin is opaque, and confirm whether the prompt is shown over the opener and whether credentials can be obtained. The opener is the page that opened the popup.
- Both dialog types. Run each candidate against
mode: widgetandmode: button, since the two dialog types share the display logic but are rendered differently. - Adjacent origin-display UIs. The report's reasoning is that sensitive UIs displaying origins should reject opaque origins. Check other Chrome surfaces that display an initiator origin for the same
://output.
A positive result in any of these is a prompt that is displayed at all from an opaque origin, or an origin string that is empty, malformed or misleading, followed by successful credential retrieval.
Glossary
- API: a set of rules that lets one piece of software ask another to do something, like a menu of available actions.
- Bisect: a method of finding the code change that introduced a bug by testing versions and narrowing the range until one commit is identified.
- Bubble: the smaller FedCM prompt style, attached near the browser's address area.
- Call chain: the sequence of functions that call one another while handling a request.
- Caller: the code that asks a function to do its job.
- Canary: an early test build of Chrome used before changes reach the normal release.
- Commit: a saved change to a codebase.
- CVE: a public identifier for a known security vulnerability.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- FedCM: Federated Credential Management, the browser API that shows a federated login prompt for an identity provider.
- Function: a named block of code that performs one job.
- Hostname: the name part of a web address, such as
example.com. - Identity provider (IDP): the company or service that holds your account and vouches for your identity, such as Google.
- Iframe: a page embedded inside another page.
- Initiator: the page that started a request.
- Main frame: the top-level page in a browser tab.
- Modal: a larger prompt window that blocks the page until you deal with it.
- Opaque origin: an origin with no usable scheme, host and port, so it has no hostname to display.
- Opener: the page that opened a popup.
- Origin: the combination of scheme, host and port that identifies where a page came from.
- Origin spoofing: making a user believe a request comes from a different site than it really does, or from no identifiable site at all.
- Origin trial: a way for a website to switch on an experimental browser feature before general release.
- Popup: a new browser window opened by a page.
- Proof of concept (PoC): a small demonstration that proves a bug is real.
- Query string: the part of a URL after
?used to pass settings. - Renderer: the Chrome process that draws a page and runs its code.
- Relying party: the website that asks the browser to show a federated login prompt.
- Scheme: the first part of a web address, such as
https. - Stable: the normal Chrome release build most people use.
- UI: user interface, the parts of a program a person sees and interacts with.
- VRP: Vulnerability Reward Program, a scheme that pays people for reporting security bugs.