Skip to content

feat(devices): list what protects the server in Phone & devices - #1975

Merged
devswha merged 1 commit into
mainfrom
feat/device-security-summary
Oct 26, 2026
Merged

devswha merged 1 commit into
mainfrom
feat/device-security-summary

Conversation

@devswha

@devswha devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Closes #1604.

What it does

Settings → Phone & devices gets a read-only Access group after Devices. It lists, one fact per row, what protects this server:

  • Access token: Set / Not set (its value is never shown)
  • Pairing gate: Not yet closed / Closed / Unavailable (devices.json unreadable, which keeps it closed)
  • Listens on: Loopback / Tailscale address / Other address, read from the configured bind literal
  • This connection: No proxy seen / Through a proxy / Through Tailscale / Through Tailscale Funnel / Unknown, for this request only
  • Public internet: Reachable only when this request came through Tailscale Funnel, otherwise Unknown

Nothing on the screen calls the setup safe, secure or local only, and LanExposureNotice is unchanged. Before the answer arrives the group shows Loading; a failed check and an older server that sends no facts each get one sentence, and neither shows an earlier answer.

Why

Settings couldn't tell you how the bridge is reachable. Agent of Empires' security page prompted this, but its summary calls a loopback bind "local only", which nothing here can prove: a proxy, tunnel or router in front can expose any bind. Neither the Codex nor the Claude app shows such a summary, so there is no app pattern to follow (DESIGN.md says so in the entry).

