Skip to content

πŸ›‘οΈ Sentinel: [MEDIUM] Fix Exception Detail Leakage in Upload Endpoint#67

Closed
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-upload-exception-leak-6066871779753876832
Closed

πŸ›‘οΈ Sentinel: [MEDIUM] Fix Exception Detail Leakage in Upload Endpoint#67
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-upload-exception-leak-6066871779753876832

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
πŸ’‘ Vulnerability: The upload_file related error handling directly embedded the Exception object (e) in the HTTPException detail, causing information leakage.
🎯 Impact: An attacker or untrusted client could potentially see server-side paths, dependency exceptions, or other internal data.
πŸ”§ Fix: Removed f"Upload failed: {e}" and replaced it with a private logger.error(f"Upload failed: {e}") and a sanitized raise HTTPException(status_code=500, detail="Upload failed").
βœ… Verification: Ran the test suite to verify no regressions were introduced.


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

This commit modifies `src/audioformation/server/routes.py` to prevent leaking internal exception details (such as stack traces or internal paths) to the client via a 500 error response. The internal exception is now logged privately using `logger.error`, and a generic error detail is returned in the HTTP response.

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 where internal exception details were leaked to clients via the ingest endpoint. The changes ensure that errors are logged privately on the server while returning a generic error message to the user. Feedback suggests correcting the endpoint name in the security documentation and utilizing logger.exception instead of logger.error to ensure full stack traces are captured for debugging.

Comment thread .jules/sentinel.md
Comment on lines +6 to +7
## 2025-02-21 - Exception Detail Leakage in Upload Endpoint
**Vulnerability:** The /projects/{project_id}/upload and similar ingest endpoints in src/audioformation/server/routes.py included the raw exception object (e) directly inside the HTTPException detail message string. This could leak internal paths, underlying library exceptions, or environmental details to untrusted clients if the upload process fails.
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 security log incorrectly identifies the /projects/{project_id}/upload endpoint as the source of the information leak. The code changes show that the vulnerability was actually in the /projects/{project_id}/ingest endpoint. The upload endpoint already used a generic error message. The documentation should be updated for accuracy.

Suggested change
## 2025-02-21 - Exception Detail Leakage in Upload Endpoint
**Vulnerability:** The /projects/{project_id}/upload and similar ingest endpoints in src/audioformation/server/routes.py included the raw exception object (e) directly inside the HTTPException detail message string. This could leak internal paths, underlying library exceptions, or environmental details to untrusted clients if the upload process fails.
## 2025-02-21 - Exception Detail Leakage in Ingest Endpoint
**Vulnerability:** The /projects/{project_id}/ingest and similar endpoints in src/audioformation/server/routes.py included the raw exception object (e) directly inside the HTTPException detail message string. This could leak internal paths, underlying library exceptions, or environmental details to untrusted clients if the ingest process fails.

Comment thread .jules/sentinel.md
## 2025-02-21 - Exception Detail Leakage in Upload Endpoint
**Vulnerability:** The /projects/{project_id}/upload and similar ingest endpoints in src/audioformation/server/routes.py included the raw exception object (e) directly inside the HTTPException detail message string. This could leak internal paths, underlying library exceptions, or environmental details to untrusted clients if the upload process fails.
**Learning:** When raising HTTP errors that are exposed to clients, avoid formatting internal exceptions into the response detail. Internal details must be logged privately on the server side.
**Prevention:** Use a private logging mechanism (e.g. logger.error) and return generic error details to the user (e.g. raise HTTPException(status_code=500, detail="Upload failed")).
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

It is recommended to suggest logger.exception in the prevention advice, as it ensures that the full stack trace is captured for debugging server-side failures, which is more effective than just logging the exception message.

Suggested change
**Prevention:** Use a private logging mechanism (e.g. logger.error) and return generic error details to the user (e.g. raise HTTPException(status_code=500, detail="Upload failed")).
**Prevention:** Use a private logging mechanism (e.g. logger.exception) and return generic error details to the user (e.g. raise HTTPException(status_code=500, detail="Upload failed")).

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: {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

Using logger.exception is preferred over logger.error when handling an exception that results in a 500 error. logger.exception automatically captures the full stack trace, which is essential for diagnosing the root cause of failures in production.

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

@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-upload-exception-leak-6066871779753876832 branch May 13, 2026 19:07
@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 by #90 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