🛡️ Sentinel: [MEDIUM] Fix information exposure in file upload#101
🛡️ Sentinel: [MEDIUM] Fix information exposure in file upload#101socialawy-dev wants to merge 1 commit into
Conversation
Co-authored-by: socialawy <24765060+socialawy@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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.
| logger.error(f"Upload failed for project {project_id}: {e}") | |
| logger.exception(f"Upload failed for project {project_id}") |
🚨 Severity: MEDIUM
💡 Vulnerability: The
/projects/{project_id}/ingestendpoint caught arbitrary exceptions during file uploads and returned them directly to the client viaraise 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.errorand return a generic "Upload failed" message to the user.✅ Verification: Ran
pytest tests/successfully, verifying no tests broke. Also ranruff checkandruff formatto ensure code style compliance.📝 Note: Logged in
.jules/sentinel.md.PR created automatically by Jules for task 17349463799640568448 started by @socialawy