Repository navigation
Conversation
The server sends LeaveRequest.regions before it asks the client to reconnect, and the JS SDK already uses them. The signal task now stores them in the region cache under the project host. SignalInner keeps that project URL, because after a region failover its own URL is the region URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 2 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| let urls: Vec<String> = settings | ||
| .regions | ||
| .iter() | ||
| .filter(|region| !region.url.is_empty()) | ||
| .map(|region| region.url.clone()) | ||
| .collect(); | ||
| if is_cloud_host(&host) && !urls.is_empty() { | ||
| region_cache().insert(host, urls, None); |
There was a problem hiding this comment.
🟥 Plaintext region overrides poison secure failover
When region_url uses plaintext, set_server_regions still trusts its leave hints if the project URL uses TLS. An on-path attacker can redirect later secure failover and receive another session’s token.
Was this helpful? React with 👍 or 👎 to provide feedback.
The region cache is keyed by host. A region list planted on a plaintext ws:// session would reach a later wss:// connect to the same host, which sends its token to the first region it dials. set_server_regions now ignores a session that is not wss, and keeps only wss region URLs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full reconnect passed SignalClient::url to the new session. After a region failover, that is the region URL, so the new session keyed its region lookup by the region host. It never saw the regions cached under the project host, from a leave or a refresh. SignalOptions::region_url lets SignalClient::connect dial a region while the project URL keys the region list, and SignalClient::project_url returns that URL. A full reconnect now connects with the project URL and dials the region the session ran in first. When that region fails, it is marked failed and the failover skips it, as in the JS SDK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changeset ✓This PR includes a changeset covering all affected packages:
|
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| if !url.starts_with("wss://") { | ||
| return; | ||
| } |
There was a problem hiding this comment.
🟡 HTTPS joins discard leave regions
When a room joins through an https:// URL, set_server_regions discards the leave’s region list despite the secure WebSocket. Reconnect falls back to an older list or fetches one again.
Learn more
get_livekit_url converts an HTTPS join URL to a secure WebSocket URL before opening signaling. signal_task passes the original project URL to the cache when a server asks the client to leave, so the prefix check rejects that secure session. SignalClient::connect then looks up the project’s cached list during the full reconnect.
Example: Join https://my-project.livekit.cloud, then receive a leave naming region B. The SDK discards the list, so reconnect cannot use that hint and must rely on an older entry or fetch the list.
Recommended fix: Keep the project URL as the cache key, but pass the actual signaling endpoint separately and check its normalized scheme for TLS. Add a regression test for a secure join made through an HTTPS project URL.
Was this helpful? React with 👍 or 👎 to provide feedback.
The server sends its region list in
LeaveRequest.regionsbefore it asks the client to reconnect. The JS SDK puts that list in its region cache. The Rust SDK dropped it, so the reconnect that follows had to fetch the list again before a failover.A full reconnect could not have used the list anyway. It passed
SignalClient::urlto the new session, which is the region URL after a region failover, so the new session looked up regions under the region host.Change
signal_taskstoresLeaveRequest.regionsin the region cache, with the default 5 s TTL as in JS, keyed by the host of the URL that the caller connected with.SignalInnerkeeps that project URL next to the URL it dialed.wsssession is trusted, and only itswssregion URLs. The cache is keyed by host, so a list planted on a plaintextwssession would reach a laterwssconnect to the same host, which sends its token to the region it dials.SignalOptions::region_url:connectdials that region instead of itsurl, while theurlkeys the region list. A failed region is marked failed, and the failover skips it.SignalClient::project_urlreturns theurlpassed toconnect. The doc comment ofSignalClient::urlnow says that it is the URL the session dialed.Verified
cargo test -p livekit-signaling: 62 tests pass.cargo check -p livekit -p livekit-ffi --testspasses.leave_regions_reach_the_region_cache: the signal task gets one leave with a region list, and a fetch without a token, which the mock answers with a 401, still returns the list. Without the change, the test fails with the 401.server_regions_need_tls: awssession adds nothing, and awsssession adds only itswssURLs.connect_dials_the_region_url_first: the region is dialed, the project URL is not, and the failover dials the project's regions.reconnect_taskhas no test of its own: a full reconnect needs a WebRTC session.🤖 Generated with Claude Code