Skip to content

🛡️ Sentinel: [HIGH] Fix timing attack and info disclosure in internal router#199

Open
ivanleekk wants to merge 1 commit into
devfrom
sentinel/fix-internal-security-16789968966607745194
Open

🛡️ Sentinel: [HIGH] Fix timing attack and info disclosure in internal router#199
ivanleekk wants to merge 1 commit into
devfrom
sentinel/fix-internal-security-16789968966607745194

Conversation

@ivanleekk

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
💡 Vulnerability: The internal scheduler API (/internal/tasks/daily-snapshot) had two security issues:

  1. It used a standard string equality check (!=) for a secret token in a custom HTTP Header, opening it up to timing attacks.
  2. The endpoint’s generic exception handler returned the raw exception string (str(e)) in a 500 error response, potentially leaking internal implementation details (e.g., database connection strings, file paths) to the client.

🎯 Impact:

  • An attacker could theoretically exploit the timing attack to guess the SCHEDULER_SECRET character by character.
  • The information disclosure could aid an attacker by revealing sensitive system internals upon triggering unexpected errors.

🔧 Fix:

  • Replaced the != check with secrets.compare_digest for constant-time comparison to prevent timing attacks, adding an explicit is None check to prevent runtime type errors if the header is omitted.
  • Updated the generic exception handler to return a standard "An internal server error occurred" message to the client, while utilizing logger.error("...", exc_info=True) to internally record the stack trace and maintain observability.

Verification:

  • The modifications in backend/src/routers/internal.py have been verified.
  • The Python code has been successfully linted (uv run ruff check src/routers/internal.py).

PR created automatically by Jules for task 16789968966607745194 started by @ivanleekk

Co-authored-by: ivanleekk <84584280+ivanleekk@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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.

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