fix(dashboard): return timingSafeEqual result instead of discarding it

The unequal-length branch of timingSafeCompare called
crypto.timingSafeEqual(paddedA, paddedB) but did not capture the return
value, unconditionally returning false and leaving the timing-safe
comparison as dead code.

Adds a regression test covering shorter, longer, and exact-match
credential lengths to lock in the correct behaviour.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Sonnet 4.6 committed 2026-02-20 11:53:05 -05:00
1 parent a5f08ff082
commit a8ee3d39ea
2 files changed
+43 -2

No files matched your search

+1 -2
View File
@@ -26,8 +26,7 @@ function timingSafeCompare(a, b) {
const paddedB = Buffer.alloc(maxLen);
bufA.copy(paddedA);
bufB.copy(paddedB);
crypto.timingSafeEqual(paddedA, paddedB);
return false;
return crypto.timingSafeEqual(paddedA, paddedB);
}
return crypto.timingSafeEqual(bufA, bufB);
}