Harden passcode hashing with PBKDF2#25
Conversation
SecretHash now uses PBKDF2-HMAC-SHA256 (120k iterations) instead of a single salted SHA-256 round, and compares in constant time. Guards the fork-local passcodes, panic code and hidden-chats exit code against offline brute force if the prefs file is extracted. Old salted-SHA-256 records (same layout across all prior versions) are detected by the pbkdf2 prefix being absent, verified against the legacy scheme, and transparently rehashed to PBKDF2 on the next correct entry — no user is locked out.
📝 WalkthroughWalkthrough
ChangesSecret hash migration
Estimated code review effort: 3 (Moderate) | ~15 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/kotlin/helpers/security/SecretHash.kt`:
- Around line 13-15: Rename the Kotlin helper object SecretHash to
SecretHashUtils and rename its source file accordingly. Update every reference
to the object so callers continue using the renamed algorithm helper without
changing its behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 20450aa8-9698-4a46-bb1f-072f431bbcd8
📒 Files selected for processing (1)
src/kotlin/helpers/security/SecretHash.kt
|
one mild issue with this: in paranoia mode, the exit code is hashed using the same SecretHelper. sha256 is ~free, but pbkdf2 is kinda not, and re-hashing input on every keystroke will inevitably cause jank. can we do something about this? |
SecretHash now uses PBKDF2-HMAC-SHA256 (120k iterations) instead of a single salted SHA-256 round, and compares in constant time. Guards the fork-local passcodes, panic code and hidden-chats exit code against offline brute force if the prefs file is extracted.
Old salted-SHA-256 records (same layout across all prior versions) are detected by the pbkdf2 prefix being absent, verified against the legacy scheme, and transparently rehashed to PBKDF2 on the next correct entry — no user is locked out.
Summary by CodeRabbit