Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-9826] Remove validation from 2fa GET and mask sensitive data #4526

Merged
merged 10 commits into from
Jul 22, 2024

Conversation

jlf0dev
Copy link
Member

@jlf0dev jlf0dev commented Jul 17, 2024

🎟️ Tracking

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

📔 Objective

Since we can't re-use TOTPs anymore, updating 2fa on accounts without a MP is currently broken. This is because we're validating the TOTP multiple times in the process (once on the GET, and once on the POST).

This removes the validation from 2fa getters, since this information mostly isn't sensitive. For the information that IS sensitive (Duo Client Secret), it masks the value before returning to user.

The TOTP is then only validated when updating the 2fa information.

Note: I also removed the validation from /get-webauthn-challenge and /send-email endpoints since they would invalidate the TOTP too early.

📸 Screenshots

See Jira for video

⏰ 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

Copy link
Contributor

github-actions bot commented Jul 17, 2024

Logo
Checkmarx One – Scan Summary & Detailsf5cb0377-c044-4db4-9a70-1519bc49c3e1

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/TwoFactorController.cs: 444 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/WebAuthnController.cs: 178 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 828 Attack Vector
MEDIUM Privacy_Violation /src/Api/Vault/Controllers/CiphersController.cs: 961 Attack Vector
MEDIUM Privacy_Violation /src/Api/Controllers/DevicesController.cs: 129 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 411 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 548 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 846 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 260 Attack Vector
MEDIUM Privacy_Violation /src/Api/Controllers/DevicesController.cs: 155 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 376 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 429 Attack Vector
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 63 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 140 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 132 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 215 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 125 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 85 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 153 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 68 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 820 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 838 Attack Vector
LOW Log_Forging /src/Api/Vault/Controllers/CiphersController.cs: 953 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 245 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 540 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 350 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 297 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 289 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 280 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 263 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 254 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 403 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 402 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 94 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 104 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 122 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 131 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 148 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 157 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 188 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 206 Attack Vector
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 120 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 380 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/TwoFactorController.cs: 369 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 240 Attack Vector
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 146 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 341 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 404 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 130
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 117
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 123
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 138
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 213
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 61
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 130

@jlf0dev jlf0dev marked this pull request as ready for review July 17, 2024 19:30
@jlf0dev jlf0dev requested a review from a team as a code owner July 17, 2024 19:30
@jlf0dev jlf0dev requested a review from quexten July 17, 2024 19:30
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 39.13043% with 14 lines in your changes missing coverage. Please review.

Project coverage is 41.58%. Comparing base (88d5a97) to head (aabbfce).
Report is 8 commits behind head on main.

Files Patch % Lines
src/Api/Auth/Controllers/TwoFactorController.cs 0.00% 9 Missing ⚠️
src/Core/Services/Implementations/UserService.cs 0.00% 3 Missing and 1 partial ⚠️
...ls/Response/TwoFactor/TwoFactorDuoResponseModel.cs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4526      +/-   ##
==========================================
+ Coverage   41.57%   41.58%   +0.01%     
==========================================
  Files        1268     1268              
  Lines       60091    60110      +19     
  Branches     5509     5514       +5     
==========================================
+ Hits        24981    24999      +18     
+ Misses      33950    33948       -2     
- Partials     1160     1163       +3     

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

ike-kottlowski
ike-kottlowski previously approved these changes Jul 19, 2024
Copy link
Contributor

@ike-kottlowski ike-kottlowski left a comment

Choose a reason for hiding this comment

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

I modified the bypass to check closer to the verification in the UserService to only affect users using the email OTP. This keeps the experience the same for master password users.

@trmartin4
Copy link
Member

I defaulted the VerifySecretAsync() additional parameter to false so that we kept existing logic everywhere except the new calls from the TwoFactorController. This was identified with a failing test on VerifySecretAsync_Works

Copy link
Contributor

@quexten quexten left a comment

Choose a reason for hiding this comment

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

Nice work!

src/Core/Services/IUserService.cs Outdated Show resolved Hide resolved
@jlf0dev jlf0dev merged commit 091c03a into main Jul 22, 2024
49 checks passed
@jlf0dev jlf0dev deleted the auth/pm-9826/2fa-get-remove-validation branch July 22, 2024 15:21
jlf0dev added a commit that referenced this pull request Jul 22, 2024
* remove validation from 2fa GET and mask sensitive data

* skip verification check on put email

* disable verification on send-email and reenable on put email

* validate authenticator on set instead of get

* Revert "validate authenticator on set instead of get"

This reverts commit 7bf2084.

* fix tests

* fix more tests

* Narrow scope of verify bypass

* Defaulted to false on VerifySecretAsync

* fix default param value

---------

Co-authored-by: Ike Kottlowski <ikottlowski@bitwarden.com>
Co-authored-by: Todd Martin <tmartin@bitwarden.com>
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.

None yet

4 participants