# GHSA-48F4-WM59-FXC5: Open redirect via protocol-relative path in HLS and WebRTC trailing-slash redirects

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-09-12
- Modified: 2026-09-12

## Affected versions

- github.com/bluenviron/mediamtx (Go): from v1.7.0, fixed in v1.18.1

## Description

The HLS and WebRTC HTTP servers each defined a local `mergePathAndQuery` helper used to build the `Location` header for the automatic redirect issued when a request path is missing its trailing slash (e.g. `GET /mypath` → `302 Location: /mypath/`). This helper simply concatenated `ctx.Request.URL.Path + "/"` with the raw query string, performing no validation or sanitization of the path.

Because `ctx.Request.URL.Path` is taken directly from the incoming request and can contain multiple leading slashes, a request such as `GET //interact.sh/en` causes the server to respond with `Location: //interact.sh/en/`. A `Location` header beginning with `//` is a protocol-relative URL, which browsers resolve against the same scheme but an attacker-chosen host, resulting in an open redirect from the MediaMTX server to an arbitrary external domain.

This helper was introduced when both HTTP servers were changed to use absolute paths in the `Location` header, replacing an earlier helper that stripped leading slashes before rebuilding the path — effectively reintroducing an open-redirect flaw that had already been fixed once before.

The issue was fixed in PR #5708, which replaced the unsafe helper with two new functions, `trailingSlashLocation` and `sanitizeLocation`, in both HTTP servers. Both call `path.Clean` on the raw path and then strip all leading slashes and backslashes before re-prepending a single `/`, neutralizing protocol-relative payloads regardless of how many leading slashes are supplied.

## References

- https://github.com/bluenviron/mediamtx/security/advisories/GHSA-48f4-wm59-fxc5

Page: https://cve.now/GHSA-48F4-WM59-FXC5

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
