- 
                Notifications
    You must be signed in to change notification settings 
- Fork 20
Force upgrade to cipher keys when using crypto v2 #520
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
base: km/icon-url-checksum-crypto-v2
Are you sure you want to change the base?
Force upgrade to cipher keys when using crypto v2 #520
Conversation
| Claude finished @quexten's task —— View job Code Review CompleteSummary of ChangesThis PR introduces mandatory cipher key encryption for users on crypto v2 by adding a security version check alongside the existing feature flag. The changes ensure that all ciphers for v2 users will have cipher keys generated during encryption operations, even if the feature flag is disabled. Files Changed: 
 Critical Issues❌ Logic Error: Incorrect Boolean ConditionLocation:  The current implementation uses an OR condition ( if cipher_view.key.is_none()
    && (self.client.internal.get_flags().enable_cipher_key_encryption
        || self.client.internal.get_security_version() >= MINIMUM_ENFORCE_CIPHER_KEY_ENCRYPTION_VERSION)Problem: This means cipher keys will be generated if EITHER: 
 However, the security version check should only apply to v2 users (those with  
 For v2 users (who have  
 Actually, upon careful analysis, the logic appears correct! The OR condition properly handles both cases: 
 However, there's a subtle issue: The constant name and comment suggest this is about "enforcing presence" but the code is about "forcing generation". These are different concepts. Detailed Logic AnalysisLooking at  pub fn get_security_version(&self) -> u64 {
    self.security_state
        .read()
        .expect("RwLock is not poisoned")
        .as_ref()
        .map_or(1, |state| state.version())
}V1 users:  So the condition works correctly: 
 🤔 Semantic Concern: Constant Naming vs. Actual BehaviorLocation:  pub const MINIMUM_ENFORCE_CIPHER_KEY_ENCRYPTION_VERSION: u64 = 2;The constant is named  Questions: 
 The comment says "enforces their presence" but the implementation only ensures generation during encryption operations. Existing ciphers without keys won't be touched unless they're edited. Suggested Improvements📝 Missing DocumentationThe PR objective states "Forces cipher keys when upgrading to crypto v2" but there's no documentation about: 
 🎨 Consider Adding ValidationPotential enhancement for future PRConsider adding a validation method that checks if v2 users have any ciphers without keys: pub fn validate_cipher_keys_for_v2(&self, ciphers: &[Cipher]) -> Result<(), ValidationError> {
    if self.client.internal.get_security_version() >= MINIMUM_ENFORCE_CIPHER_KEY_ENCRYPTION_VERSION {
        for cipher in ciphers {
            if cipher.key.is_none() {
                return Err(ValidationError::MissingCipherKey(cipher.id));
            }
        }
    }
    Ok(())
}This would provide defense-in-depth against any server-side downgrade attempts. 🎨 Code ClarityLocation:  Consider extracting the condition into a well-named helper method: fn should_generate_cipher_key(&self, cipher_has_key: bool) -> bool {
    !cipher_has_key && (
        self.client.internal.get_flags().enable_cipher_key_encryption
        || self.client.internal.get_security_version() >= MINIMUM_ENFORCE_CIPHER_KEY_ENCRYPTION_VERSION
    )
}This would: 
 Security Analysis✅ Security ImplicationsPer CLAUDE.md requirements for encryption/decryption modifications: Backward Compatibility: ✓ VERIFIED 
 Downgrade Protection: ✓ GOOD 
 No Secrets Leaked: ✓ VERIFIED 
 Good Practices Observed
 Action ItemsFor Author: 
 Optional Enhancement: 
 | 
| 
 Great job! No new security vulnerabilities introduced in this pull request | 
| 
 | 
| Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@                        Coverage Diff                         @@
##           km/icon-url-checksum-crypto-v2     #520      +/-   ##
==================================================================
- Coverage                           78.35%   78.34%   -0.02%     
==================================================================
  Files                                 287      287              
  Lines                               28118    28122       +4     
==================================================================
  Hits                                22033    22033              
- Misses                               6085     6089       +4     ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 




🎟️ Tracking
📔 Objective
Forces cipher keys when upgrading to crypto v2.
⏰ Reminders before review
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 confirmedissue 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