Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions docs/adr/0041-credential-transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ADR 0041: Credential Transport — HTTPS or Loopback for Configured Credential Destinations

## Status

Accepted (2026-11-28).
ADR 0006 continues to govern checked RPC.

## Rules at a glance

1. **Supported remote setup.** The daemon and `agent-device proxy` listen on loopback.
A TLS tunnel (cloudflared, ngrok, Tailscale Serve) or `ssh -L` carries remote traffic.
Remote clients connect with an `https://` URL, or with a loopback URL through the SSH forward.
In this setup, a first-party credential crosses a network only inside TLS or SSH.
2. **One admission rule.** Before agent-device sends a first-party credential to a URL that an operator configured, the URL must use `https:` or name a loopback host over `http:`.
Otherwise the client refuses with `INVALID_ARGS` and `details.reason: 'insecure_credential_transport'`.
The refusal happens before any network I/O.
It names the URL origin and the fix, and never the credential.
3. **Loopback** is `localhost` or an IPv4, IPv6, or IPv4-mapped loopback literal, after WHATWG URL parsing.
The rule never resolves names and never infers encryption from a private range, a DNS suffix, or an interface.
4. **One operator override.** `AGENT_DEVICE_ALLOW_INSECURE_TRANSPORT=1` in the sending process's environment admits plain HTTP to any host.
It relaxes only this rule.
It never relaxes URL validation, the remote authentication requirement, cloud issuer binding, or checked RPC.
Only the operator's environment sets it. A fetched profile, ticket, bridge message, or remote request cannot set it.
`@agent-device/proxy` has no override: its own upstream is the local daemon, and an embedder routes elsewhere with HTTPS or its own `upstreamFetch`.
5. **Admission points.** The rule applies at these destinations:
- the remote daemon base URL, from any source (flag, environment, SDK, connection profile, cloud profile);
- the cloud base URL, including the issuer stored at login when a refresh uses it;
- the Metro bridge base URL that receives the Metro or daemon bearer;
- the `@agent-device/proxy` `upstreamBaseUrl`, when the proxy uses its own transport;
- a direct-upload ticket URL. If a ticket fails the rule, the client discards it unsent and uses the legacy upload on the admitted daemon base.
6. **No redirect policy.** This decision adds no redirect handling.
The protocol rules on main stay: checked RPC never follows a redirect (ADR 0006), cloud auth stays on its issuing origin, and streamed uploads stay same-origin.

## Reason

RFC 6750 §5.3 says that a client must use TLS or equivalent transport security for bearer tokens.
Credential-sending clients with a remote destination commonly refuse cleartext by default and exempt loopback: Docker registries, Go module fetches, and Git Credential Manager do so.
Each of those tools has one explicit opt-in.
A warning is not sufficient: an unattended agent or CI job sends the token before a person reads the warning.

The realistic failure is an operator mistake, not an attacker.
Examples are a plain `http://` URL typed for a LAN host, or a proxy behind a TLS tunnel started without `--public-origin`.
In the second case the proxy writes the client credential into an `http://` upload ticket for the public host, and the credential crosses the internet in cleartext.
One check at the place that reads each configured URL prevents both mistakes.

Redirects need no general policy.
An on-path observer of a plaintext request already has the credential, so refusing its redirect protects nothing.
Over TLS, only the server that the operator configured can issue a redirect.
The daemon client uses `node:http`, which never follows redirects, upload preflight uses `redirect: 'error'`, and the checked RPC route forbids redirects.
The proxy's other upstream requests use `fetch` defaults. Their upstream is the operator's own daemon, so only the operator's own service can issue those redirects.

## Rejected alternatives

- **Warn and continue.** The credential leaks before anyone reads the warning. A temporary warning before the refusal ships is a release choice, outside this decision.
- **Infer encryption** from RFC 1918, CGNAT, IPv6 ULA, `.ts.net`, or interface membership. An address does not prove the route. Tailscale users can use Tailscale Serve for HTTPS, or set the override.
- **Per-host override list** (as Docker `--insecure-registry` and `GOINSECURE` do). A client process has one daemon destination. A boolean is enough.
- **General redirect inspection or a custom HTTP client.** No realistic actor gains from it. Redirect issuers are the operator's own services.
- **Extend the rule to provider URLs (Limrun, Revyl), the Metro dev-server relay, and returned WebSocket URLs.** These carry no first-party credential, or their owner already has a rule. Revyl already admits only HTTPS or loopback HTTP for its backend.
- **Check an embedder's custom proxy transport.** `upstreamFetch` replaces the network route, so its URL can be a logical name. The embedder owns that route.
- **Authorization-only daemon auth in this decision.** The token is also in `x-agent-device-token` and in JSON-RPC `params.token`. These copies matter only after a cross-origin redirect from the operator's own HTTPS service. A wire cleanup can follow as its own change.

## Consequences

- An existing LAN `http://` deployment must move to HTTPS or `ssh -L`, or set the override.
- An `@agent-device/proxy` embedder with a non-loopback HTTP upstream and the default transport must use HTTPS or supply `upstreamFetch`.
- A misconfigured `--public-origin` costs an extra transfer through the daemon instead of a cleartext credential.
- The operator keeps these duties, which the supported setup already meets:
keep the daemon token secret, set `--public-origin` behind a TLS terminator, keep the onward hop from a TLS terminator on loopback, and bypass any environment HTTP proxy for every loopback host they use (for example `NO_PROXY=localhost,127.0.0.1,::1`).

## Review rules

- A finding must name the actor, the capability that the actor needs, and the credential that the actor reads.
If the actor needs a capability that this decision excludes, such as reading TLS traffic or controlling the operator's own server, reject the finding.
- A finding against the supported remote setup must give reproduction steps that start from that setup.
If the steps depart from the setup, name the departure.
If the departure is not a configuration that the docs support or a likely operator mistake, reject the finding.
- For a redirect finding, name the party that issues the redirect.
If only the operator's own service can issue it, reject the finding.
If that party can already read the first request, treat the finding as a plaintext finding.
- To add an admission point, show that a first-party credential goes to an operator-configured URL there.
- Do not add redirect handling for credential secrecy. Keep the redirect rules of ADR 0006, cloud auth, and upload streaming. They protect protocol invariants.
- If a claim depends on runtime behavior, reproduce it with a script of 20 lines or fewer before you write code.
Record the runtime version, the platform, every relevant setting (such as `NODE_USE_ENV_PROXY`, `HTTP_PROXY`, and `NO_PROXY`), and the observed output.
- Before you request a new protection layer, check whether a change at one existing owner, or a deletion, keeps the invariant.
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
| [0037 Web Session Devices](0037-web-session-devices.md) | web sessions as devices of their own, the session name rule, the `p_`/`t_` backend key and tenant isolation, and first-open locking for web |
| [0038 Snapshot capture source routing](0038-snapshot-capture-source-routing.md) | the source router for multi-source owners, one fallback, refusal scopes, surface proof, and the producer registry |
| [0039 Pre-dispatch admission](0039-pre-dispatch-admission.md) | one admission step for resolved-target input: ordered typed checks, one request-bound wait loop, one evidence path, and no extra reads for an idle target |
| [0041 Credential Transport](0041-credential-transport.md) | URLs that receive a first-party credential, the HTTPS-or-loopback admission rule, `AGENT_DEVICE_ALLOW_INSECURE_TRANSPORT`, the supported remote setup, upload tickets, proxy upstreams, and redirects as a credential concern |
Comment thread
thymikee marked this conversation as resolved.
Resolved

ADRs record rationale.
The registries and gates they describe are the current source of truth.
Expand Down
3 changes: 2 additions & 1 deletion docs/agents/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The client trusts a remote daemon for data and validated identifiers.
Scripts and remote record stop reject daemon paths (#4518). Trace and perf take them.
The daemon admits its state directory. Nobody trusts the network or other local users.
Out of scope: same uid, hostile root, ACLs, mounts, untrusted filesystems.
ADR 0041 owns credential transport. Change it only with a new decision.

## Applied today

Expand All @@ -16,4 +17,4 @@ Remote script delivery caps in-memory bytes and error answers.

#4669 proposes private writes for credentials, client state, and daemon state (#4649): create each under a verified state root, and never write through a link at the final name.
Do not apply these before #4669 is approved.
Do not apply the ADR 0016 walk to other caller outputs. Screenshot `--out`, contact sheets, the JUnit reporter, and trace and recording outputs keep a plain write to the path the caller names.
Do not apply the ADR 0016 walk to other caller outputs, like screenshot `--out`, contact sheets, JUnit, traces, recordings.
Loading