π‘οΈ Sentinel: [MEDIUM] Fix information exposure via exception details#79
π‘οΈ Sentinel: [MEDIUM] Fix information exposure via exception details#79socialawy-dev wants to merge 1 commit into
Conversation
- Prevent sensitive internal state/stack traces from leaking to clients - Update `HTTPException` detail in `ingest_files` to return a generic "Upload failed" - Update engine listing loop in `list_engines` to return a generic "Failed to load engine" instead of `str(e)` - Log the detailed exception strings via server-side logger for debugging Co-authored-by: socialawy <24765060+socialawy@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. |
There was a problem hiding this comment.
Code Review
This pull request addresses information exposure vulnerabilities by replacing detailed exception messages with generic ones in client responses within src/audioformation/server/routes.py. It also adds a corresponding entry to the security documentation in .jules/sentinel.md. The reviewer suggests using logger.exception() instead of logger.error() to ensure that full stack traces are preserved in server logs for debugging purposes while maintaining generic error messages for the client.
| with open(dest, "wb") as buffer: | ||
| shutil.copyfileobj(file.file, buffer) | ||
| except Exception as e: | ||
| logger.error(f"Upload failed: {e}") |
There was a problem hiding this comment.
Using logger.exception() is preferred over logger.error() when handling an exception. It automatically captures the full stack trace, which is essential for debugging internal server errors (500), whereas logging just the exception string ({e}) often omits critical context and the root cause.
| logger.error(f"Upload failed: {e}") | |
| logger.exception("Upload failed") |
| ## 2025-02-21 - Information Exposure via Exception Details | ||
| **Vulnerability:** Several API endpoints in `src/audioformation/server/routes.py` (like `/projects/{project_id}/ingest` and `/engines`) returned internal exception messages directly to the client (e.g., `raise HTTPException(status_code=500, detail=f"Upload failed: {e}")`). | ||
| **Learning:** Returning exception strings directly to the client (`{e}` or `str(e)`) can leak sensitive internal state, stack traces, paths, or configurations to users. | ||
| **Prevention:** Catch errors, log the detailed exception string with a server-side logger (e.g., `logger.error(...)`), and return a generic error message (like `"Upload failed"`) to the client. |
There was a problem hiding this comment.
In the Prevention section, it is recommended to suggest using logger.exception() instead of logger.error(). logger.exception() is specifically designed for exception handlers as it includes the stack trace in the logs, which is vital for troubleshooting the internal errors that this entry aims to address.
| **Prevention:** Catch errors, log the detailed exception string with a server-side logger (e.g., `logger.error(...)`), and return a generic error message (like `"Upload failed"`) to the client. | |
| **Prevention:** Catch errors, log the detailed exception with a server-side logger (e.g., logger.exception(...)), and return a generic error message (like "Upload failed") to the client. |
Understood. Acknowledging that this work is superseded by #90 and stopping work on this task. |
π¨ Severity: MEDIUM
π‘ Vulnerability: Several API endpoints returned internal exception strings directly to the client via
HTTPExceptiondetails or response JSON.π― Impact: Attackers could gain insights into internal paths, configurations, or stack traces through these error messages, aiding further attacks.
π§ Fix: Replaced dynamic exception details (
{e}) with static, generic error messages and ensured the actual exception is logged server-side usinglogger.error().β Verification: Ran
uv run pytest tests/to confirm no regressions and verified correct generic error strings in source.PR created automatically by Jules for task 2056376526784215684 started by @socialawy