Skip to content

🛡️ Sentinel: [MEDIUM] Fix information disclosure in ingest route#102

Open
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-information-disclosure-ingest-15498800652787405020
Open

🛡️ Sentinel: [MEDIUM] Fix information disclosure in ingest route#102
socialawy-dev wants to merge 1 commit into
mainfrom
sentinel-fix-information-disclosure-ingest-15498800652787405020

Conversation

@socialawy-dev
Copy link
Copy Markdown
Collaborator

🚨 Severity: MEDIUM
💡 Vulnerability: The /projects/{project_id}/ingest endpoint in src/audioformation/server/routes.py directly returned unhandled exception details (str(e)) in the HTTPException detail field when a file upload failed. This could potentially expose sensitive internal file paths, library versions, or system state to a client.
🎯 Impact: Exposing raw exception messages can aid an attacker by revealing internal directory structures and the libraries/tools in use, which could be chained to exploit further vulnerabilities.
🔧 Fix:

  • Modified the exception block in ingest_files to log the actual error message internally using logger.error().
  • Raised the HTTPException with a generic detail="Upload failed" message to fail securely.
  • Also enhanced the validate_path_within helper in src/audioformation/utils/security.py to gracefully catch TypeError and AttributeError for malformed inputs, ensuring further robustness against exception-based disclosure or unexpected errors in path validation.
  • Recorded the findings in the .jules/sentinel.md journal.
    Verification:
  • The full test suite and lint checks ran and passed successfully.
  • Code conforms to defense-in-depth principles by logging sensitive info to the backend and failing securely on the frontend.

PR created automatically by Jules for task 15498800652787405020 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 disclosure vulnerability in the ingest route by sanitizing error messages returned to the client and logging the actual errors internally. It also enhances path validation security by catching additional exception types and updates dependency versions. Feedback was provided regarding a likely typo in the ruff version within the lock file and a suggestion to use logger.exception() for better error tracking in the server routes.

Comment thread uv.lock
{ name = "python-dotenv", marker = "extra == 'cloud'", specifier = ">=1.0,<2" },
{ name = "python-multipart", marker = "extra == 'server'", specifier = ">=0.0.27,<1" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1.9" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.15.1" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version specifier 0.15.1 for ruff appears to be a typo. Ruff versions currently follow a 0.x.y format, and the 0.1.x series ended at 0.1.15, while the current series is at 0.9.x. This invalid version will likely cause dependency resolution to fail. If you intended to update to a newer version, please verify the correct version number (e.g., 0.1.15 or a recent 0.9.x release). Furthermore, manually editing uv.lock is generally discouraged; it is better to update pyproject.toml and let the package manager regenerate the lock file.

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

When handling exceptions that result in a 500 Internal Server Error, it is more idiomatic and useful to use logger.exception(). This method automatically captures the full stack trace, which is essential for debugging the root cause of the failure. Additionally, using logger.exception("Upload failed") is preferred over f-strings for the log message to allow for cleaner logging and better integration with logging aggregators.

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

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