π‘οΈ Sentinel: [MEDIUM] Fix exception handling in admin login to prevent information leak - #166
Conversation
Co-authored-by: shadowcoder8 <185462083+shadowcoder8@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. |
π¨ Severity: MEDIUM
π‘ Vulnerability: The
/admin/login/route used a genericexcept Exception as ehandler that caught all errors (includingHTTPExceptions thrown by underlying logic, such as a 500 error for missing configuration) and blindly returnedstr(e)in the detail of a new 401HTTPException. This incorrectly exposed raw internal string representations of exceptions directly to the client.π― Impact: Potential leakage of sensitive internal details (e.g. database connection strings or missing configuration state) to unauthorized users.
π§ Fix: Refactored the exception handling in
main.py's/admin/login/route. Explicitly caught and re-raisedHTTPExceptionto preserve intended responses (like 500 for missing config), and replaced the catch-allExceptionblock to log the detail internally while returning a sanitized generic error to the client. Also added a.jules/sentinel.mdentry.β Verification: Verified via an ad-hoc test script using mocks (since removed) that unconfigured credentials result in a proper 500 error and other exceptions are sanitized. All existing Pytest tests continue to pass.
PR created automatically by Jules for task 17223080497846640034 started by @shadowcoder8