Skip to content

fix(studio): a saved WiFi token goes only to the address it was saved for; any other address asks first - #754

Merged
pbertsch merged 3 commits into
mainfrom
fix/saved-token-binding
Nov 17, 2026
Merged

pbertsch merged 3 commits into
mainfrom
fix/saved-token-binding

Conversation

@pbertsch

@pbertsch pbertsch commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

A saved WiFi token was looked up by the device's announced name, and any machine on the network can announce any name. Selecting a look-alike at another local address with the token field blank sent it the saved token (the 10.x/192.168.x check only refuses non-local addresses).

  • SaveWiFiToken binds the token to the address (host and port) of the WiFi connection that has just accepted it (a second keychain item per device).
  • ConnectWiFiSaved sends the token to that address as before. For any other address, and for a token with no address (saved before this change), it asks first, in the window: "Send the saved token?", naming the announced name, the address it would go to and the one the token was saved for. Cancel is focused, Enter does not press the send button, Escape is a no, and the send button is armed after half a second (the clear-data dialog's rules). No answer, no window (the headless bridge cannot answer), a timeout: all a no, and nothing is dialled.
  • A public address is refused before anyone is asked. After a confirmed connection the token is bound to the new address. Forgetting a token forgets its address; a new token with no connection to bind it to drops the old address.
  • The confirmation machinery is generalised (askInWindow, extracted from the clear-data path with no change in behaviour: its existing tests and the browser confirm-dialog specs pass).

Tests and mutants

Go, against a real fake agent: same address connects with no question; a spoofed name at another address is asked about with both addresses, a no dials nothing (the agent saw no ping), a yes connects and binds; no window and an unanswered question are a no; a legacy token asks once and is then bound; forget and replace drop the address; a public address is refused before the question; the question's text is cleaned; address spellings compare equal. 11 mutants killed: never ask, ask for a legacy token never, ask at the bound address, a no ignored, a public address asked about, an approved address not bound, a replaced token keeping the old address, forget keeping it, save not binding, case not folded, no window not a no. Node tests for the dialog copy.

Not run in the real window yet: the dialog itself for this kind (the clear-data one has been, by hand).

Docs

CHANGELOG (Security), Studio docs (Physical devices). The CLI keeps no saved tokens, so the CLI docs are unchanged.

Test plan

  • go test -race ./studio (whole package)
  • npm run test:confirm, test:wifi; browser confirm-dialog specs (10 passed)
  • mutants as above
  • disclosure scan

🤖 Generated with Claude Code

https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF

Review fixes

  • The address that is compared is the address that is dialled: ConnectWiFiSaved normalises the host (no brackets, no trailing dot, no surrounding space, lower case) and dials that, so 127.0.0.1. can no longer compare equal to the bound address yet be resolved as a name.
  • A confirmed connection that fails binds nothing; the bind happens only if the token saved now is still the one this connection used.
  • A token saved with no address is asked about as "saved without an address"; DOM specs cd-11 and cd-12 cover the new dialog kind (focus on Cancel, Enter on Send token does nothing, armed after half a second, Escape a no).
  • Mutants added: the raw host dialled, one round of trimming, no lower-casing, a failed connection binding, no generation check, an approved address never bound: all killed.

… for; any other address asks first

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch requested a review from a team as a code owner November 17, 2026 04:27
pbertsch and others added 2 commits November 16, 2026 22:49
…ith the same token, and word a token with no address as such

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch merged commit 05f1b21 into main Nov 17, 2026
10 of 12 checks passed
jay23606 added a commit to jay23606/flutter-probe that referenced this pull request Nov 17, 2026
… for; any other address asks first (AlphaWaveSystems#754)

## Summary
A saved WiFi token was looked up by the device's announced name, and any machine on the network can announce any name. Selecting a look-alike at another local address with the token field blank sent it the saved token (the 10.x/192.168.x check only refuses non-local addresses).

- `SaveWiFiToken` binds the token to the address (host and port) of the WiFi connection that has just accepted it (a second keychain item per device).
- `ConnectWiFiSaved` sends the token to that address as before. For any other address, and for a token with no address (saved before this change), it asks first, in the window: "Send the saved token?", naming the announced name, the address it would go to and the one the token was saved for. Cancel is focused, Enter does not press the send button, Escape is a no, and the send button is armed after half a second (the clear-data dialog's rules). No answer, no window (the headless bridge cannot answer), a timeout: all a no, and nothing is dialled.
- A public address is refused before anyone is asked. After a confirmed connection the token is bound to the new address. Forgetting a token forgets its address; a new token with no connection to bind it to drops the old address.
- The confirmation machinery is generalised (`askInWindow`, extracted from the clear-data path with no change in behaviour: its existing tests and the browser confirm-dialog specs pass).

## Tests and mutants
Go, against a real fake agent: same address connects with no question; a spoofed name at another address is asked about with both addresses, a no dials nothing (the agent saw no ping), a yes connects and binds; no window and an unanswered question are a no; a legacy token asks once and is then bound; forget and replace drop the address; a public address is refused before the question; the question's text is cleaned; address spellings compare equal. 11 mutants killed: never ask, ask for a legacy token never, ask at the bound address, a no ignored, a public address asked about, an approved address not bound, a replaced token keeping the old address, forget keeping it, save not binding, case not folded, no window not a no. Node tests for the dialog copy.

Not run in the real window yet: the dialog itself for this kind (the clear-data one has been, by hand).

## Docs
CHANGELOG (Security), Studio docs (Physical devices). The CLI keeps no saved tokens, so the CLI docs are unchanged.

## Test plan
- [x] `go test -race ./studio` (whole package)
- [x] `npm run test:confirm`, `test:wifi`; browser confirm-dialog specs (10 passed)
- [x] mutants as above
- [x] disclosure scan



## Review fixes
- The address that is compared is the address that is dialled: `ConnectWiFiSaved` normalises the host (no brackets, no trailing dot, no surrounding space, lower case) and dials that, so `127.0.0.1.` can no longer compare equal to the bound address yet be resolved as a name.
- A confirmed connection that fails binds nothing; the bind happens only if the token saved now is still the one this connection used.
- A token saved with no address is asked about as "saved without an address"; DOM specs cd-11 and cd-12 cover the new dialog kind (focus on Cancel, Enter on Send token does nothing, armed after half a second, Escape a no).
- Mutants added: the raw host dialled, one round of trimming, no lower-casing, a failed connection binding, no generation check, an approved address never bound: all killed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant