π‘οΈ Sentinel: [security improvement] Fix swallowed tracebacks in global exception handler - #236
Conversation
The custom global exception handler for FastAPI (used to inject security headers into 500 error responses) was successfully catching all exceptions but returning a generic plain text response without logging the exception traceback. This causes unhandled exceptions to be silently swallowed on the server side, violating operational security practices for debugging and incident response. This commit adds a call to `logging.error` with `exc_info=_exc` to explicitly log the traceback server-side before returning the generic 500 response to the client. Co-authored-by: n24q02m <135627235+n24q02m@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 global
@app.exception_handler(Exception)insrc/tacet/serve/server.pywas returning a generic 500 error to avoid leaking tracebacks to the client (which is good), but it failed to log the exception server-side. This silently swallowed all unhandled exceptions, making incident response and debugging extremely difficult.π― Impact: Unhandled server errors would fail silently without leaving a trace in the logs, leading to a loss of critical diagnostic information and delayed vulnerability detection.
π§ Fix: Added
logging.error("Unhandled exception", exc_info=_exc)to theunhandled_exception_handlerto ensure the traceback is preserved in the server logs while still returning the safe, generic 500 response to the client.β Verification: Verified by throwing a deliberate exception (
1/0) in a test route and confirming that the traceback is correctly logged via standard pythonloggingoutput while the HTTP client still receives the generic 500 response. Tests pass viauv run --all-extras pytest.PR created automatically by Jules for task 1979960182809448400 started by @n24q02m