External NATS hands every task container the broker's full token #1866
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#1866
Reference in new issue
Block a user
Problem
On the embedded broker a task container logs in as
task-<id>with its run credential and is limited to its own task's subjects. On an external broker,NATSEndpoint.ContainerTokenreturns the broker's own token becauseScopedis false whenever[nats] modeis external (archied bootstrap). Both task paths pass it in:containerEnvon the default path andkitrun.WorkerEnvon the Kit path. Any process in any task container can then publish and subscribe to every subject, including other tasks' work. archied reports this as a health issue but runs anyway.Multi-host workers (#1864) need an external broker, so this blocks that work.
Wanted
Use NATS auth callout so an external broker hands each login to archie, and apply the same check the embedded broker uses (the
authenticatorineventbus/nats/auth.go): instance token gets full permissions,task-<id>gets only its task's subjects, inbox and one reply. Then deleteContainerTokenand the unscoped fallback.Done when
Landed on main; task check passed on the merged tree. Not yet proven live.
Already fixed by
3a965e2a4: external-broker logins go through the embedded authenticator via the callout (internal/infrastructure/eventbus/nats/callout.go:59), TestBrokerScopesTaskCredentials (internal/infrastructure/eventbus/nats/auth_test.go:29) checks both brokers, and no ContainerToken remains in internal or cmd.