GHSA-vvp7-h4fj-m28w FileBrowser Quantum's path traversal issue in subtitle handler allows any authenticated user to read arbitrary files
SummaryThe `subtitlesHandler` endpoint (`GET /api/media/subtitles`) accepts two user-controlled query parameters: `path` and `name`, both of which are used in filesystem operations without sanitization, creating two independent path traversal vectors.The primary vector is the `path` parameter: it is passed directly to `idx.GetRealPath()` without calling `SanitizeUserPath()`, allowing an attacker to escape the storage root and set `parentDir` to any directory on the host. No existing anchor file is required.The secondary vector is the `name` parameter: it is joined with `parentDir` via `filepath.Join(parentDir, name)` without stripping directory components, allowing traversal relative to any resolved `parentDir`.Any authenticated user (regardless of role or permissions) can exploit either vector to read any text file readable by the server process, including `/etc/passwd`, SSH keys, database credentials, and JWT signing keys.Details**1. `path` parameter lacks `SanitizeUserPath()` — primary vector (`http/media.go:54`)**`SanitizeUserPath()` explicitly rejects `..` segments:Every other handler in the codebase calls `SanitizeUserPath()` before `GetRealPath()`. This handler skips it, so `path=../../etc/passwd` resolves `parentDir` to `/etc`, with no anchor file required.**2. `name` parameter used directly in `filepath.Join` — secondary vector (`http/media.go:63`)**`filepath.Join(parentDir, "../../etc/passwd")` resolves the `..` components, escaping `parentDir`. This vector requires a valid file in scope as the `path` anchor.**3. `GetSubtitleSidecarContent` reads and returns file contents (`common/utils/media.go:17-43`)**The only constraint is that the target file must be UTF-8 valid and under 50MB. Binary files silently return an empty string.**4. Endpoint is behind `withUser` but requires no special permissions**Any authenticated user can access this endpoint: no admin, modify, share, or download permission is required.PoC**Vector 1: `path` traversal (no anchor file needed):****Expected output:** `/etc/passwd` contents with HTTP 200.**Vector 2: `name` traversal (anchor file required):****Expected output:** `/etc/passwd` contents with HTTP 200.Impact**Arbitrary file read**: Any authenticated user can read any text file on the host filesystem that the server process has read permission for.**No anchor file required**: The `path` vector works on a default install with an empty storage root, so no existing file in scope is needed.**Scope bypass**: Scoped users (restricted to a subdirectory) can escape their scope via either vector and access files belonging to other users or the host system.**Credential exposure**: `/etc/passwd`, `/etc/shadow` (if running as root), SSH private keys, application configuration files with database passwords, API keys, and JWT signing secrets.**Privilege escalation**: Reading the JWT signing key from the database or config file enables forging admin tokens.**No special permissions required**: The endpoint only requires basic authentication: no admin, modify, share, or download permissions.Recommended FixApply `SanitizeUserPath()` to the `path` parameter and `filepath.Base()` to the `name` parameter:`SanitizeUserPath()` rejects any `..` segment. `filepath.Base("../../etc/passwd")` returns `"passwd"`, preventing traversal via `name`. Additionally, consider adding a file extension allowlist to restrict `name` to subtitle formats (`.srt`, `.vtt`, `.ass`, `.ssa`, `.sub`) only.
CVSS v3.1 score: 7.7