Skip to content

🔒 security: Add Bytes.equalsConstantTime() for timing-safe comparison#266

Merged
roninjin10 merged 1 commit intomainfrom
fix/issue-109-bytes-isequal
Jan 4, 2026
Merged

🔒 security: Add Bytes.equalsConstantTime() for timing-safe comparison#266
roninjin10 merged 1 commit intomainfrom
fix/issue-109-bytes-isequal

Conversation

@roninjin10
Copy link
Contributor

Summary

Test plan

  • Equal arrays return true
  • Different arrays return false
  • No early exit behavior
  • 14 tests pass

🤖 Generated with Claude Code

Addresses issue #109: Bytes.isEqual timing leak for different lengths.

- Add equalsConstantTime() that uses XOR accumulation without early exit
- Add warning to equals() JSDoc about timing attack vulnerability
- Keep equals() for performance in non-security contexts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
dist Error Error Jan 4, 2026 8:36am
voltaire Error Error Jan 4, 2026 8:36am

Copy link
Contributor Author

@roninjin10 roninjin10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review summary for PR #266 — 🔒 security: Add Bytes.equalsConstantTime() for timing-safe comparison\n\nTouched areas: Bytes | Files changed: 4 (+154/-0)\n\n- Tests: yes\n- Types & API: yes\n- Docs: ensure behavior is documented where user-facing.\n- Performance: consider micro-allocations in tight loops.\n\nFocus points:\n - Enforce unique per-key nonces; document catastrophic reuse impact.\n\nOutcome: Comment-only review; no blocking issues spotted. Please consider the above suggestions.\n

@roninjin10 roninjin10 merged commit a779d6f into main Jan 4, 2026
20 of 49 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.

Bug: Bytes.isEqual timing leak for different lengths

1 participant