Skip to content

Commit 423cd18

Browse files
committed
fix(daemon): fail closed when the auth hook is silent about tenant
An auth hook that ran but returned no tenantId opted the deployment into tenant attestation; falling back to the client's own claim (RPC body meta.tenantId, aux-route x-agent-device-tenant header) let a holder of one valid shared token impersonate any tenant on /rpc and on the diagnostics/ upload/download routes. resolveTrustedTenant() in the new src/daemon/server/tenant-trust.ts is now the single seam both surfaces go through and the only place that computes the resulting identity: hook attests -> use it; no hook configured -> keep today's client-declared behavior (loopback/dev unchanged); hook configured but silent with a client-declared tenant -> refuse (401) instead of trusting the claim, and no raw client-declared metadata survives into the dispatched request in that case either. Fixes #2095
1 parent 2e87347 commit 423cd18

8 files changed

Lines changed: 546 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Unreleased
44

5+
- Security (daemon, remote/proxy HTTP only): when `AGENT_DEVICE_HTTP_AUTH_HOOK` is configured and a
6+
request's hook result does not attest a `tenantId`, the request is now refused (401) outright — the
7+
daemon no longer runs it as whichever tenant the client declared (RPC body `meta.tenantId` or
8+
`flags.tenant`, or the `x-agent-device-tenant` header on the upload/artifact-download/diagnostics
9+
routes) and no longer admits it unscoped when the client declares nothing either. This closes both
10+
a shared-token impersonation path and an unscoped-access path to tenant-owned sessions/artifacts in
11+
multi-tenant deployments. Deployments with no hook configured (the local loopback CLI) are
12+
unaffected. A hook must attest `tenantId` on every request it wants the daemon to admit.
513
- Breaking (0.21): removed aggregate performance compatibility (`perf`, `perf sample`, `perf metrics`, the `metrics` alias, optionless `client.observability.perf()`, and SDK `area: 'metrics'`). Use `perf frames`, `perf memory sample`, `perf cpu profile start|stop|report`, or `perf trace start|stop`; removed CLI and raw daemon forms fail with this migration guidance.
614
- Breaking (0.21): removed legacy batch JSON steps with `positionals`/`flags`. Use `{"command":"...","input":{...}}`; rejected steps now include a concrete structured example.
715
- Breaking (0.21): removed the deprecated Node client `command.rotate` wrapper and its `RotateCommandOptions` / `RotateCommandResult` exports. Use `command.orientation`; the already-removed CLI `rotate` form keeps its targeted migration error.

src/__tests__/test-utils/env.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function restoreEnv(key: string, previous: string | undefined): void {
2+
if (previous === undefined) delete process.env[key];
3+
else process.env[key] = previous;
4+
}

0 commit comments

Comments
 (0)