Skip to content

🛡️ Sentinel: Harden timing-safe equality checks#65

Open
SuvenSeo wants to merge 1 commit into
masterfrom
sentinel/harden-timing-safe-checks-8811627831529881274
Open

🛡️ Sentinel: Harden timing-safe equality checks#65
SuvenSeo wants to merge 1 commit into
masterfrom
sentinel/harden-timing-safe-checks-8811627831529881274

Conversation

@SuvenSeo

@SuvenSeo SuvenSeo commented Jun 9, 2026

Copy link
Copy Markdown
Owner

🛡️ Sentinel Security Enhancement

Severity: HIGH (Defense-in-depth)

💡 Vulnerability:
Constant-time comparison functions like timingSafeEqual were 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_PASSWORD or CRON_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.

  • Hardened safeEqual in frontend/src/lib/middleware/auth.js.
  • Hardened safeEqualText in frontend/src/proxy.js (Edge-compatible).
  • Updated callers and optimized redundant hashing.
  • Added comprehensive functional tests.

✅ Verification:

  • Ran npm test in the frontend directory (36/36 tests passed).
  • Verified new security tests in frontend/tests/security-hardening.test.js pass successfully.
  • Confirmed implementation in both Node.js (auth.js) and Edge (proxy.js) contexts.

PR created automatically by Jules for task 8811627831529881274 started by @SuvenSeo

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>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
seo-os-agent Ready Ready Preview, Comment Jun 9, 2026 7:53pm

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.

1 participant