Summary
A path traversal weakness in AzuraCast's Flow.js media upload endpoint allows authenticated users with media management permissions to write files outside the intended station media directory.
When a local filesystem backend is used, this can be abused to place arbitrary files such as PHP scripts into the web root, potentially leading to remote code execution.
Affected context
The vulnerability appears in AzuraCast instances using the Flow.js media upload API at POST /api/station/{station_id}/files/upload with a local filesystem storage backend.
It affects scenarios where the currentDirectory request parameter is accepted and used to build filesystem paths without fully neutralizing path traversal sequences such as ../.
Only users who are authenticated and have media management permissions for a station can reach and exercise this endpoint under normal configurations.
Exploit preconditions
- Attack surface: HTTP API endpoint
POST /api/station/{station_id}/files/upload - Required access: Valid authenticated user account with media management permissions for a target station
- Environmental dependencies:
- Station configured with a local filesystem storage backend (default mode)
- Web server executing server-side code (e.g., PHP) from a directory reachable via filesystem traversal from the station media root
- Trigger point: Supplying a crafted
currentDirectoryparameter containing path traversal sequences so that the uploaded file is written outside the station's media directory - Why exploitation is possible: The server-side handler trusts and concatenates
currentDirectorywith base paths without robust normalization or restriction, allowing attackers to break out of the intended storage directory and target sensitive locations such as the web root.
Why this happens
This issue stems from insufficient validation and normalization of user-controlled path components when constructing filesystem paths for uploaded media.
The currentDirectory parameter is used to determine where an uploaded file should be stored, but it is not properly sanitized to remove or reject traversal sequences like ../, absolute paths, or other bypass patterns.
As a result, the application logic violates the intended directory confinement and allows writing files outside the station media storage root.
Conceptually, this maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where user input is naively combined with filesystem paths, enabling attackers to reach arbitrary locations on the server's filesystem.
Potential impact
- An authenticated attacker may write arbitrary files to directories outside the station's media storage area.
- Attackers could place a PHP webshell or other executable script into the web root, enabling remote code execution under the web server's privileges.
- Modification or overwriting of application files, configuration files, or other sensitive assets may occur if file permissions allow it.
- Potential escalation from a limited media-management account to broader system compromise, including data theft or service disruption.
General mitigation guidance
Effective mitigation focuses on constraining file operations to well-defined directories and minimizing trust in client-controlled paths:
- Enforce strict canonicalization of any directory parameters by resolving to an absolute path and verifying that it remains within a predefined base directory; reject requests that resolve outside this root.
- Treat all user-supplied path segments, including directory names, as untrusted and restrict them to a whitelist of allowed characters and structures (e.g., no
.., no leading slashes). - Centralize file storage APIs so all file writes pass through a safe abstraction that enforces directory confinement and path normalization.
- Run the application and web server with minimal filesystem privileges, ensuring they cannot write to code directories or other sensitive locations wherever possible.
- Consider using storage backends or deployment models where uploaded files cannot be interpreted as executable code (e.g., segregated file servers, object storage, or separate domains for static content).
How teams detect issues like this
Organizations can identify and monitor for this class of vulnerability using a combination of proactive and reactive techniques:
- Static analysis and code scanning: Create rules that flag direct concatenation of user input into filesystem paths, especially parameters like
directory,path, orfilename, and require explicit normalization and boundary checks. - Code review practices: During reviews, scrutinize upload endpoints and file handling routines for assumptions about trusted paths; ensure reviewers look for
../handling, canonical path checks, and enforced base directories. - Runtime logging and monitoring: Log upload destinations, including resolved absolute paths, and alert on attempts to write outside expected directories or into unusual locations such as application code paths.
- Security testing and fuzzing: Incorporate path traversal payloads into API security tests for upload and file management endpoints to detect breakout behaviors before deployment.

