Skip to content

fix(auth): use constant-time comparison for email-verification tokens - #1303

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
anifast-123:fix/constant-time-email-verification-tokens
Aug 30, 2026
Merged

fix(auth): use constant-time comparison for email-verification tokens#1303
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
anifast-123:fix/constant-time-email-verification-tokens

Conversation

@anifast-123

Copy link
Copy Markdown
Contributor

Summary

Replaces non-constant-time equality checks () with via a new utility to prevent timing attacks on email verification token and backup code comparisons.

Changes

  • ****: Added exported utility that uses for byte-level constant-time comparison
  • ****: Replaced / hash comparisons in and with
  • ****: New test suite (10 tests) covering the utility for various edge cases
  • ****: Added 2 tests verifying wrong tokens and wrong backup codes are rejected through the constant-time path

Testing

  • All 49 auth-related tests pass ✅
  • TypeScript typecheck passes ✅
  • No regressions detected ✅

Closes #1155

Replace non-constant-time equality checks (===) with crypto.timingSafeEqual
via a new `constantTimeEqual` utility in jwt.ts to prevent timing attacks
on email verification token and backup code comparisons.

Closes rinafcode#1155

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@anifast-123
anifast-123 force-pushed the fix/constant-time-email-verification-tokens branch from fa1369a to 86a489f Compare August 30, 2026 13:33
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@anifast-123 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 2ea4a54 into rinafcode:main Aug 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use constant-time comparison for email-verification tokens

2 participants