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)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox150 | --- | fixed |
People
(Reporter: rew.islam, Assigned: jschanck)
References
Details
(Keywords: dev-doc-complete, Whiteboard: [wecg])
Attachments
(1 file, 1 external file)
|
4.26 KB,
application/zip
|
Details |
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.
Comment 2•1 year ago
|
||
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.
| Comment hidden (metoo) |
| Comment hidden (metoo) |
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.
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 6•1 year ago
|
||
Updated•1 year ago
|
Comment 7•8 months ago
|
||
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.
Comment 10•7 months ago
|
||
| bugherder | ||
Comment 11•7 months ago
|
||
dev-doc-needed + needinfo to Richard, our tech writer (for Add-ons documentation). We need some documentation for this.
- Release note for Firefox 150: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/150#changes_for_add-on_developers
- add bullet point to
host_permissionexplanation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/host_permissions#format:~:text=The%20extra%20privileges%20include - add bullet point to
permissionsexplanation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#format:~:text=The%20extra%20privileges%20include - This functionality is supported in Firefox 150+ (this bug) and Chrome 122+ (https://lists.w3.org/Archives/Public/public-webauthn/2023Dec/0078.html).
- Need new article titled
Web Authn API in WebExtensionsdocumenting the usage, characteristics and requirements, and refer to this article from various documentation pages on MDN (also mentioned below).- (maybe including an example for https://github.com/mdn/webextensions-examples, the first post of this report includes a full example).
- The Extension workshop should also add an entry linking to that new article under the list of APIs that require an extension ID: https://extensionworkshop.com/documentation/develop/extensions-and-the-add-on-id/#:~:text=You%20need%20to%20set%20an%20ID
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:
rpIdfield in thepublicKeyobject property ofnavigator.credentials.get- https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialRequestOptions#rpididfield in therpobject of thepublicKeyobject property ofnavigator.credentials.create- https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp
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.comorwww.example.com). - With credentials created by extensions, the origin is different:
- In Chrome, the origin looks like
chrome-extension://idwhereidis 32 characters (a-p) denoting the Chrome extension ID. This is the base of the URL of extension documents, e.g. also seen aslocation.originin an extension document. - In Firefox, the origin looks like
moz-extension://hash, wherehashis 64 characters (described below). This is NOT the same aslocation.origin.
- In Chrome, the origin looks like
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
Comment 12•7 months ago
•
|
||
Next on my list.
Updated•7 months ago
|
Comment 13•6 months ago
|
||
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.
Description
•