Skip to content

πŸ›‘οΈ Sentinel: [MEDIUM] Fix information exposure via exception details#79

Closed
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-error-leak-2056376526784215684
Closed

πŸ›‘οΈ Sentinel: [MEDIUM] Fix information exposure via exception details#79
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-error-leak-2056376526784215684

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
πŸ’‘ Vulnerability: Several API endpoints returned internal exception strings directly to the client via HTTPException details 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 using logger.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

- 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>
@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 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}")
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. 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.

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

Comment thread .jules/sentinel.md
## 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.
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

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.

Suggested change
**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.

@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-error-leak-2056376526784215684 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 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