# GHSA-CQVX-R8CV-PQP5: Argument injection via MTX\_QUERY in hook commands

- Database: GitHub
- Severity: CVSS 8.1 (High)
- Published: 2026-09-12
- Modified: 2026-09-12

## Affected versions

- github.com/bluenviron/mediamtx (Go): from 1.0.0, fixed in 1.18.1

## 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.

## References

- https://github.com/bluenviron/mediamtx/security/advisories/GHSA-cqvx-r8cv-pqp5

Page: https://cve.now/GHSA-CQVX-R8CV-PQP5

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