Skip to content

[crash] librtmp AMF_Decode: unbounded recursion on server data -> stack overflow #102

Closed

Description

@chriscoveries

AMF_Decode/AMFProp_Decode/AMF_DecodeArray in
plugins/obs-outputs/librtmp/amf.c recurse once per nesting level of the
AMF data, with no depth limit, on packet bodies supplied by the remote
RTMP server.

  • amf.c:697 (AMF_OBJECT), :725 (AMF_ECMA_ARRAY), :741
    (AMF_STRICT_ARRAY) all recurse into AMF_Decode/AMF_DecodeArray
    with attacker-controlled nesting; the AMF3 path mirrors it at
    amf.c:601, :787.
  • Reached from rtmp.c:1397/:1420 (HandleInvoke on invoke/command
    packets), rtmp.c:3568 (HandleMetadata) and rtmp.c:4800
    (stream metadata) — i.e. during the handshake and on every media
    packet the server sends.
  • A nested object/array chain costs only a few bytes per level, so a
    1 MB packet (m_nBodySize max 0xFFFFFF) provides hundreds of
    thousands of recursion levels — well past the send thread's stack.

A malicious server (or MITM on plaintext RTMP) crashes OBS by answering
connect with a deeply nested AMF object. Bounds arithmetic elsewhere in
the decoder is fine; this is purely missing recursion depth limiting.

Suggested fix: thread a depth counter through AMF_Decode /
AMFProp_Decode / AMF_DecodeArray / AMF3_Decode / AMF3Prop_Decode
and fail with -1 past a bound (e.g. 128), or decode iteratively.

Activity

  1. chriscoveries commented on Oct 11, 2026

    @chriscoveries
    ContributorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions