fix(player): accept clock-sync pongs only from the host (#1850)
Every authoritative message a guest acts on is gated on the relay-stamped `senderId` matching `_session.hostPeerId` — room state, `hostExitedPlayer` — except `pong`, which `_handleMessage` fed to `ClockSync` on nothing more than "I am a guest and this pingId is one I am waiting for". That matters because the guest's clock, not just the state it receives, is part of the trust boundary. A guest estimates the host's clock offset from the round trip: it sends `ping` at its own local time, the host answers `pong` stamped with the host clock, and the guest takes the midpoint as the one-way delay. Every anchor the host publishes — `anchorHostTimeMs` on a state, a scheduled synchronized start — is translated into local time through that offset, so a wrong offset silently shifts the target position `GuestPlaybackReconciler` computes from otherwise authentic state. Past the 2000 ms hard-seek threshold the guest seeks, then keeps mistranslating the corrections that follow, while the host and every other guest stay fine. Any peer in the room could therefore reply to another guest's ping. This is a weak primitive rather than playback takeover: the forged pong has to name a `pingId` that is currently outstanding and land inside its RTT window, and `ClockSync` discards samples over a second. But the relay already stamps the sender on every inbound message, so the check costs one conjunct. Verified: full suite green (5788 tests, 5 skipped), 186 of them under test/watch_together, plus dart format and analyzer parity.
This commit is contained in:
@@ -354,7 +354,7 @@ class WatchTogetherController {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SyncMessageType.pong:
|
case SyncMessageType.pong:
|
||||||
if (message.pingId != null && !_session.isHost) {
|
if (!_session.isHost && senderId == _session.hostPeerId && message.pingId != null) {
|
||||||
_clockSync?.onPong(message.pingId!, message.timestamp);
|
_clockSync?.onPong(message.pingId!, message.timestamp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user