Skip to content

Fix RTMP abort message deleting the chunk stream being parsed - #3452

Open
wwbmmm wants to merge 2 commits into
apache:masterfrom
wwbmmm:fix-rtmp-abort-chunk-stream-uaf
Open

Fix RTMP abort message deleting the chunk stream being parsed#3452
wwbmmm wants to merge 2 commits into
apache:masterfrom
wwbmmm:fix-rtmp-abort-chunk-stream-uaf

Conversation

@wwbmmm

@wwbmmm wwbmmm commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: null

Problem Summary:

An RTMP Abort control message that references the chunk stream carrying
the message itself made the parser free that chunk stream while it was
still being processed. RtmpChunkStream::Feed() continues to access the
freed chunk stream right after OnMessage() returns, which may crash the
server or corrupt memory.

What is changed and the side effects?

Changed:

  • RtmpChunkStream::OnAbortMessage now skips ClearChunkStream when the
    abort targets the chunk stream that is currently being parsed.
  • Added a unit test that feeds a self-referencing Abort message and
    verifies the chunk stream survives.

Side effects:

  • Performance effects: None.

  • Breaking backward compatibility: None.


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a potential use-after-free in the RTMP chunk parser when handling an Abort control message that targets the same chunk stream currently being parsed, and adds a regression test for that scenario.

Changes:

  • Prevent RtmpChunkStream::OnAbortMessage from deleting the currently-parsed chunk stream (this) via ClearChunkStream.
  • Add a unit test that feeds a self-referencing Abort message to exercise the previous crash/UAF path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/brpc/policy/rtmp_protocol.cpp Avoids deleting the active RtmpChunkStream while Feed() is still executing.
test/brpc_rtmp_unittest.cpp Adds a regression test that constructs a self-referencing Abort message and feeds it through RtmpContext::Feed().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/brpc_rtmp_unittest.cpp Outdated
Comment thread test/brpc_rtmp_unittest.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants