Skip to content

πŸ›‘οΈ Sentinel: Hardened timing-safe comparison and added Telegram secret filtering#58

Open
SuvenSeo wants to merge 1 commit into
masterfrom
sentinel-security-hardening-17546227515962454379
Open

πŸ›‘οΈ Sentinel: Hardened timing-safe comparison and added Telegram secret filtering#58
SuvenSeo wants to merge 1 commit into
masterfrom
sentinel-security-hardening-17546227515962454379

Conversation

@SuvenSeo

@SuvenSeo SuvenSeo commented Jun 5, 2026

Copy link
Copy Markdown
Owner

πŸ›‘οΈ Sentinel: Security Hardening & Secret Filtering

🚨 Severity: HIGH (Timing Attack Mitigation) / MEDIUM (Secret Filtering)

πŸ’‘ Vulnerability

  1. Timing Attack: The safeEqual and safeEqualText utilities were susceptible to length-based timing attacks because they performed an early return if input lengths differed.
  2. Secret Leakage: Telegram messages were not being filtered for sensitive content (API keys, passwords) before being persisted and processed by LLMs.

🎯 Impact

  1. Timing Attack: An attacker could potentially brute-force the length of a secret token by measuring response times, significantly reducing the search space for a full brute-force attack.
  2. Secret Leakage: Sensitive credentials could be logged to the database or exposed to the AI model, increasing the risk of accidental exposure or misuse.

πŸ”§ Fix

  1. Hardened Equality Checks: Updated safeEqual (Node.js) and safeEqualText (Edge/SubtleCrypto) to hash both inputs with SHA-256 before constant-time comparison. This ensures fixed-length buffers (32 bytes) are always compared, eliminating length side-channels.
  2. Proactive Filtering: Integrated hasSensitiveContent into the Telegram message handler to intercept and refuse processing of messages that look like secrets.

βœ… Verification

  • Ran npm test in the frontend directory: All 34 tests passed, including authentication and webhook verification.
  • Verified code changes for correctness and potential side effects.
  • Updated .jules/sentinel.md with documented vulnerabilities and preventions.

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

…t filtering

- Hardened `safeEqual` and `safeEqualText` against length-based timing attacks by hashing inputs with SHA-256 before comparison.
- Added proactive secret leakage protection to the Telegram `handleMessage` to reject messages containing potential credentials or tokens.
- Updated the Sentinel security journal with key learnings from these improvements.
- Verified fixes with the existing test suite (all tests passing).

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.

Copilot AI review requested due to automatic review settings June 5, 2026 19:51
@vercel

vercel Bot commented Jun 5, 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 5, 2026 7:53pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens secret/token comparisons to avoid length-based timing side-channels and adds Telegram message ingestion filtering to prevent sensitive-looking user content from being processed or persisted.

Changes:

  • Updated Node (safeEqual) and Edge (safeEqualText) equality checks to compare fixed-length SHA-256 digests in constant time.
  • Added hasSensitiveContent gating in the Telegram handleMessage path to refuse processing of messages that look like credentials/secrets.
  • Added .jules/sentinel.md documenting the vulnerabilities and mitigations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
frontend/src/proxy.js Makes safeEqualText async and hashes inputs before constant-time comparison in the proxy/middleware path.
frontend/src/lib/middleware/auth.js Hardens safeEqual by hashing both inputs before timingSafeEqual.
frontend/src/lib/handlers/messageHandler.js Rejects sensitive-looking Telegram messages early and logs a security event.
.jules/sentinel.md Documents the timing-attack and secret-filtering mitigations introduced by this PR.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// ── Main Message Handler ──────────────────────────────────────────────────────
export async function handleMessage(chatId, text, messageId) {
if (hasSensitiveContent(text)) {
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.

2 participants