Skip to content

🔒 [security fix] Path Traversal in BrowserController and DownloadController#118

Merged
juzaweb merged 1 commit into
masterfrom
security-fix-path-traversal-browser-controller-3829253760826571357
Mar 20, 2026
Merged

🔒 [security fix] Path Traversal in BrowserController and DownloadController#118
juzaweb merged 1 commit into
masterfrom
security-fix-path-traversal-browser-controller-3829253760826571357

Conversation

@juzaweb

@juzaweb juzaweb commented Mar 20, 2026

Copy link
Copy Markdown
Owner

This PR fixes a security vulnerability that allowed path traversal in the file manager's showFile and getDownload endpoints.

🎯 What

The showFile and getDownload methods used user-supplied paths to access files on the storage disk without sufficient sanitization. This allowed an attacker to use ../ sequences to access files outside the intended storage root.

⚠️ Risk

An attacker could potentially read sensitive system files or other users' private files if the storage disk had access to them, leading to information disclosure.

🛡️ Solution

  1. Centralized Sanitization: Added a cleanPath method to the base FileManagerController that:
    • Aborts with a 404 if the path contains .., preventing any traversal attempts.
    • Trims leading slashes and backslashes to ensure paths are relative to the disk root.
  2. Refactored DownloadController: Updated DownloadController to extend FileManagerController and use the cleanPath logic.
  3. Explicit Existence Check: Enhanced DownloadController::getDownload to verify file existence via Storage::exists($file) before attempting to retrieve the local path, ensuring that traversal attempts that bypass string checks (if any) are caught by the filesystem driver's own security boundaries.
  4. Automated Testing: Added a new feature test tests/Feature/Security/PathTraversalTest.php covering standard traversal, nested bypass attempts (....//), and edge cases.

PR created automatically by Jules for task 3829253760826571357 started by @juzaweb

…oller

Addresses a path traversal vulnerability in the file manager where arbitrary file access was possible via the 'path' or 'file' parameters.

- Implemented centralized path sanitization in `FileManagerController::cleanPath`.
- Rejects any paths containing '..' to prevent directory traversal.
- Updated `DownloadController` to inherit from `FileManagerController` and use the new sanitization logic.
- Added explicit file existence check in `DownloadController` using the Storage facade.
- Added comprehensive security tests in `PathTraversalTest.php`.

Co-authored-by: juzaweb <47020363+juzaweb@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.

@juzaweb juzaweb merged commit ec088c7 into master Mar 20, 2026
8 checks passed
@juzaweb juzaweb deleted the security-fix-path-traversal-browser-controller-3829253760826571357 branch March 20, 2026 08:03
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