shouldRejectMessage() lets every *.unsubscribe frame through, member or not,
and processFullMessage() then handed the frame's channel to
authenticateConnection(). On a connection's first full auth (the first
non-ping frame, the frame after a refused subscribe, any frame after
C:RESET) loadCachedAuth() and ensureUserIsSet() called saveConnection(), so
{"event":"websocket.unsubscribe","channel":"private-x"} put the socket on
private-x, private-encrypted-x or presence-x and it received the channel's
broadcasts. A later unsigned subscribe found hasConnection() true, skipped
the signature check and tracked the socket. The same frame also undid a
legitimate unsubscribe from a public channel.
- processFullMessage() notes whether the socket is on the channel before the
auth step and takes it off again (Channel::removeConnection(), no leave
events) if the auth step added it. This also covers consumer overrides
that call saveConnection() themselves. The channel is still passed in:
some overrides call $channel->saveConnection() without a null check.
- loadCachedAuth() and ensureUserIsSet() only refresh a stored connection,
they never add one.
- handleSubscription() checks the signature of a socket that is on a
private/presence channel without being tracked there (saved by a hook)
and refuses it on a mismatch. PrivateChannel::verifySubscription() is the
new public wrapper around verifySignature(). Tracked members still get a
no-op on a repeated subscribe.
Tests cover an unsubscribe as the first frame, after a refused subscribe,
after an auth reset and through an override that saves the connection
unconditionally, for private-, private-encrypted- and presence-, each
followed by an unsigned subscribe that must be refused; the public-channel
unsubscribe; and the saved-but-untracked socket with and without a
signature.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>