fix(security): bound publish/play AMF waits with wall-clock deadline#145
Merged
Merged
Conversation
Client::publish() and Client::play() passed None as the I/O deadline, so a malicious server could stall the caller for up to ~650 seconds (64 recv polls × 10s) after connect succeeded. Reuse the configured connect_timeout budget for these blocking AMF exchanges and add a regression test. Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
AlexanderWagnerDev
marked this pull request as ready for review
July 19, 2026 15:53
Contributor
Author
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_702b6dcf-faf4-4ec1-b722-1745f9a2a205) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security review fix
Fixes #144
Finding (Medium)
Location:
src/client/mod.rsImpact: A malicious RTMP server that completes
connect+createStreambut withholdsonStatusduringpublish()orplay()could block the embedder's calling thread for up to ~650 seconds (64 recv polls × 10sRECV_POLL_TIMEOUT_MS, plus up to 10s on send).Root cause
do_amf_connect()threads a wall-clock deadline through its AMF exchanges, butpublish()andplay()passedNone, sowait_for_command()fell back to unbounded per-poll 10s waits.Fix
command_io_deadline()that reuses the configuredconnect_timeout(default 10s).Some(deadline)frompublish()andplay()intosend_command_msg()andwait_for_command().publish_and_play_honor_command_io_deadline.Remediation leverage
Single helper + two call-site changes; no API break.
set_connect_timeout()now also governs publish/play blocking I/O, matching the existing comment that recv budgets apply during those phases.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Touches blocking client I/O and timeout behavior on publish/play; low API surface but security-relevant thread-blocking fix.
Overview
Fixes a denial-of-service path where a server that stalls after
createStreamcould keeppublish()orplay()blocked for many minutes because those paths waited foronStatuswith no overall deadline.publish()andplay()now compute a wall-clock deadline via newcommand_io_deadline(), reusing the existingconnect_timeout/ default 10s budget, and pass it intosend_command_msg()andwait_for_command()—matching whatdo_amf_connect()already did. Docs onconnect_timeoutandset_connect_timeout()are updated to state that this budget applies to blocking I/O inconnect(),publish(), andplay().A regression test asserts both methods return
ErrorCode::Timeoutnear the configured deadline when the peer sends nothing.Reviewed by Cursor Bugbot for commit 86c1b11. Bugbot is set up for automated code reviews on this repo. Configure here.