feat(security): warn before sending credentials over plain http to non-loopback hosts
Summary
First-party credentials belong on https:, or http: to loopback. For other URLs, 0.21.x warns on stderr once per origin; 0.22 will refuse (insecure_credential_transport; one function flips). ADR: #5178.
Covers daemon, cloud (including refresh), Metro bridge, and default-transport proxy URLs. Insecure upload tickets are dropped unsent for the legacy upload. Daemon and Revyl share one loopback classifier.
Breaking: none on main. In 0.22, non-loopback http:// setups need encryption or AGENT_DEVICE_ALLOW_INSECURE_TRANSPORT=1. The proxy package has no override: use https, a loopback upstream, or upstreamFetch.
- Cloud URLs are judged where each flow reads them (login, refresh, profile);
auth-session.tsis at the line cap. - New
host-kitsubpath: reusing an existing one grows 9ā43 startup closures. - 164 added, 46 removed production lines (target ~150), including the moved classifier.
Before / after
Remote daemon at a plain-HTTP, non-loopback URL. Before: token sent silently. After:
Warning: credentials for http://remote-mac.example.test:7777 are sent in cleartext. agent-device 0.22 will refuse this. Use https, ssh -L, or Tailscale Serve, or set AGENT_DEVICE_ALLOW_INSECURE_TRANSPORT=1.
Validation
At 5537b6e014: nine changed test files (69 tests) and package-boundaries.test.ts passed; a scratch closure measurement found no growth. Ticket tests fail without the guard. Lint, typecheck, and other gates are left to CI. No live run.
Security
- Each listed path is checked before its request.
- The override must equal
1, from the sending process's host environment; profiles, tickets and requests cannot set it. - The Metro companion receives exactly the judged URL and token.
- Messages show the origin only.
- No redirect, wire-format, or provider URL changes.
š¤ Generated with Claude Code