Contract (needs a real review: HTTP contract + access facts)

  • GET /api/health (full and ?scope=bridge) carries an optional security: SecuritySummary (shared/access.ts) only for authenticated full access, a watching device included, sent Cache-Control: no-store. The bridge scope answers it without herdr. Anonymous answers (no auth, wrong token, forged Funnel headers) carry no facts.
  • It holds no token, hash, header, login or address. Authorization (decideAccess) is unchanged; lanExposed keeps its results (its bind check is now bindScope).
  • Tailscale and Funnel are labelled only on an install that declared serve its only ingress (OVIS_TAILSCALE_SERVE_ONLY), from loopback, while Tailscale runs here. Tailscale-shaped headers alone are unknown; other forwarding is proxy.
  • direct means no proxy said it forwarded the request. A proxy that adds nothing (nginx's bare proxy_pass, an SSH tunnel) looks the same, so the UI shows it as No proxy seen with a line saying so, never as "Direct".
  • Client: useAccessState lets the newest read to settle decide the facts. An older answer landing after a newer failure shows nothing, and a failure clears the facts even while a newer read is still out.

Verification

  • server/access.test.ts (bind aliases, tailnet literals, wildcard/other binds, verified/unverified ingress, lanExposed unchanged): 48 pass.
  • server/api.contract.test.ts "access facts on /api/health": 7 cases on isolated servers (authenticated facts only, anonymous omits them, watch reads but can't change devices, corrupt registry is unavailable and gated, auth via is not ingress, an unknown proxy never means local only, bridge health without herdr).
  • src/lib/useAccess.hook.test.ts: overlapping reads. The "failure while a newer read is out" case failed before the fix.
  • scripts/security-summary-demo-regression.ts at 390 and 1440 px (enrolled in the browser lane): known, unknown, proxy, gated, funnel, tailnet, unavailable, watch, older-server, loading and error answers; no controls in the group; no verdict wording; LAN warning unchanged; a held older answer released after a failure shows no facts.
  • Live: a throwaway server on the Tailscale address with a fictional token and no herdr. curl -i /api/health?scope=bridge anonymous → no security; with the token → the five facts + Cache-Control: no-store; Tailscale-shaped and Funnel headers → unknown; X-Forwarded-For → proxy; the token appears nowhere in a response.
  • bun run check fast on the final commit: ok (workflow syntax, generated types/themes, typecheck, build; unit 7200 pass, 0 fail).
  • Reviews: omo-native-code-reviewer, Codex (gpt-6.1-sol) and gpt-6-astra. Fixed: overlapping-read stale facts, the misleading "Direct" label, the SecurityFacts type moved from a component into src/lib, a stale env name in a comment, a DESIGN.md font token. Declined, with reasons: requiring an owner login for Funnel on a tagged node (a tagged node is "Tailscale runs here"; the owner adds nothing to whether serve carried the request); unknown for unforwarded requests (it would apply to every headerless peer, so direct would never be produced; the relabel says exactly what is observed).

Note: an earlier local run failed server/legacy-env.test.ts on clean main too, from this host's inotify limit (#1968); it passed in the final run, and this PR does not touch it.

Settings > Phone & devices gains a read-only Access group: whether an
access token is configured, the durable pairing gate (open, closed, or
unavailable when devices.json cannot be read), the kind of address the
server listens on, and how this one request arrived. Public reachability
stays "Unknown" unless the request came through Tailscale Funnel on an
install that declared serve its only ingress. Nothing reads as a safety
verdict, and the open-LAN warning is unchanged.

/api/health (both scopes) carries an optional SecuritySummary
(shared/access.ts) only for authenticated full access, a watching device
included, sent no-store and without herdr. It holds no token, hash,
header, login or address. Anonymous answers omit it; an older server
that sends none is shown as unavailable, never rebuilt from auth or the
LAN warning. Tailscale and Funnel are labelled only with that provenance;
Tailscale-shaped headers alone are "unknown", other forwarding is
"proxy". A request no proxy said it forwarded is shown as "No proxy
seen" with a line saying a proxy that adds nothing looks the same.

useAccessState keeps the facts: the newest read to settle decides them,
so an older answer landing after a newer failure shows nothing, and a
failure clears the facts even while a newer read is still out.

Checked with server/access.test.ts, seven api.contract.test.ts cases on
an isolated herdr, src/lib/useAccess.hook.test.ts (the overlapping-read
case failed before the fix), and scripts/security-summary-demo-regression.ts
at 390 and 1440 px over known, unknown, proxy, gated, funnel, tailnet,
unavailable, watch, older, loading and error answers.

Closes #1604
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7ab4bde and 0dea204.

Files selected for processing: 27
  • DESIGN.md
  • changelog.d/device-security-summary.md
  • scripts/ci-browser.sh
  • scripts/security-summary-demo-regression.ts
  • server/access.test.ts
  • server/access.ts
  • server/api.contract.test.ts
  • server/index.ts
  • shared/access.ts
  • shared/machines.ts
  • shared/protocol.ts
  • site/demo/transport.ts
  • src/App.tsx
  • src/components/SettingsDialog.css
  • src/components/SettingsDialog.tsx
  • src/lib/api.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/i18n/devices.ja.ts
  • src/lib/i18n/devices.ko.ts
  • src/lib/i18n/devices.zh.ts
  • src/lib/i18n/settings.ja.ts
  • src/lib/i18n/settings.ko.ts
  • src/lib/i18n/settings.zh.ts
  • src/lib/useAccess.hook.test.ts
  • src/lib/useAccess.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit's review was rate-limited ("Review limit reached"), so no CodeRabbit review has run on this PR. This change touches an HTTP contract and access facts, so here are the reviews that ran on it before the push, with how each finding was resolved. Reviewers: omo-native-code-reviewer (Claude), Codex gpt-6.1-sol (xhigh), Codex gpt-6-astra.

HIGH, raised by all three: an unforwarded request was shown as "Direct" (server/access.ts observedIngress). A proxy that adds no header (nginx's bare proxy_pass rewriting Host to the loopback address, an SSH tunnel) looks exactly like a direct request.
Resolved: the UI no longer says "Direct". The value reads No proxy seen, with the line "No proxy said it forwarded this browser's request. One that adds nothing, such as an SSH tunnel, looks the same." The wire value stays direct, now documented in shared/access.ts as "no proxy said it forwarded the request". Declined: Sol's and Astra's alternative of returning unknown. The same ambiguity applies to every peer without headers, including a LAN proxy_pass, so direct would never be produced and the row would lose its information. The relabel states exactly what the server observed. Public internet stays "Unknown" in every one of these cases.

HIGH, Sol and Astra: a failed check could leave stale facts on screen (src/lib/useAccess.ts). Sequence: facts shown, read B starts, read C starts, B fails while C is still pending. B's failure was ignored because B was no longer the newest read started.
Resolved: the newest read to settle now decides. A failure clears the facts even while a newer read is out, and an older answer cannot overwrite a newer settled result. src/lib/useAccess.hook.test.ts covers both orders plus the older-server case; the overlapping-failure case failed on the old hook before the fix.

HIGH, Sol: a tagged node without an owner earns the Funnel label. Declined. Funnel and Tailscale are labelled only on an install that declared serve its only ingress (OVIS_TAILSCALE_SERVE_ONLY), from loopback, while Tailscale runs on this PC. A tagged node is that last condition: Tailscale runs here and names no person. An owner login says nothing about whether serve carried the request, so requiring it would hide true Funnel facts on tagged PCs without making any label more reliable. Forged headers on a non-serve-only install stay unknown (contract test "unknown proxy never means local only").

MEDIUM (code reviewer): SecurityFacts was imported by a src/lib hook from a component. Fixed: the type now lives in src/lib/useAccess.ts. Separately, the screenshot matrix in the demo script runs only with UI_EVIDENCE_DIR. Kept: 87 browser scripts use that same opt-in capture pattern.

LOW (code reviewer):

  • Fixed a stale HERDR_WEB_TAILSCALE_SERVE_ONLY in a comment; it is now OVIS_TAILSCALE_SERVE_ONLY.
  • Fixed a DESIGN.md font token (--fs-md).
  • Kept: a signed-out client would read "does not report". It cannot reach Settings, because the access gate replaces the shell.
  • Kept: generic i18n keys, since the English string is the key throughout the repo.

After the fixes: bun run check fast green, with unit 7200 pass and 0 fail. The demo regression passes at 390 and 1440. The "access facts on /api/health" contract cases (7) and server/access.test.ts (48) pass.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review report. Overall: PASSED. This PR touches the access/authentication surface and an HTTP contract (shared/protocol.ts, shared/access.ts, server/index.ts). An Astra gate (omo-native-gate-reviewer, gpt-6-astra) approved 0dea204, with no confirmed failure in secrecy, authorization, accuracy or compatibility.

Tests and visual checks (all reproduced independently by Astra):

  • 51 access/hook tests and 7 HTTP contract tests pass, and TypeScript is clean.
  • The browser regression passes at 390 and 1440 px.
  • Desktop and mobile captures were inspected.

What the Access group shows:

  • One fact per row: access token Set / Not set, pairing gate, listen address, this connection, and public internet.
  • The token's value is never shown.
  • An unreadable devices.json keeps the gate closed and shows Unavailable.
  • Nothing calls the setup safe or local only, and LanExposureNotice is unchanged.

Contract: BridgeHealth gains an optional security, sent only on authenticated requests. An older server that sends no facts gets one sentence instead.

Not covered: live Tailscale Funnel and older remote bundles were checked by reading the code, not run. CodeRabbit was rate-limited, so the agent review stands in for it, as AGENTS.md allows.

git merge-tree against main is clean. Locally, 51/51 pass and typecheck is clean. This PR conflicts with #1977 (6 files). Whichever of the two merges second needs a rebase. It merges only after the 0.4.18 Release run, because it touches server/ and shared/.

@devswha
devswha merged commit 8121a73 into main Oct 26, 2026
19 checks passed
@devswha
devswha deleted the feat/device-security-summary branch October 26, 2026 11:29
devswha pushed a commit that referenced this pull request Oct 26, 2026
…summary

#1975 shows the Phone & devices access facts with the demo's
/api/devices left a 404 by design, and its browser regression stubs the
list itself. The demo now answers its device routes (list, pairing,
revoke-all, rename and revoke) only with ?demo_devices=; `list` is the
fictional devices, and the other values are the lane's states as before.
Without it the demo has no device list, as before this branch.

The device-security regression asks for `list` where it named no state.
Its phone press on Revoke all scrolls the row into view first, since the
access facts now sit below Devices and the scrolled-end frame passes it.
Its 44 px touch-target check allows a 0.01 px layout remainder (a 44 px
box measured 43.99999 below the new group).

Checked with both demo regressions (device-security at 390 and 1440,
light, dark and Korean; security-summary at 390 and 1440) and the
conventions and ci-browser tests.
devswha pushed a commit that referenced this pull request Oct 26, 2026
…summary

#1975 shows the Phone & devices access facts with the demo's
/api/devices left a 404 by design, and its browser regression stubs the
list itself. The demo now answers its device routes (list, pairing,
revoke-all, rename and revoke) only with ?demo_devices=; `list` is the
fictional devices, and the other values are the lane's states as before.
Without it the demo has no device list, as before this branch.

The device-security regression asks for `list` where it named no state.
Its phone press on Revoke all scrolls the row into view first, since the
access facts now sit below Devices and the scrolled-end frame passes it.
Its 44 px touch-target check allows a 0.01 px layout remainder (a 44 px
box measured 43.99999 below the new group).

Checked with both demo regressions (device-security at 390 and 1440,
light, dark and Korean; security-summary at 390 and 1440) and the
conventions and ci-browser tests.
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.

Sidebar: show a read-only access summary in Phone & devices

1 participant