Security: Hash backup codes instead of storing in plain text #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Security Issue: Plain Text Backup Code Storage
Current Implementation
Backup codes are currently stored as plain JSON in the
backup_codescolumn in the database:The Problem
Industry Best Practice
Backup codes should be hashed (like passwords) and only shown once during generation:
Services that hash backup codes:
Recommended Approach:
Trade-offs
Current approach (plain text):
Hashed approach:
Note: Most services consider this trade-off acceptable - backup codes are shown once with strong warnings to save them securely.
Proposed Changes
User#verify_backup_codeto hash and compare codesReferences
Priority
Medium - This is a security improvement but requires database access to exploit. Should be addressed before production deployment or when handling sensitive data.
Related to: #1 (Development Progress Tracker)
complete