Skip to content

🛡️ Sentinel: [MEDIUM] Fix error handling exposing internal details#68

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

🛡️ Sentinel: [MEDIUM] Fix error handling exposing internal details#68
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-exception-leak-7886688864749258669

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
💡 Vulnerability: The /projects/{project_id}/ingest API endpoint caught generic exceptions during file upload processing and interpolated the exception string directly into the HTTPException detail returned to the client.
🎯 Impact: This allowed system-level exceptions (like OSError or shutil errors) to leak sensitive internal details, such as file paths and server internal states, to the end-user or potential attackers.
🔧 Fix: Replaced the raw exception string ({e}) in the HTTPException response with a generic "Upload failed" message. Logged the actual exception using logger.exception() to ensure the error is safely recorded internally for debugging without external exposure.
Verification: Verified by inspecting the changes and running pytest test suite, validating that tests continue to pass and exceptions are successfully isolated to server logs.


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

… /ingest

Replaced raw exception string in the HTTPException detail response with a generic error message, and logged the actual exception internally using logger.exception() to prevent leakage of internal system details and stack traces to clients.

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 improves error handling in the ingest_files route by logging exceptions and returning a generic error message to the client. The review feedback identifies an opportunity to improve the API's accuracy by handling ValueError as a 400 Bad Request instead of a 500 Internal Server Error, and notes that the exception object is redundantly included in the logger.exception call.

Comment on lines +188 to +189
logger.exception(f"Ingest upload failed: {e}")
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

The current implementation catches all exceptions and returns a 500 Internal Server Error. However, sanitize_filename raises a ValueError if the input is invalid (e.g., empty after sanitization), which is a client-side error that should return a 400 Bad Request. Returning a 500 error for client-side issues can mislead users and trigger unnecessary server-side alerts.

Additionally, when using logger.exception(), the exception details (message and traceback) are automatically captured and appended to the log output. Including {e} in the message string is redundant and leads to cluttered logs where the error message appears twice.

        if isinstance(e, ValueError):
            raise HTTPException(status_code=400, detail=str(e))
        logger.exception("Ingest upload failed")
        raise HTTPException(status_code=500, detail="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-exception-leak-7886688864749258669 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 now obsolete 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