Skip to main content
Menu
Advisories

Zero-length HEVC parameter sets in an RTMP publisher's configuration cause an index-out-of-range panic that crashes MediaMTX

GHSA-7498-VJGW-9CR2Published Updated GitHub

Description

MediaMTX's RTMP server relies on the gortmplib library to parse the codec configuration sent by publishers. For H265 streams, the HEVCDecoderConfigurationRecord carried by an RTMP video configuration message contains arrays of VPS, SPS and PPS NAL units. The helper h265FindNALU() in gortmplib's reader.go looked up each parameter set by checking that the array had the requested type and exactly one NAL unit (entry.NumNalus == 1), and then verified the NAL unit type by reading entry.Nalus[0].NALUnit[0]. It never checked that the declared NAL unit contained at least one byte.

A publisher can send an HEVC configuration in which the VPS, SPS and PPS arrays each declare a single NAL unit of length zero. Dereferencing NALUnit[0] on the empty slice raises a runtime error: index out of range [0] with length 0. The configuration can be sent after a valid track has been set up, since gortmplib handles later configuration messages in the OnDataH265() callback, so the panic occurs in the RTMP connection goroutine, which does not recover from it. A panic in any goroutine terminates the whole Go process, so a single unauthenticated RTMP publisher (on a default configuration, where publishing is open) could crash MediaMTX and interrupt every stream and protocol served by it. The same unchecked access was present in MediaMTX's own RTMP code before it was moved into gortmplib, and was present in gortmplib since its first release.

This was fixed in gortmplib PR #121, which replaces h265FindNALU() with a stricter h265FindParams() that returns an error for empty or multiple parameter sets, and makes the message parsing reject empty H264/H265 parameters, so the connection is closed with an error instead of panicking. The fix is included in MediaMTX v1.21.0, which updates gortmplib to v1.0.2.

Reported by the University of Sydney security research team.

Affected versions

References

GitHub · bluenviron/mediamtx