Skip to main content
Menu
Advisories

CORS wildcard echoes request Origin while allowing credentials, enabling cross-origin credential theft

GHSA-9589-5P58-QPH8Published Updated GitHub

Description

The HTTP origin-handling middleware shared by MediaMTX's HLS, WebRTC, API, playback, metrics and pprof servers is responsible for adding CORS headers when a request carries an Origin header. When the configured allow-list contains the wildcard *, the handler was supposed to signal that any origin is permitted by returning the literal string * in Access-Control-Allow-Origin. Instead, it returned whatever value the client sent in its own Origin request header, and the same code path unconditionally also set Access-Control-Allow-Credentials: true.

Browsers refuse to expose a credentialed cross-origin response when Access-Control-Allow-Origin is the literal wildcard, but they accept it when a specific origin is named, even if that origin was just echoed back verbatim from the request. Combining an echoed, attacker-controlled origin with Access-Control-Allow-Credentials: true therefore produces a response that looks fully spec-compliant to the browser while approving every possible origin. Any third-party web page can issue a credentialed cross-origin request to a MediaMTX instance configured with a wildcard allow-list and have the browser attach cached credentials, letting the attacker's script read the response body directly, including stream data, recordings, and, on the API server, configuration and administrative responses.

This was fixed in PR #5975, which makes the wildcard branch return the literal * instead of the request's Origin header and stops setting Access-Control-Allow-Credentials altogether, so browsers correctly withhold credentials from wildcard-permitted requests.

Affected versions

References

GitHub · bluenviron/mediamtx