Skip to main content
Menu
Advisories

Argument injection via MTX_QUERY in hook commands

GHSA-CQVX-R8CV-PQP5Published Updated GitHub

Description

internal/externalcmd/cmd.go expanded $VAR references in a hook's configured command string using os.Expand before the string was tokenized into arguments. Because MTX_QUERY holds the raw, attacker-controlled query string from an RTSP SETUP URL, a client could embed shell metacharacters in it that, once substituted into the command string and then split into arguments, were interpreted as additional arguments, redirections, or command separators rather than literal text. Any runOnDemand, runOnReady, runOnRead hook (or their Un* counterparts) that references $MTX_QUERY was affected, and exploitation required only an active RTSP publish or read on the target path, with no authentication.

The fix, merged in PR #5707, tokenizes the command string first and then expands variables within each resulting argument individually, so a substituted value can no longer introduce new argument boundaries. As defense in depth, MTX_QUERY is now also URL-encoded before being exposed to hooks.

Affected versions

References

GitHub · bluenviron/mediamtx