fix: remove early length exit from timingSafeEqStr#81
Open
bmersereau wants to merge 3 commits into
Open
Conversation
Dshamir
added a commit
to Dshamir/AI-Legal
that referenced
this pull request
May 24, 2026
…email - downloadTokens: pad buffers to equal length before timingSafeEqual to eliminate length-oracle side channel (PR willchen96#81) - keyRotation: add HKDF key derivation with random 16-byte per-row salt; existing rows without salt decrypt via legacy SHA-256 path; all new encryptions use HKDF (PR willchen96#76) - projects: use case-insensitive comparison for shared_with email in GET /projects/:projectId, matching access.ts pattern (PR willchen96#79) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dshamir
added a commit
to Dshamir/AI-Legal
that referenced
this pull request
May 24, 2026
…tegration - CHANGELOG: add security hardening and feature entries for PRs willchen96#158, willchen96#81, willchen96#76, willchen96#79, willchen96#145, willchen96#112, willchen96#111, willchen96#110, willchen96#155, willchen96#157, willchen96#59 - ROADMAP: mark 12 new items as completed - CLAUDE.md: add sanitize.ts, streamTimeout.ts, credits.ts to lib index, update test count to 40 - README: update API endpoints table (chat pagination, workflow export), security row (HKDF, RLS, prompt defense), encryption row Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
timingSafeEqStrreturnedfalseimmediately when string lengths differed, before callingcrypto.timingSafeEqual— violating the constant-time contract and creating a theoretical timing oracleCloses #72
Changes
backend/src/lib/downloadTokens.ts— early length check removed;timingSafeEqStrnow pads the shorter buffer and runstimingSafeEqualunconditionally before length verification; exported for testabilitybackend/src/lib/__tests__/timingSafeEq.test.ts— 5 unit testsTest plan