Closed Bug 1956484 Opened 1 year ago Closed 7 months ago

Allow web extensions to assert WebAuthn relying party identifiers of a web domain they have host permissions for

Categories

(Core :: DOM: Web Authentication, enhancement, P2)

Firefox 136
enhancement

Tracking

()

RESOLVED FIXED
150 Branch
Tracking Status
firefox150 --- fixed

People

(Reporter: rew.islam, Assigned: jschanck)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [wecg])

Attachments

(1 file, 1 external file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Steps to reproduce:

To experience this, first create a browser extension for Firefox that allows the user to register a WebAuthn credential, and also authenticate with it from within the extension popover.

The objective is for the WebAuthn credential to have a specific RPID, rather than the browser extension ID as the RPID.

For example, if example.com develops a browser extension for their service, provided on their website and mobile apps, the browser extension should be able to use any WebAuthn credential that is registered on the example.com website and/or the mobile apps. The mobile apps can be tied to example.com using a associated domain and/or asset links. However there isn't a way to tie the companies browser extension to its domain.

Chrome solves this as is explained here:
https://chromiumdash.appspot.com/commit/cfea6b18ede2a8fe0d7ea32e6bba967a7f2de6f8

The attached extension demonstrates this issue. Knowledge of WebAuthn is required in order to create the correct options dictionary to pass into the registration and authentication functions.

Actual results:

In Firefox, if the extension attempts to set the RPID in the options passed into navigator.credentials.create, an error occurs:

"SecurityError: The operation is insecure."

Expected results:

Ideally Firefox has a way for a browser extension developer to create and use WebAuthn credentials from the extension with the RPID of the developer, just as is possible with mobile apps. Either the same implementation as Chrome is allowed or any alternative where a browser extension developer can associate their extension with their domain, allowing WebAuthn from within their extension to use the associated domain of their browser extension as the RPID.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Web Authentication' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Web Authentication
Product: Firefox → Core

Bitwarden is adding WebAuthn login to their browser extension, but it can't work in Firefox without this. I would really appreciate not needing to type my master password into the Bitwarden extension and just tapping my Yubikey.

https://github.com/bitwarden/clients/pull/16385

Assignee: nobody → jschanck
Severity: -- → N/A
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P2
Whiteboard: [wecg]

Hi Mozilla team, can you please push forward with this functionality? Keeper is on hold with our passkey login feature for Firefox users until this is resolved, as are other password managers.

We are targeting Firefox 150 for this functionality.

Pushed by jschanck@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a8b511c2be77 https://hg.mozilla.org/integration/autoland/rev/829e2d57145e allow web extensions to claim WebAuthn RP IDs based on host permissions. r=keeler,robwu
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Blocks: 2024980

dev-doc-needed + needinfo to Richard, our tech writer (for Add-ons documentation). We need some documentation for this.

This change allows extension to assert a WebAuthn Relying Party ID (RP ID) for domains where they have scripting access (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#permissions).

For more context and a summary of the relevant concepts, see https://phabricator.services.mozilla.com/D269076#inline-1566432

This change affects properties documented here:

Ordinarily, the RP IDs mentioned above can only be passed to these APIs from web pages with the same domain (or subdomains thereof). When other domains are passed, the API calls are rejected. The change in this bug now allows extension documents to call these APIs and specify a domain for which they have access through the extension's host permissions.

When the Web Authn API is used to create a credential, it is already standard practice for the relying party server to validate various parts of the credential, including the origin: "Ensuring that the origin was the origin expected.".

  • On the web, typical values are the domain (e.g. example.com or www.example.com).
  • With credentials created by extensions, the origin is different:
    • In Chrome, the origin looks like chrome-extension://id where id is 32 characters (a-p) denoting the Chrome extension ID. This is the base of the URL of extension documents, e.g. also seen as location.origin in an extension document.
    • In Firefox, the origin looks like moz-extension://hash, where hash is 64 characters (described below). This is NOT the same as location.origin.

Firefox currently does not have a predictable origin or base URL that external servers can rely on.
In order to allow web servers (relying party server) to validate requests from the extension, we introduced a new moz-extension:// URL for extensions, which is the sha256 hash of the extension ID, with 0-9a-f represented as a-p (i.e. the byte value of the lowercase characters increased by 97). This new URL is stable and the same for all users, unlike the current moz-extension://uuid shaped URLs.

Here is a cross-browser way to see the origin for a credential (publicKeyCredential is from https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/create#creating_a_public_key_credential)

let clientData = JSON.parse(new TextDecoder().decode(publicKeyCredential.response.clientDataJSON));
console.log(clientData.origin);
// Example in Chrome : chrome-extension://mabekielmoibbmlepeohhncklpnjmcpk
// Example in Firefox: moz-extension://ngpncaopklanhjklijieoihgbhbgknjjdklmlpagjoaobbpmknfgmhgghbadgoai
Flags: needinfo?(rbloor)
Keywords: dev-doc-needed

Next on my list.

QA Whiteboard: [qa-triage-done-c151/b150]
Flags: needinfo?(rbloor)
See Also: → 2026687

Documentation provided in ## Bug-1956484 WebAuthn support in web extensions #43653. The example is pending approval in Example to illustrate the use of the Web Authentication API #629, and a new PR will be created to cross-reference from the documentation when merged.

See Also: → 1693562
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: