Security: cap E-RTMP multitrack sub-track count (fixes #131)#132
Conversation
Reject multitrack containers with more than 4096 sub-tracks, matching the existing aggregate sub-tag cap. A single 4 MiB message could otherwise encode ~1M zero-byte tracks and force millions of callback iterations per poll tick. Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds a 4096-sub-track cap to multitrack parsing and verifies successful parsing at the limit plus rejection with no callbacks when the limit is exceeded. ChangesMultitrack parser limit
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e43436364f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if tracks.len() >= MAX_MULTITRACK_SUBTRACKS { | ||
| return false; |
There was a problem hiding this comment.
Don't report over-limit multitrack as ordinary media
When a publisher sends a multitrack container with more than 4096 subtracks, this new branch makes foreach_track return false, but callers such as Conn::handle_media_message and Client::deliver_av_frame_cb interpret false as “not multitrack” and then invoke the normal single-frame callback/relay path. That means the over-limit packet is not actually rejected at the session/client layer; it is reclassified as an opaque ordinary media frame. Please return a distinguishable parse error/drop signal, or have callers avoid the fallback when is_multitrack_container(...) was true.
Useful? React with 👍 / 👎.
Security fix
Fixes #131
Finding
Severity: Medium (CPU exhaustion / poll-loop DoS)
Location:
src/ertmp/multitrack_media.rsProblem
foreach_trackparsed an unbounded number of sub-tracks from a single E-RTMP multitrack A/V message. A 4 MiB ManyTracks container can encode ~1,048,574 zero-byte sub-tracks, each triggeringon_frame_cband intermediateVecallocations. Nested inside aggregate messages (4096 sub-tag cap), amplification multiplies further.Fix
MAX_MULTITRACK_SUBTRACKS = 4096(matching the existing aggregate sub-tag cap).rejects_multitrack_messages_with_too_many_subtracks.Verification
cargo test --no-default-features multitrack— all 21 multitrack-related tests pass.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit