Skip to content

feat(pairing): sign in a Roku from the iPhone - #906

Merged
Quick104 merged 1 commit into
mainfrom
feat/roku-companion-sign-in
Oct 25, 2026
Merged

Quick104 merged 1 commit into
mainfrom
feat/roku-companion-sign-in

Conversation

@Quick104

@Quick104 Quick104 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

A new Roku can't be signed in from a phone the way an Apple TV or Android TV can. The Roku client now shows a "Use your phone" card on its server and sign-in screens (Silo-Server/silo-roku#6), but the iPhone never offers to sign it in. The Roku advertises _silopair-roku._tcp instead of _silopair._tcp, and it can't accept TLS. This change lets the iPhone find a Roku, sign it in, and check its code, just as it does for the other TVs.

Approach

  • The pairing browser now browses both _silopair._tcp and _silopair-roku._tcp and shows them in one list. A device listed under both types appears once and keeps TLS.
  • A device found under the Roku type connects over plain TCP. Every other TV still uses TLS-PSK. Only the service type a device was found under decides this; nothing in its TXT record can switch a TV off TLS. The PSK ships in every app, so TLS added no secrecy, and no pairing message carries a token. What stops an impostor is the code check on the phone and the Roku's own consent prompt (silo-roku docs/companion-pairing.md section 2).
  • A Roku keeps one server, so its chooser picks a single server and the phone pushes only that one. The confirm step shows the Roku's code without match words.
  • The approval screen calls a device_platform of roku a Roku.

The messages are the same pairing protocol. Apple TV and Android TV pairing don't change. iOS only; tvOS and macOS don't browse for TVs to pair.

Validation

  • Unit tests (simulator): the pairing coordinator, TV sign-in and offer suites pass on this branch, including new tests for Roku discovery, plain TCP, the single-server push and the single-select chooser.
  • Device: the iPhone found a Roku Ultra on its sign-in screen, approved the code, and the Roku went on to its profile picker. The phone then reported the Roku as signed in.
  • tvOS: the shared code compiles.

Evidence

Surface and build: iPhone, Debug build from this branch, against a Roku Ultra on OS 16.0.4. A Roku appears in the nearby-TV card, the server chooser is single-select, and the copy says "a server". iPad uses the same card. Apple TV and Mac don't show this flow.

Risks

  • The local-network prompt text changes from "your Apple TV" to "your TV".
  • NSBonjourServices gains _silopair-roku._tcp.
  • The plain-TCP connection is limited to devices found under the Roku service type.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

🤖 Generated with Claude Code

Note

Add Roku TV sign-in support to the iPhone pairing flow

  • The app can now discover Roku TVs via a separate Bonjour service type and pair with them. Roku sessions use plain TCP instead of TLS-PSK in PairingSession.swift, while other TVs keep TLS.
  • TVPairingBrowser.swift runs one browser per service type, tags each result with its source type, and merges them. A device found under both types appears once, with the standard record taking precedence. If either browser fails, both are cancelled and restarted together.
  • Roku pairing sends at most one server: CompanionPairingCoordinator.swift truncates the selected list to its first item, and the confirmation screen shows only the user code without match words. The server picker in CompanionPairingCard.swift uses single-select for Roku (re-tapping a row clears it); other TVs keep multi-select.
  • The Roku Bonjour service is declared in Info.plist for local-network permission, and TVApprovalModel.swift labels Roku approval requests as Roku.
  • Behavioral Change: DiscoveredTV carries a new isRoku flag (defaults false), and FramedJSONSession<PairingMessage>.init gains an optional Roku argument; standard TV pairing paths are unchanged.

Macroscope summarized a4ca135.

A Roku on its server or sign-in screen advertises _silopair-roku._tcp and
takes the pairing messages over plain TCP, since Roku sockets have no TLS.
The phone browses both pairing types, lists each device once, dials a Roku
without TLS, pushes it one server (a Roku keeps one), and shows its code
alone on the confirm step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 25, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T03:36:22.172310Z a4ca135 PR opened
🔒 Security Review ✅ Completed 2026-10-25T03:41:10.422567Z a4ca135 PR opened

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 78e097eb-82d4-46bb-883d-0b8916b2ff81
Commits

Reviewing files that changed from the base of the PR and between 9102159 and a4ca135.

Files selected for processing: 9
  • iosApp/Tests/PairingCoordinatorTests.swift
  • iosApp/Tests/TVSignInTests.swift
  • iosApp/iosApp/Info.plist
  • iosApp/iosApp/Pairing/Approver/TVApprovalModel.swift
  • iosApp/iosApp/Pairing/Companion/CompanionPairingCard.swift
  • iosApp/iosApp/Pairing/Companion/CompanionPairingCoordinator.swift
  • iosApp/iosApp/Pairing/Companion/TVPairingBrowser.swift
  • iosApp/iosApp/Pairing/PairingProtocol.swift
  • iosApp/iosApp/Pairing/PairingSession.swift

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

Walkthrough

The iOS app now discovers Roku TVs through a Roku-specific Bonjour service. It identifies Roku devices and applies Roku-specific transport, confirmation, and server-selection behavior during pairing.

Changes: Roku TV pairing

Layer / File(s) Summary
Discover and identify Roku TVs
iosApp/iosApp/Pairing/PairingProtocol.swift, iosApp/iosApp/Pairing/Companion/TVPairingBrowser.swift, iosApp/iosApp/Info.plist, iosApp/Tests/TVSignInTests.swift, iosApp/iosApp/Pairing/Approver/TVApprovalModel.swift
The browser searches the standard and Roku Bonjour services, merges discovered TVs by ID, and marks Roku records. The app allows Roku Bonjour discovery and labels Roku devices as “Roku.”
Apply Roku pairing behavior
iosApp/iosApp/Pairing/PairingSession.swift, iosApp/iosApp/Pairing/Companion/CompanionPairingCoordinator.swift, iosApp/Tests/PairingCoordinatorTests.swift
Roku pairing uses plain TCP, omits match words from the confirmation state, and queues only the first selected server. Tests cover the Roku pairing outcome.
Select a server for Roku
iosApp/iosApp/Pairing/Companion/CompanionPairingCard.swift, iosApp/Tests/PairingCoordinatorTests.swift
The chooser uses singular wording for Roku TVs and supports single-select toggling. Tests cover single- and multi-select behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant RokuTV
  participant TVPairingBrowser
  participant parseAdvertisement
  TVPairingBrowser->>RokuTV: Browse _silopair-roku._tcp
  RokuTV-->>TVPairingBrowser: Service record, TXT record, and endpoint
  TVPairingBrowser->>parseAdvertisement: Parse record with service type
  parseAdvertisement-->>TVPairingBrowser: DiscoveredTV with isRoku flag
  TVPairingBrowser->>TVPairingBrowser: Merge results by device ID
Loading

Suggested labels: enhancement, impact: security, size/M

Suggested reviewers: zzebrahz

Merge Risk: Minimal · up to a4ca1

Roku pairing is ready to merge after normal checks; no actionable issue remains from the reviewed changes.

Security architecture risk: High · up to a4ca1

An attacker able to alter local network traffic during Roku pairing could potentially turn one legitimate confirmation into approval for another device. The new plaintext connection exposes an inherited approval-state weakness; limiting Roku to one server does not prevent this attack.

Retained concerns

  • High · security · inferred: The new plaintext Roku channel exposes an inherited confirmation-reuse weakness. After the user confirms the real Roku's code, an on-path attacker can inject another deviceStarted containing an independent pending request's userCode and matchCode before serverResult concludes the session. The coordinator validates that new pair against the selected server, then automatically approves it because confirmed remains true. It does not require the new request to be the one the user confirmed. Limiting the queue to one server does not enforce one authorization request. Under the documented start/approve/poll contract, this can authorize an attacker's device as the phone's account on that server.
Security review details

Security Blast Radius

  • inferred — The identified authorization attack requires an on-path LAN attacker during an active, user-confirmed pairing session and access to the selected server's device-start endpoint. For Roku, the affected authority is the phone account on that one selected server. The inspected path does not establish exposure to other saved servers, other tenants, infrastructure credentials, or administrative privileges beyond the resulting account session.

Security Findings and Attack Paths

  • inferred — A second injected deviceStarted can carry the attacker's own valid pending request and matching server-issued code. Lookup equality authenticates that new pair, not its relationship to the user's earlier confirmation. The confirmed branch then approves without another comparison. This does not require a match-code collision. The automatic approval logic predates the PR, but the new plaintext Roku connection exposes it without TLS interception.

Trust Boundaries and Controls

  • observed — Initial authorization retains meaningful controls: the first code is shown for explicit comparison, lookup and approval use the locally selected server, and bearer credentials remain in HTTP authorization headers rather than pairing messages. These controls constrain first-request substitution and bearer exfiltration, but do not bind subsequent requests to the first confirmation.
  • observed — Plaintext Roku frames disclose server URLs, optional alternate endpoints, and user/match codes to a party able to observe the connection. The existing design explicitly describes TLS-PSK as opportunistic confidentiality, not peer authentication; a public PSK does not make plaintext equivalent to encrypted transport.

Resilience and Maintainability Implications

  • observed — Terminal guards reject late inbound messages and prevent some post-await state publication. Cancellation nevertheless does not recheck concluded after bearer acquisition before approval. This cancellation gap is also present in the base; no separate material worsening beyond entry from the new platform was established.

Hardening Proposals

  • proposed — Bind confirmation to an immutable server-and-request identity. For single-server Roku pairing, reject a different deviceStarted after confirmation and make repetition of the confirmed request idempotent. Revalidate session activity and request identity after suspended credential acquisition and before the approval call.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the Roku iPhone pairing changes, implementation approach, validation, risks, and user-visible behavior.
Title check Passed The title clearly and concisely summarizes the main change: adding Roku sign-in support from the iPhone.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 8 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes priority: P2 Limited scope, workaround exists, or polish labels Oct 25, 2026
@silo-triage

silo-triage Bot commented Oct 25, 2026

Copy link
Copy Markdown

The Evidence section describes the new flow but includes no captures or artifact link. Please attach or publish before-and-after captures of the nearby-TV card, single-server chooser and Roku code-confirmation screen on the affected iPhone, iPad and iPhone Duo layouts (folded/open), or explain any unaffected device. Include a short recording for the multi-step pairing flow. The stated Mac and Apple TV exclusions are clear.

@macroscopeapp

macroscopeapp Bot commented Oct 25, 2026

Copy link
Copy Markdown

The Evidence section describes a device run but includes no screenshots, recording, or evidence link.

  • Roku discovery and companion pairing, including the single-server chooser (TVPairingBrowser.swift, CompanionPairingCard.swift): missing same-screen before/after captures and a recording of the multi-step flow for iPhone, iPhone Duo folded and open, and iPad.
  • Local Network permission prompt copy (Info.plist): missing before/after captures for iPhone, iPhone Duo folded and open, and iPad.
  • Roku platform label in the TV approval card (TVApprovalModel.swift): missing before/after captures for iPhone, iPhone Duo folded and open, and iPad.

Please identify the build or commit for each capture and label the iPhone Duo captures as folded or open.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@coderabbitai coderabbitai Bot added impact: security Auth, privacy, or permission boundary size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Oct 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: a4ca135abb

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

/// this gives up nothing: no pairing message carries a token, and the
/// code the person compares is what stops an impostor.
static func parameters(isRoku: Bool) -> NWParameters {
isRoku ? NWParameters(tls: nil, tcp: NWProtocolTCP.Options()) : tlsParameters()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

P1 Badge Security: Authenticate the Roku pairing transport

When a user sets up a Roku while an attacker can proxy its LAN traffic, this raw-TCP path lets the proxy replace the pushed Silo URL with a fake server, start its own device request at the real server, and make the Roku display that request's user/match codes. The phone then approves those legitimate codes, so the comparison passes, while the attacker polls with the retained device code and receives the user's access/refresh tokens. Authenticate and integrity-protect the Roku channel (for example, with a displayed-code PAKE) before sending server details; the current post-start code check does not bind the receiver.

Useful? React with 👍 / 👎.

@silo-triage silo-triage Bot removed the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 25, 2026
@Quick104
Quick104 merged commit a70b255 into main Oct 25, 2026
9 of 10 checks passed
@Quick104
Quick104 deleted the feat/roku-companion-sign-in branch October 25, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: security Auth, privacy, or permission boundary priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant