Skip to content

Gate dynamic pairing on a pairing window - #361

Merged
arturpragacz merged 6 commits into
mainfrom
ap/gate-dynamic-pairing-emission
Nov 20, 2026
Merged

arturpragacz merged 6 commits into
mainfrom
ap/gate-dynamic-pairing-emission

Conversation

@arturpragacz

Copy link
Copy Markdown
Contributor

Gate dynamic pairing on a pairing window.

A man in the middle can pair with the server under a client's name, then drive the real client's display or speaker through a role so it shows or speaks the attacker's code. The operator reads it off the device and the server pairs with the attacker. Our pairing protections do not help: the client never enters pairing and the code is never generated on it.

Changes to the pairing section:

  • Every dynamic attempt is gesture-gated by a pairing window, which becomes a shared section for both code flows.
  • While a window is open, or an attempt it gates runs, the client holds all server-driven output and emits only pairing state. A window closes only on success, an operator gesture, or expiry; failed attempts exhaust it but never close it, so nothing a server does releases the outputs.
  • The round limit is folded into the window: 20 failed rounds per window, no cooldown or cross-window count.
  • The server must tell the operator to trigger pairing on the device before reading the code, since it cannot tell whether its peer is that device.

No wire changes.

A man in the middle between server and client can pair with the server
under the client's name, then drive the client's display or speaker
through a role so it shows or speaks the attacker's pairing code as
artwork or audio. The operator reads it off the client, enters it into
the server, and the server pairs with the attacker. Commit-and-reveal
binding does not help: the code is never generated on the client.

The client must now emit the code only where no server can forge it:
through an out-channel no server can drive, or through a shared one
only during an attempt gated by a pairing window. While the window is
open the client suspends all server-driven output on that channel and
shows only pairing state. The window closes solely on a completed
pairing, an operator gesture on the client, or expiry; nothing a
server sends, including an abort or a dropped connection, releases it.

Pairing Window becomes a shared section covering both code flows

@maximmaxim345 maximmaxim345 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kahrendt @chrisuthe what do you think about this? I'm a bit split on this one. The attack is possible before this PR and this PR closes that gap, but IMO it also impacts the user experience around pairing in a substantial way since every dynamic pairing now needs a gesture on the client first, and the client stops all playback while the window is open.
Pairing is already a pain point and the attack needs quite a setup, so I'm leaning more toward the user experience side.
Artur and I were already thinking about how to solve this without a UX trade-off, but we couldn't come up with anything else (except for my idea of only requiring the gesture with unpaired access enabled). I'd like to hear your thoughts and ideas on this.

No matter if we go with this, I think the sendspin-cpp-cli installer should also ask the user if they want unpaired access enabled (I'd even default to enabled), and with this PR even more so, since every pairing then needs a sendspin-cli pair confirm on the player's host.

From the technical side, I'm also not sure if this is (easily) possible to implement in sendspin-python-cli, but that client is more or less deprecated, so this should not sway the decision.

Comment thread pairing.md Resolved
Comment thread pairing.md
- **Window lifetime.** From window opening, without pausing during attempts. Recommended 5 minutes. On expiry, the window closes silently. An attempt already in progress runs to its own end, but starting another requires a new pairing window.
- **Signal to the server.** The client sends [`client/pair-init`](#client--server-clientpair-init) once the window is open and the [`server/activate`](messaging.md#server--client-serveractivate) has arrived; while a gesture is awaited it signals [`client/pair-pending`](#client--server-clientpair-pending), optionally naming the gesture in `message`. The server MUST NOT send [`server/pair-auth`](#server--client-serverpair-auth) until it has received `client/pair-init`.
- **Signal to the server.** The client sends [`client/pair-init`](#client--server-clientpair-init) once the window is open and the [`server/activate`](messaging.md#server--client-serveractivate) has arrived; while a gesture is awaited it signals [`client/pair-pending`](#client--server-clientpair-pending), optionally naming the gesture in `message`. The server MUST NOT send [`server/pair-auth`](#server--client-serverpair-auth) or [`server/pair-init`](#server--client-serverpair-init) until it has received `client/pair-init`.
- **Out-channel hold.** A client that offers `dynamic_pairing_code` MUST suspend all server-driven output, not only on the emitting out-channel, while a window is open or an attempt it gates is in progress, emitting nothing but pairing state: the code during a dynamic attempt, otherwise its pairing state, such as that it is waiting (see [Forged emission](#dynamic-pairing-code-flow)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a user perspective this has the potential to feel broken: after a pairing that was cancelled or failed, the speaker stays silent until the window expires or the operator cancels it on the device. I understand why a server can't release it if we want to close this, but that can be up to 5 minutes of silence after pressing cancel in the server.

@arturpragacz arturpragacz Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the client has a screen, then it keeps showing that it's in pairing mode on there; if it has a speaker, then it can say something like "Currently pairing"; if it has some LEDs, it can flash them a distinct colour, etc.

In any case I think that's an implementation detail, so should go to the implementation guide?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only lever that we have here is the timeout and I feel that 5 minutes is already on the short side. It's only a recommendation though, so a client can still pick a shorter one.

@arturpragacz

arturpragacz commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

I see the UX cost, but I don't think we can trade against this one, because the attack is fundamental. It completely breaks dynamic pairing: the server passes every check and still ends up paired with the attacker.

the attack needs quite a setup

Not from a security perspective. The attacker only needs a device on the same network while someone is pairing: it advertises a client with the same name over mDNS and connects to the real device as a server. That's the same attacker the rest of our pairing was designed to defend against.

my idea of only requiring the gesture with unpaired access enabled

I don't think that works, for two reasons. First, the attack doesn't actually need unpaired access: a paired server can do the same thing, and a paired server should never be able to impersonate the client to another server (although that's obviously much less impactful in practice). Second, the server couldn't tell when to ask for the gesture, because it only learns that setting from its peer, which in this case is the attacker.

every pairing then needs a sendspin-cli pair confirm on the player's host

I might be missing something here, but don't you already have to run a command on the host to read the code? So pair confirm could just open the window and print the code, replacing the status step instead of adding one.

@arturpragacz

Copy link
Copy Markdown
Contributor Author

We discussed it as a team and determined the PR is OK to proceed, so I'm going to merge.

@arturpragacz
arturpragacz merged commit 2cfe197 into main Nov 20, 2026
1 check passed
@arturpragacz
arturpragacz deleted the ap/gate-dynamic-pairing-emission branch November 20, 2026 14:03
@github-project-automation github-project-automation Bot moved this from Next to Done in Sendspin Project Board Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants