🛡️ Sentinel: Harden timing-safe equality checks#65
Conversation
This change prevents length-based side-channel attacks by hashing both inputs with SHA-256 before performing constant-time comparisons. This ensures that the comparison logic always operates on inputs of identical length, regardless of the original secret's length. - Updated `safeEqual` in `auth.js` to hash inputs with `node:crypto`. - Updated `safeEqualText` in `proxy.js` to be async and hash inputs using `crypto.subtle`. - Optimized `proxy.js` to avoid redundant hashing of the dashboard secret. - Added functional security tests in `frontend/tests/security-hardening.test.js`. - Updated Sentinel's journal with critical security learnings. Co-authored-by: SuvenSeo <263689617+SuvenSeo@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🛡️ Sentinel Security Enhancement
Severity: HIGH (Defense-in-depth)
💡 Vulnerability:
Constant-time comparison functions like
timingSafeEqualwere used directly on sensitive secrets. While "timing-safe", these functions require inputs to be of equal length. If an attacker provides an input of a different length, the function either returns early or throws an error, potentially revealing the secret's length through timing or response differences.🎯 Impact:
An attacker could brute-force the length of sensitive secrets (like
DASHBOARD_PASSWORDorCRON_SECRET) by observing response times or error states, significantly reducing the search space for a full brute-force attack.🔧 Fix:
Implemented the "Hash-then-Compare" pattern. Both the secret and the user-provided input are now hashed with SHA-256 before constant-time comparison. This ensures the comparison always operates on fixed-length buffers.
safeEqualinfrontend/src/lib/middleware/auth.js.safeEqualTextinfrontend/src/proxy.js(Edge-compatible).✅ Verification:
npm testin thefrontenddirectory (36/36 tests passed).frontend/tests/security-hardening.test.jspass successfully.PR created automatically by Jules for task 8811627831529881274 started by @SuvenSeo