fix(fips): replace md5 with sha256 for 2fa fingerprint#39262
fix(fips): replace md5 with sha256 for 2fa fingerprint#39262
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
WalkthroughThe change makes fingerprint hashing conditional: when Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/jira FIPS-4 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #39262 +/- ##
===========================================
- Coverage 70.92% 70.86% -0.07%
===========================================
Files 3207 3207
Lines 113353 113353
Branches 20554 20529 -25
===========================================
- Hits 80399 80327 -72
- Misses 30908 30978 +70
- Partials 2046 2048 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/meteor/app/2fa/server/code/index.ts (1)
57-64:⚠️ Potential issue | 🟠 MajorPlan an explicit migration/invalidation path for legacy remembered-device hashes
Changing the fingerprint algorithm at Line 63 invalidates previously stored
twoFactorAuthorizedHashvalues, so the check at Line 114 will reject existing remembered sessions after rollout. Please make this transition explicit (one-off cleanup/migration or versioned hash format + rollout note) to avoid a silent UX break.Suggested future-proofing for hash format versioning
function getFingerprintFromConnection(connection: IMethodConnection): string { const data = JSON.stringify({ userAgent: connection.httpHeaders['user-agent'], clientAddress: connection.clientAddress, }); - return crypto.createHash('sha256').update(data).digest('hex'); + return `sha256:${crypto.createHash('sha256').update(data).digest('hex')}`; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/app/2fa/server/code/index.ts` around lines 57 - 64, The new fingerprint algorithm in getFingerprintFromConnection will invalidate existing twoFactorAuthorizedHash values; update the code to support a migration path by implementing a versioned hash format or fallback validation: when verifying a remembered device (the check that compares twoFactorAuthorizedHash), detect the hash version (e.g., prefix like "v1:" vs "v2:"), accept legacy hashes by computing the old algorithm for v1 entries, then on successful legacy validation re-hash with the new algorithm and store the upgraded "v2:" value (or enqueue a one-off migration job to rewrite existing records). Ensure getFingerprintFromConnection is the canonical v2 generator, add a legacy generator function for the previous algorithm, and update the verification logic to handle both versions and persist the upgraded hash.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/meteor/app/2fa/server/code/index.ts`:
- Around line 57-64: The new fingerprint algorithm in
getFingerprintFromConnection will invalidate existing twoFactorAuthorizedHash
values; update the code to support a migration path by implementing a versioned
hash format or fallback validation: when verifying a remembered device (the
check that compares twoFactorAuthorizedHash), detect the hash version (e.g.,
prefix like "v1:" vs "v2:"), accept legacy hashes by computing the old algorithm
for v1 entries, then on successful legacy validation re-hash with the new
algorithm and store the upgraded "v2:" value (or enqueue a one-off migration job
to rewrite existing records). Ensure getFingerprintFromConnection is the
canonical v2 generator, add a legacy generator function for the previous
algorithm, and update the verification logic to handle both versions and persist
the upgraded hash.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aaffdb49-a5a0-4ecb-ba86-551c9253fd2f
📒 Files selected for processing (1)
apps/meteor/app/2fa/server/code/index.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/2fa/server/code/index.ts
🧠 Learnings (4)
📚 Learning: 2025-10-07T15:08:37.419Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36942
File: apps/meteor/client/lib/e2ee/pbkdf2.ts:13-45
Timestamp: 2025-10-07T15:08:37.419Z
Learning: In apps/meteor/client/lib/e2ee/pbkdf2.ts, PBKDF2 iteration count validation is not enforced because the iterations parameter is outside the user's control and is system-managed.
Applied to files:
apps/meteor/app/2fa/server/code/index.ts
📚 Learning: 2025-10-07T15:08:37.419Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36942
File: apps/meteor/client/lib/e2ee/pbkdf2.ts:13-45
Timestamp: 2025-10-07T15:08:37.419Z
Learning: In apps/meteor/client/lib/e2ee/pbkdf2.ts, the team has decided to use Latin-1 encoding (via Binary.toArrayBuffer and Binary.toString) for password encoding and decrypt output instead of UTF-8 encoding. This is a deliberate choice for E2EE password/key material handling.
Applied to files:
apps/meteor/app/2fa/server/code/index.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/app/2fa/server/code/index.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/app/2fa/server/code/index.ts
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Task: FIPS-9
Summary by CodeRabbit