Skip to content

fix(k8s): gateways and commonly-bot mount no service account token - #4176

Merged
lilyshen0722 merged 3 commits into
mainfrom
cto/f533-gateway-sa
Nov 16, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
cto/f533-gateway-sa

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@coderabbitai ignore

Agent gateways the backend provisions, and the chart's commonly-bot, no longer mount the provisioner's service account token (F533).

Why

Both run as agent-provisioner. Its Role (templates/agent-provisioning/rbac.yaml) covers the Secrets, Deployments, Services, ConfigMaps and PVCs in the namespace, and pod exec. Neither workload calls the Kubernetes API:

  • A gateway runs agent turns. When the backend writes into one, it execs with its own credentials.
  • commonly-bot calls LiteLLM and the Commonly API.

A token neither one uses is reach that a compromised process would get for free. The account carries no cloud identity (checked read-only on dev and staging: only Helm's own annotations), so the mounted token was its only reach.

What changes

  • backend/services/gatewayProvisionerServiceK8s.ts: the gateway pod spec sets automountServiceAccountToken: false, on both the create and replace paths.
  • k8s/helm/commonly/templates/agents/commonly-bot-deployment.yaml: the same setting.
  • scripts/verify-service-account-tokens-chart.js, wired into chart-lint and its path filter:
    • Renders the default, dev and staging lanes with the optional workloads on.
    • Fails if any workload other than the backend, backend-worker and ops-runner Deployments runs as the provisioner account with a token.
    • Reads the account name from values.
    • Covers Jobs and CronJobs, the serviceAccount spelling, and an account-level setting.
  • backend/__tests__/unit/services/gatewayProvisionerServiceK8s.serviceAccount.test.js: drives the real provisionGateway through create and replace.

Proof

  • Both checks were written first and failed on main. The verifier flagged Deployment/commonly-bot in all three lanes, and both gateway tests failed.
  • With the change, the verifier prints "ok: 12 workloads render as agent-provisioner across 3 lanes", and the gateway tests pass 2 of 2. The PDB and NetworkPolicy chart checks still pass.
  • Neither image reads a token. commonly-bot and its shared code have no Kubernetes client, kubectl or /var/run/secrets, and neither does the openclaw gateway source.

Rollout

commonly-bot restarts once on the next deploy, which rides Tuesday's roll. No gateway runs today, so the gateway change takes effect at the next provision.

Filed separately:

  • ops-runner probably needs no token either (F539).
  • buildAgentDeploymentManifest in agentProvisionerServiceK8s.ts uses the same account but has no callers, so it goes to the dead-code sweep.

Tier 2, with one review (Opus) below. It touches .github/, so it's a hand press.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N4VWLGaqG2kVEDDn4hY3nm

lilyshen0722 and others added 2 commits November 15, 2026 14:32
Both run as agent-provisioner, an account that can read and write every
Secret in its namespace and exec into pods. Neither calls the Kubernetes API:
a gateway runs agent turns, and commonly-bot calls LiteLLM and the Commonly
API. So both now set automountServiceAccountToken: false. The account carries
no cloud identity, so the token was its only reach.

A chart check (scripts/verify-service-account-tokens-chart.js, in chart-lint)
fails if any workload other than backend, backend-worker and ops-runner runs
as agent-provisioner with a token. A backend test covers the gateway pods the
provisioner creates at runtime. F533.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4VWLGaqG2kVEDDn4hY3nm
…pts Deployments only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4VWLGaqG2kVEDDn4hY3nm

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one review for this change (D218, Tier 2: access rights): an Opus subagent, read-only, at dbb413f. It found nothing Major. Its Minors on the verifier are fixed at 46b7a27.

Lanes covered: k8s chart, backend provisioner, CI workflow (chart-lint step and path filter).

Checked and true:

  • commonly-bot (external/commonly-agent-services/commonly-bot/index.js:1-4, ../shared, Dockerfile): no Kubernetes client, kubectl, /var/run/secrets or sidecar. fs only reads the config file.
  • Gateway: the openclaw source (src/, extensions/) has no Kubernetes use. The backend's exec into a gateway uses the backend's own kubeconfig (agentProvisionerServiceK8s.ts:232).
  • No cloud identity: read-only, agent-provisioner carries only Helm annotations on dev and staging.
  • Live pods on the account: backend, backend-worker, ops-runner and commonly-bot. No gateway pods. The allowlist is right for today.
  • The verifier: it flags Deployment/commonly-bot in all 3 lanes on main's template and passes here (12 renders = 4 workloads × 3 lanes). It covers Job and CronJob, the serviceAccount fallback, and the account-level setting, with the pod-level setting winning.
  • CI: the filter regex matches, and chart-lint has node, npm ci and helm like the other verify-*.js steps.
  • Gateway test: it drives the real provisionGateway, create (404 then create) and replace (read then replace), and passes 2 of 2.
  • Roll safety: neither image uses the default token. No infra identifiers in the diff.
  • buildAgentDeploymentManifest (agentProvisionerServiceK8s.ts:2867) is not exported and has no callers, so it's dead and goes to the dead-code sweep.

Minors, with what was done:

  • The account name was hard-coded. It's now read from values.yaml (rbac.serviceAccount.name), tolerating Helm's duplicate keys. Fixed at 46b7a27.
  • The exemption matched by name for any kind. It's now Deployment/<name> only. Fixed at 46b7a27.
  • An existing gateway picks up the setting on its next re-provision. None are live, so this has no effect today.
  • ops-runner is an exec target, and nothing found uses Kubernetes from inside it. Filed as F539, not changed here.

Nits: the success line's wording is fixed. A bare Pod or ReplicaSet isn't checked, and the chart renders neither.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 6ef56da Nov 16, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant