Skip to content

bug: obs-ffmpeg: a failed RIST open frees the stream credentials twice #482

Closed

Description

@chriscoveries

Summary

When a RIST stream fails to open, the passphrase, username and password are freed twice, once inside librist_open and again when the caller cleans up. Anyone streaming to a rist:// URL with a passphrase, username or password set can hit heap corruption or a crash on a failed start instead of a clean error. Severity: medium. It needs a failed start, but the result is memory corruption in the main process.

Steps / trigger

  1. Create the ffmpeg_mpegts_muxer output with a service that supplies an encryption passphrase (or a username and password).
  2. Start it with a rist:// URL that makes librist_open fail. Two simple ways: a URL that does not parse, or a URL with aes-type=128 and no secret while the service passphrase is set.
  3. The start fails and both cleanup calls free the same strings. No RIST receiver is needed.

Cause

Line numbers are against current master.

  • plugins/obs-ffmpeg/obs-ffmpeg-rist.h:101-106: librist_close calls bfree on secret, username and password but leaves the pointers set.
  • plugins/obs-ffmpeg/obs-ffmpeg-rist.h:189, :196, :231: librist_open calls librist_close itself on the parse, missing-secret and generic error paths, then returns the error.
  • plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c:355-360: connect_mpegts_url runs its fail: path on that error and calls librist_close(uc) a second time on the same context. The credentials were allocated at :328-340.

The second close frees the three dangling pointers again. This is plugin C code, so it is the same with ENABLE_RUST_LIBOBS OFF and ON.

Proposed fix

Set secret, username and password to NULL right after freeing them in librist_close. The context pointer is already guarded, so after that the function is safe to call twice and the caller's cleanup becomes a no-op for the credentials. The regression test drives the real librist_open and librist_close with the external librist calls replaced, and checks that allocations return to baseline after open and that the three pointers are NULL before the caller's second close.

I'd like to work on this; a fix with a regression test is ready.

Activity

  1. zackees commented on Oct 13, 2026

    @zackees
    Member

    @chriscoveries go ahead: please open the PR with the RED test commit first, then the fix (one PR per issue, targeting master). Marking it claimed for you.

  2. added
    claimed
    on Oct 13, 2026
  3. chriscoveries commented on Oct 14, 2026

    @chriscoveries
    ContributorAuthor

    Releasing this one. We're backed up on CI and won't get it landed soon, so anyone who wants it is welcome to take it.

    If it helps, our RED test and fix are on the fork branch fix/rist-open-failure-cleanup. They passed review on our side but haven't been through CI, so reuse them or start fresh, whichever you prefer.

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