[PM-32401] fix: Prevent TOTP autofill for non-premium accounts#2467
[PM-32401] fix: Prevent TOTP autofill for non-premium accounts#2467matt-livefront merged 3 commits intomainfrom
Conversation
|
Claude finished @matt-livefront's task in 1m 35s —— View job Code Review: PM-32401 Prevent TOTP autofill for non-premium accounts
SummaryOverall Assessment: ✅ APPROVE This PR adds defense-in-depth authorization checks to prevent TOTP autofill for non-premium accounts that lack organizational TOTP access. Changes span three layers: a new centralized No findings. The authorization logic is consistent across both the identity registration and credential provision layers, premium status is fetched once per batch operation to avoid redundant calls, and the test updates correctly adopt the |
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2467 +/- ##
==========================================
- Coverage 86.88% 86.86% -0.02%
==========================================
Files 1841 1846 +5
Lines 162382 163149 +767
==========================================
+ Hits 141078 141725 +647
- Misses 21304 21424 +120 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @available(iOS 18.0, *) | ||
| func test_provideOTPCredential_totpAuthorized() async throws { |
There was a problem hiding this comment.
🎨 On XCTest the @available is not respected for the test runs (it does on new Swift Testing Framework), so if one runs this on iOS 17 simulator it will try to run the test and it will fail. I'd add a guard at the beginning as with other similar tests like in ASPasskeyCredentialRequestExtensionsTests.
| @available(iOS 18.0, *) | |
| func test_provideOTPCredential_totpAuthorized() async throws { | |
| func test_provideOTPCredential_totpAuthorized() async throws { | |
| guard #available(iOS 18.0, *) else { | |
| throw XCTSkip("Skipped on iOS < 18.0") | |
| } |
Same applies to other tests here.
There was a problem hiding this comment.
Good catch, updated!
| func isTotpAuthorized(for cipher: CipherView) async -> Bool { | ||
| let accountHasPremium = await stateService.doesActiveAccountHavePremium() | ||
| return cipher.organizationUseTotp || accountHasPremium | ||
| } |
There was a problem hiding this comment.
♻️ Perhaps we could create a tech debt task to update other places where this logic is used like DefaultVaultRepository or DefaultVaultListPreparedDataBuilder. What do you think?
There was a problem hiding this comment.
Yep, great idea, I added a ticket: https://bitwarden.atlassian.net/browse/PM-34016.

🎟️ Tracking
PM-32401
📔 Objective
This fixes an issue where non-premium accounts were able to use TOTP autofill.
ASOneTimeCodeCredentialIdentityfor the credential identity store if authorized.