Skip to content

Conversation

abergs
Copy link
Member

@abergs abergs commented Sep 11, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-13632

📔 Objective

This PR contains enablement work for the browser extension work, tracked by https://bitwarden.atlassian.net/browse/PM-13632.

It enables us to configure multiple allowed origins, so that we can list our domain (https://bitwarden.com etc) as well as our browser extension (chrome-extension://aabbbccc).

It loads additional Origins from the configuraiton to allow us to update it dynamically or use different values in different environments.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@abergs abergs requested review from withinfocus and removed request for withinfocus September 11, 2025 19:06
@abergs abergs force-pushed the anders/configurable-fido2-origins branch from 011e779 to e15cda9 Compare September 11, 2025 19:12
@abergs abergs force-pushed the anders/configurable-fido2-origins branch from e15cda9 to baa3d0a Compare September 11, 2025 19:19
Copy link
Contributor

github-actions bot commented Sep 11, 2025

Logo
Checkmarx One – Scan Summary & Details9bdd9a16-4ac6-4dab-86ae-43f61702f5b6

New Issues (3)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 259
detailsMethod at line 259 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
ID: KebdugJ0qblKwPtrc9%2FRDCaLpCU%3D
Attack Vector
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1506
detailsMethod at line 1506 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
ID: uaZJpiJ78LRBNDwwZkUWmcWIWQg%3D
Attack Vector
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1387
detailsMethod at line 1387 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
ID: 1xLfiRwN9lkroucCvbONJ53Q3OQ%3D
Attack Vector
Fixed Issues (3)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 262
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 299
MEDIUM Use_Of_Hardcoded_Password /src/Identity/IdentityServer/RequestValidators/SendAccess/SendAccessConstants.cs: 115

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.15%. Comparing base (6c512f1) to head (465868b).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
...SharedWeb/Utilities/ServiceCollectionExtensions.cs 76.47% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6317      +/-   ##
==========================================
+ Coverage   50.00%   50.15%   +0.14%     
==========================================
  Files        1831     1840       +9     
  Lines       81457    81670     +213     
  Branches     7217     7232      +15     
==========================================
+ Hits        40735    40960     +225     
+ Misses      39157    39137      -20     
- Partials     1565     1573       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@withinfocus withinfocus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need SRE tasks to get this configured everywhere.

Copy link
Contributor

@withinfocus withinfocus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine with me, but Auth to provide formal review.


public class Fido2Settings
{
public HashSet<string> Origins { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I am assuming the configuration readers in .NET can work with this type but an array or list of strings is more typical.

Copy link
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@abergs
Copy link
Member Author

abergs commented Sep 19, 2025

We don't need a separata QA test for this, right? I'm good to merge as is? No behaviour should change unless we start adding configuration.

@JaredSnider-Bitwarden
Copy link
Contributor

We don't need a separata QA test for this, right? I'm good to merge as is? No behaviour should change unless we start adding configuration.

Since it is not feature flagged, I would recommend a QA smoke test per our standard practices.

}
else
{
options.Origins = new HashSet<string> { globalSettings.BaseServiceUri.Vault };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add hardcoded extension ids and such

Copy link
Member

@trmartin4 trmartin4 Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer to have those hard-coded at compile-time or inserted via environment variables at runtime? I assume that by hardcoding you mean to put them into Constants.cs so that we don't have to ask self-hosted customers to configure their extensions as well? We do have a precedent for hard-coding those on clients but no need up to this point on server.

Is there any need to provide an avenue for override/extension by third-party extension developers to add to the list for a self-hosted scenario? If these extension IDs were compile-time constants, and we have the Vault URL, then we could eliminate the need to expose the ability to configure the Origins via environment variables (other than the Vault URI).

Copy link
Member

@kspearrin kspearrin Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to eliminate the need for customers to have to configure this on their end. Client IDs/origins don't really change, and if they need to break away from them for some reason (custom client, QA environment, etc), they could override it with their own ENV variable global setting that is exposed.

Copy link
Member Author

@abergs abergs Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added chromium constants in 26e8cf4.

I also included the development extension so that "Login with passkey" would work for local dev / testing out of the box too.

I verified that I was able to use the feature successfully without any custom config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abergs I was thinking that we would provide defaults/overrides at the extension ID level, rather than wholesale "override all values or use the defaults" as done here.

Perhaps the globalSettings could be extended with an ExtensionIdentifierSettings class, like we do for web push, with default values set to the production extension IDs. That way if you want to override the Chrome extension to use the Developer version, you could make just that change in your appSettings.Development.json and not have to also override all the other values. It also means that we could avoid having to list the developer extension along with the others.

Part of this ties in with @JaredSnider-Bitwarden's question here, as I'm not 100% sure what the use-case is for the override and so not absolutely sure how the override API could be designed to fit the anticipated case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we believe that the hard-coding of the development extension is not valid. From what QA has told us, when you side-load an extension you get a different, random ID for each time you do so. So hard-coding that value is just capturing what that random GUID is for you and will not work for others.

@abergs abergs requested review from withinfocus, trmartin4 and JaredSnider-Bitwarden and removed request for justindbaur September 24, 2025 08:55

if (globalSettings.Fido2?.Origins?.Any() == true)
{
options.Origins = new HashSet<string>(globalSettings.Fido2.Origins);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ : What real world scenario do we expect any values to be set in globalSettings.Fido2.Origins? With the recent change to hardcode extension ids down below... I'm not seeing when this would be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JaredSnider-Bitwarden Any browser extension that is not already hard coded ("beta", new browser etc) or custom domain / extension-id in a selfhost/enterprise deployment.

As well as the ability to remove the support for some extension, for whatever reason that may be.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants