Skip to content

[crash] obs-websocket: deeply nested JSON/MsgPack payload overflows the stack pre-auth #99

Closed
obs-rust/obs-websocket
#2

Description

@chriscoveries

Any client that can complete the WebSocket handshake (no obs-websocket auth
needed — parsing happens before the op-code/session checks) can crash OBS
with a stack overflow by sending a deeply nested JSON or MsgPack message.

Trace:

  • plugins/obs-websocket/src/websocketserver/WebSocketServer.cpp:379
    incomingMessage = json::parse(payload); and :394
    json::from_msgpack(payload) run on the raw frame payload inside the
    QThreadPool runnable, before IsIdentified() / op validation
    (ProcessMessage is only called at :436).
  • nlohmann::json 3.11.3 (bundled via obs-deps) parses containers by
    recursive-descent sax_parse: every [/{ costs one C++ stack frame.
    A payload of e.g. 1–4 MB of [ characters yields hundreds of thousands
    of nesting levels — far beyond a worker-thread stack (~512 KB–8 MB).
  • The only catch is json::parse_error; a stack overflow is not an
    exception — the thread (and process) dies.

Reproducer sketch: connect to the obs-websocket port, send a text frame
consisting of "[" repeated ~500k times followed by matching ]
(websocketpp's default max message size permits it). OBS aborts with a
stack overflow / SIGSEGV in the parser.

Suggested fix: cap message size and/or pre-scan nesting depth before
json::parse (or iterate with a depth counter and reject past a bound
such as 512 levels). Same bound applies to from_msgpack, whose
container parsing also recurses per nesting level.

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. The websocket JSON/MsgPack depth fix is still in progress on our side.

  2. zackees commented on Oct 13, 2026

    @zackees
    Member

    Claiming: pre-auth JSON/MsgPack nesting crash. Plan: (1) add a black-box regression for over-deep frames against the C++ server and verify RED; (2) bound frame size and container depth before nlohmann parsing for text and binary; (3) verify GREEN with the full Tier 4 suite, run the required local gate, and open a PR targeting master. Expected first PR: today.

  3. added
    claimed
    on Oct 13, 2026
  4. zackees commented on Oct 13, 2026

    @zackees
    Member

    Fixed in #477 (merge ba4922b) using the bounded JSON/MsgPack parser from obs-rust/obs-websocket#2. The RED Tier 4 case sent an over-deep valid JSON envelope that the original in-tree plugin failed to reject with 4002; the built fixed app returns 4002 for both JSON and MsgPack and remains alive. Lint, unit suite, symbol parity, and stamped local gate passed. A separate intermittent full Tier 4 crash also reproduces with the original plugin and is tracked in #476.

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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions