Closed
Description
A malicious or broken RTMP server can send a Set Chunk Size (type 0x01)
message with a value of 0 or a negative int32. The value is stored
unchecked:
plugins/obs-outputs/librtmp/rtmp.c:3600-3608
HandleChangeChunkSize:r->m_inChunkSize = AMF_DecodeInt32(packet->m_body);
no validation that the result is > 0.
Consumed at rtmp.c:3949-3963 in RTMP_ReadPacket:
nToRead = packet->m_nBodySize - packet->m_nBytesRead;
nChunk = r->m_inChunkSize;
if (nToRead < nChunk) nChunk = nToRead;
if (ReadN(r, packet->m_body + packet->m_nBytesRead, nChunk) != nChunk)ReadN (rtmp.c:1475-1576) loops while (n > 0) and returns
nOriginalSize - n, so for nChunk <= 0 it reads nothing and returns
nChunk itself — the != nChunk error check passes.
Effects:
m_inChunkSize == 0:nChunk = 0,m_nBytesReadnever advances.
RTMP_ReadPacketconsumes only per-chunk headers and the packet never
completes — a server that keeps trickling headers wedges
process_recv_dataforever; the send thread can't service stop, so
stopping the output hangs the streaming stop path.m_inChunkSize < 0:m_nBytesReaddecreases each chunk
(rtmp.c:3972), going negative and movingm_body + m_nBytesRead
before the allocation; the packet still never completes (same DoS),
and the corrupted offset is copied intom_vecChannelsIn[]
(rtmp.c:3975-3977).
Suggested fix: in HandleChangeChunkSize, ignore values < 1 (and
cap the maximum, e.g. > 128 MB), matching the RTMP spec's
1..0x7FFFFFFF range.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
test/cmocka: Add RTMP Set Chunk Size test
librtmp: Reject invalid Set Chunk Size values
chriscoveries commentedon Oct 11, 2026
Note on upstream OBS Studio: this bug very likely affects obsproject/obs-studio too. We would report it there, but OBS Studio bans AI-assisted contributions, and in the owner's view they're probably too woke to handle it anyway, so we're keeping it here. Fix: #115.
librtmp: Clamp Set Chunk Size to RTMP_MAX_IN_CHUNK_SIZE