Skip to content

🛡️ Sentinel: [MEDIUM] Fix Exception Details Leakage in API response#70

Closed
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-exception-leakage-3853378492521698343
Closed

🛡️ Sentinel: [MEDIUM] Fix Exception Details Leakage in API response#70
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-exception-leakage-3853378492521698343

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
💡 Vulnerability: The /projects/{project_id}/ingest API endpoint returned raw internal exceptions in the HTTP 500 response directly to the client, exposing details about the file system or internal logic.
🎯 Impact: Attackers can potentially gain insight into internal paths, system state, or server logic by analyzing exposed error strings, which aids in crafting further attacks.
🔧 Fix: Updated exception handling to log the raw exception securely on the server using logger.error and return a generic "Upload failed" message in the HTTP response.
✅ Verification: Ran the test suite successfully and verified that HTTP 500 exceptions now only return generic text.


PR created automatically by Jules for task 3853378492521698343 started by @socialawy

Co-authored-by: socialawy <24765060+socialawy@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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a security vulnerability in the ingest endpoint where internal exception details were exposed to clients. The changes implement server-side logging and return a generic error message, along with updating the sentinel documentation. Review feedback recommends using logger.exception() instead of logger.error() in both the implementation and the documentation to ensure full stack traces are captured for debugging purposes.

except Exception as e:
shutil.rmtree(tmp_dir, ignore_errors=True)
raise HTTPException(status_code=500, detail=f"Upload failed: {e}")
logger.error(f"Upload failed for project {project_id}: {e}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When catching an exception to log it, it is best practice to use logger.exception(). This method automatically captures the full stack trace, which is much more helpful for debugging than just the exception string. Using logger.error() with an f-string only logs the message and the exception's string representation, losing the traceback context.

Suggested change
logger.error(f"Upload failed for project {project_id}: {e}")
logger.exception(f"Upload failed for project {project_id}")

Comment thread .jules/sentinel.md
## 2025-02-21 - Exception Details Leakage in Ingest Endpoint
**Vulnerability:** The `/projects/{project_id}/ingest` API endpoint in `src/audioformation/server/routes.py` returned the raw exception string in the `detail` field of the HTTP 500 response (`Upload failed: {e}`).
**Learning:** Exposing internal exception details (like file system errors, internal state, or stack traces) to the client can give attackers insight into the internal workings of the application. Error handling should log the details server-side and return generic error messages to the client.
**Prevention:** Always log the exception object using a logger (e.g., `logger.error()`) internally, and return a sanitized, generic error message (e.g., `detail="Upload failed"`) to the client in the `HTTPException`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The prevention advice should recommend using logger.exception() instead of logger.error() when handling exceptions. logger.exception() is specifically designed for use inside except blocks to capture the full traceback, which is essential for internal troubleshooting while still allowing the API to return a generic error message to the client.

@socialawy
Copy link
Copy Markdown
Owner

Superseded by #90 (merged ac23b55). The Sentinel/Jules SafeStaticFiles chain was iterating on the same middleware; #90's Path(str(path).lower()) fix addresses the root AttributeError. Closing as duplicate; re-open if a distinct vulnerability emerges.

@socialawy socialawy closed this May 13, 2026
@socialawy socialawy deleted the sentinel-fix-exception-leakage-3853378492521698343 branch May 13, 2026 19:06
@google-labs-jules
Copy link
Copy Markdown
Contributor

Superseded by #90 (merged ac23b55). The Sentinel/Jules SafeStaticFiles chain was iterating on the same middleware; #90's Path(str(path).lower()) fix addresses the root AttributeError. Closing as duplicate; re-open if a distinct vulnerability emerges.

Understood. Acknowledging that this work is superseded and stopping work on 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.

2 participants