Skip to content

verify_code on every site: serve Apple Passwords codes (TOTP, Messages) beyond Apple sign-in #339

Closed

Description

@MehdiMamas

What happened (2026-11-15, Windows desktop, helper 1.4.33)

An agent on a GitHub "Confirm access" page (emailed code) ran verify-code <tabId> github.com and got:

{"ok": false, "error": "not_allowed", "reason": "not_apple_site"}

The owner has chosen Allow every site (*) for agents and wants the code reader to serve every site, not only Apple.

Why it was Apple-only

verify_code (src/agent.js:307-351, host check :327 isCodeHost) has one code source: Apple's own trusted-device prompt ("Sign in requested" > Allow > 6 digits), read by native/code-reader/ (Mac) or native/windows/code-reader.ps1. That prompt only ever shows Apple Account codes. Scope was set in #320 (D1 = A). On github.com that source would approve an Apple sign-in and type an Apple Account code into GitHub: no GitHub code, and an Apple code handed to another site. So the host check stays for that source.

Decision: widen by adding a second code source for every other site

  • Apple sign-in hosts: unchanged, the Apple prompt reader.
  • Every other site (on the agent allowlist, or any site when Allow every site (*) is on, with the every-site rules): the one-time codes Apple Passwords already offers for that tab, the same list the person sees in the inline code menu (listOtpEntries, src/session/otp-list.js):
    • totp: authenticator codes saved in Apple Passwords for the site (Mac and Windows);
    • codes from Messages/Mail that macOS offers (Mac only).
  • The Apple prompt reader is never started on a non-Apple host.
  • What PassBridge still can not serve: an emailed or SMS code on Windows, or on a Mac where Apple does not offer it. The reply then says no_code with a hint to use Keytray.

Security kept: off by default, per-profile switch, Allow agent sign-in required, allowlist or every-site rules (https, not local, not blocked, code saved for the tab's own site), shared verify_code rate limit (3 / 10 min), Activity row without the value, a notification per fill, the code goes only into the probed field and is never in a reply or log, Apple Passwords asks for approval when it wants to (needs_user). Trade-off accepted by the owner: with every site on, an agent holding both the password and the authenticator code can finish a sign-in with no person.

Plan

  1. src/agent.js verifyCode: after the tab checks, branch on isCodeHost(host).
    • Apple host: as today.
    • Other host: allowed when on the allowlist, or agentAllowAll with the every-site rules (as sign_in, :453-460). Then rate limit, probe the field, call new dep vaultCode(tab, frame, username?), fill with fillCode; reply {ok, domain, filled:true, source:"totp"|"messages"}.
    • Errors: no_code (+hint naming Keytray), several_codes (several entries and no username; no values), needs_user (approval refused or timed out).
  2. src/background.js: implement vaultCode with listOtpEntries for the probed frame; keep totp rows saved for the tab's site; pick by username, else exactly one; else a single non-totp row (Mac; its domain must match when it has one); re-read a TOTP fresh (as resolveOneTimeCode). Never logs the value.
  3. native/passbridge-agent-cli.py: verify-code <tabId> [site] [username].
  4. Tests (test-harness/automation/unit.test.ts): flip the :292/:294 cases; new cases for every-site non-Apple host, reader never called, no_code hint, several_codes, username pick, needs_user, blocked/http/local refused, shared rate limit.
  5. Docs: docs/agent-protocol.md Verification codes (drop "Allow every site (*) does not apply", add which-code-from-where), Replies table; AGENTS.md.
  6. Check: pnpm typecheck, pnpm test, CI green, release patch, update desktop, live proof on GitHub (list-only check first that a GitHub code exists in the vault; never print it).

Rollout state found today (checked live, not assumed)

machine helper Allow every site code reader switch Apple prompt reader works
desktop 1.4.33, paired on (status allowAll:true) on no: code-reader.json still TODO-DESCRIBE -> not_configured
laptop 1.4.33 unknown: status -> no_host (browser not connected) unknown no: TODO-DESCRIBE
Mac 1.4.33, paired on (allowAll:true) off (unlock -> code_reader_off) no: Code Reader app not installed -> reader_missing

The switch lives in each browser profile's chrome.storage.local (never synced), so it is set on each machine in its browser.

Follow-ups

Activity

  1. changed the title [-]verify_code on non-Apple sites: say which tool serves the code (Keytray), document Apple-only scope[/-] [+]verify_code on every site: serve Apple Passwords codes (TOTP, Messages) beyond Apple sign-in[/+] on Nov 16, 2026
  2. MehdiMamas commented on Nov 16, 2026

    @MehdiMamas
    OwnerAuthor

    Status 2026-11-15

    • sign_in username mismatch (found on a password-only step): sign_in filled a saved login whose username differed from the account the page showed, and the page refused it. Fixed in sign_in: refuse a username that differs from the account the page shows #341 (merged): when the page shows a fixed account (hidden or read-only username, account chip, or the address near the password field), sign_in fills only that account's login. A different username, or no saved login for it, returns username_mismatch with the saved usernames, and nothing is filled. An editable username field does not block the fill.
    • Desktop: dist rebuilt from main (verify_code: serve Apple Passwords codes on every site (#339) #340 + sign_in: refuse a username that differs from the account the page shows #341). It goes live when the extension reloads; the local manifest version was bumped, so the 30-minute update alarm reloads it. The GitHub verify-code test has not run yet.
    • Laptop no_host: the relay only connects while "Allow agents to sign in" or the code reader is on. Neither key exists in the laptop Chrome profile's storage, so both switches are off there. Helper 1.4.33 and the native-host registration are correct. Fix: turn on Options > Agents > Allow agents to sign in (and Allow every site) in the laptop's PassBridge.
    • Apple prompt reader (all machines): code-reader.json (Windows) and prompt.json (Mac) still hold TODO-DESCRIBE, so it reads nothing anywhere. A real "Sign in requested" prompt has to be recorded once on screen: on the Mac with the app's --describe mode; Windows has no describe mode yet, so the iCloud process names and the Allow/Done AutomationIds have to be read with a UI Automation dump while the prompt is open.
    • Mac: to switch it on: (1) toggle the code reader in Options > Agents. It lives only in chrome.storage.local on purpose, with no file or CLI. (2) Build the app into the PassBridge app-support folder with native/code-reader/build.sh and the Developer ID identity; an ad-hoc build loses its grant on every rebuild. (3) Grant Accessibility in System Settings. (4) Record the prompt as described above.
    • Release: not cut. A version bump, Mac signing and a real-PC smoke test are still needed (docs/releasing.md).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions