Skip to content

🛡️ Sentinel: [MEDIUM] Fix information exposure in file upload#101

Open
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-upload-leak-17349463799640568448
Open

🛡️ Sentinel: [MEDIUM] Fix information exposure in file upload#101
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-upload-leak-17349463799640568448

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
💡 Vulnerability: The /projects/{project_id}/ingest endpoint caught arbitrary exceptions during file uploads and returned them directly to the client via raise HTTPException(status_code=500, detail=f"Upload failed: {e}"). This leaks internal stack trace/exception details which could aid attackers.
🎯 Impact: Attackers could gain knowledge of the internal system structure, file paths, or potentially sensitive configuration details if they can reliably trigger upload errors.
🔧 Fix: Changed the exception handling to log the raw exception internally using logger.error and return a generic "Upload failed" message to the user.
✅ Verification: Ran pytest tests/ successfully, verifying no tests broke. Also ran ruff check and ruff format to ensure code style compliance.
📝 Note: Logged in .jules/sentinel.md.


PR created automatically by Jules for task 17349463799640568448 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 an information exposure vulnerability in the file upload endpoint by returning a generic error message to the client instead of raw exception details. It also updates the security sentinel log to document this vulnerability. A review comment suggests using logger.exception instead of logger.error to ensure that full stack traces are captured in the internal logs for better diagnostics.

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

Using logger.exception is preferred over logger.error when handling exceptions in an except block. It automatically includes the full stack trace in the logs, which is essential for diagnosing the root cause of the upload failure (e.g., disk full, permission issues) without exposing those internal details to the client in the HTTP response.

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

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.

1 participant