GHSA-gv7r-3mr9-h5x8 AzuraCast has Password Reset Poisoning via Untrusted X-Forwarded-Host Header that Leads to Account Takeover and 2FA Bypass
SummaryThe `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.DetailsRoot Cause 1: Unconditional X-Forwarded-Host Trust`backend/src/Middleware/ApplyXForwarded.php:35-40`: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 `fastcgi_pass` with `include fastcgi_params`. Standard nginx behavior passes all client HTTP headers through to PHP-FPM as `HTTP_*` parameters. The `proxy_params.conf` file — which explicitly sets `X-Forwarded-For`, `X-Forwarded-Proto`, and `X-Forwarded-Port` — only applies to `proxy_pass` directives (websocket and vite dev server), NOT to the `fastcgi_pass` 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()`:With `prefer_browser_url = 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 `base_url` 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`: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`: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**Expected result:** The password reset email sent to `admin@target.com` contains a URL like:Step 2: Capture the tokenWhen 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**Result:** The victim's password is changed to `AttackerPassword123` and their 2FA is destroyed (`two_factor_secret = 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 settingsThe 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 successRecommended 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):**Fix 2 (Defense in depth): Use configured base URL for security-critical emails**In `ForgotPasswordAction.php`, generate the reset URL using the configured `base_url` setting rather than the request-derived URL: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->two_factor_secret = null;`. If 2FA recovery is needed, it should be a separate, explicit flow — not a side effect of password reset.
CVSS v3.1 score: 8.1