Summary
Bazarr's subtitle API can read files outside the media library and, through subtitle synchronization or translation, may overwrite files outside it. The risk arises when an accessible endpoint processes caller-supplied paths without ensuring they stay within authorized media files; the affected files are limited by the Bazarr process's permissions.
Affected context
The issue affects Bazarr's /api/subtitles/subtitles-info and /api/subtitles/subtitles handlers. The first checks the supplied subtitle file's extension but does not confine its resolved path to files indexed by Bazarr; the second passes supplied paths and references to synchronization and translation without per-path authorization. The authentication decorator gates both endpoints when API authentication is enabled; when auth = None, they can be accessed without credentials.
Exploit preconditions
- Attack surface: The Bazarr subtitle API endpoints must be reachable.
- Required access: If API authentication is enabled, valid access through the configured authentication mechanism is required. With
auth = None, credentials are not required. - Trigger point: A request supplies a path to the subtitles-info handler or a path and reference to the subtitles handler for synchronization or translation.
- Why exploitation is possible: The handlers do not consistently verify that resolved paths refer to authorized files within the media library.
- Permission boundary: Reads and writes are limited to files the Bazarr process can access.
Why this happens
The underlying bug is insufficient path validation and authorization, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). Checking a filename extension does not establish that its resolved path is inside an allowed directory, and accepting paths for file operations without per-path authorization can expose files beyond the intended media-library boundary.
Potential impact
- An attacker with access to the endpoints may read files outside the media library that the Bazarr process can access.
- Synchronization or translation may overwrite files outside the media library within the process's write permissions.
- Exposed or modified files could affect the confidentiality or integrity of the host or application environment.
General mitigation guidance
Defensive patterns focus on keeping file operations within explicit, authorized boundaries:
- Resolve supplied paths to canonical paths and verify they remain under an approved media-library root.
- Prefer server-side identifiers for indexed files over accepting arbitrary filesystem paths.
- Apply per-file authorization to paths and references used for reading, synchronization, and translation.
- Use restrictive file permissions and run the application with only the filesystem access it needs.
- Require authentication for API access and avoid configurations that expose sensitive endpoints without credentials.
- Validate inputs against an explicit schema and reject paths that do not map to approved files.
How teams detect issues like this
- Use static analysis to flag file operations that consume request-controlled paths without canonicalization and directory-boundary checks.
- Review API handlers for extension-only validation, missing per-resource authorization, or path parameters passed to read and write operations.
- Test policy enforcement with requests targeting paths outside the configured media-library roots, verifying that both reads and writes are rejected.
- Monitor application access logs and filesystem activity for unusual requests or file operations outside expected media directories.

