Repository navigation
Check cluster ownership for infra applies and cluster bindings (BUG-319978) - #1980
Merged
Merged
Conversation
…19978)
POST /v1/envs/{env}/{stage}/infras authorizes only the env in the path,
but ApplyInfraWorker acted on the clusterName from the request body.
Any env admin could reconfigure or resize another env's Rodimus cluster,
or claim a group that live hosts report. PUT and POST /v1/envs also
accepted any clusterName, which lets an env bind a name another env owns.
Add one ownership check in EnvironmentHandler and run it:
- in ApplyInfraWorker before any Rodimus or Teletraan change, which also
covers jobs already queued;
- when an env stage's clusterName changes, and when an env stage is
created with one.
The check rejects cluster names Rodimus cannot address, existing Rodimus
clusters not bound to the env, names bound to another env, and new names
that another non-sidecar env deploys to or that hosts already report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osoriano
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes BUG-319978.
Summary
Problem (Why)
POST /v1/envs/{env}/{stage}/infrasrequires EXECUTE on the env in the path, but the cluster it changes comes fromclusterNamein the request body.ApplyInfraWorkeracted on that name without checking that it belonged to the env:EnvCapacitiesapplies.Any user can create an env and becomes its admin, so any user could change another env's cluster or take over a group that live hosts report.
PUT /v1/envs/{env}/{stage}andPOST /v1/envshad the same gap: they accepted anyclusterName. Capacity checks, main-env lookups, and Rodimus resolve a cluster's owner from that field, so binding another env's cluster name undermines them too.Solution (What + How)
One check in
EnvironmentHandler, run in three places:ApplyInfraWorker.applyInfrarunsvalidateInfraClusterbefore any Rodimus or Teletraan change. Checking in the worker covers every way a job gets queued, including jobs queued before this change deploys.EnvironmentHandler.updateEnvironmentrunsvalidateClusterClaimwhen an env stage'sclusterNamechanges.Environs.createrunsvalidateClusterClaimwhen a new env stage has aclusterName. It checks a bean without the caller-suppliedid.The check rejects:
[a-zA-Z0-9_-]{1,128}(400). This is Rodimus's own path pattern, andenvirons.cluster_nameisVARCHAR(128). Cluster names are interpolated into Rodimus URLs, so the ownership check only holds if the name checked is the cluster Rodimus acts on.clusterName.EnvInfrasis unchanged: a rejected apply still returns 200 and its job then fails. The only automated caller, Spinnaker'sTeletraanInfrastructureApplyMonitorTask, treats a failed job as a failed stage.Behavior changes
clusterNamefirst);PUT /v1/envs/{env}/{stage}andPOST /v1/envs:clusterNamechanges to a name bound to another env, used as another env's group capacity, or reported by hosts this env doesn't deploy to;{env}-{stage}before the cluster exists, so they are unaffected.Before deploying
The owner lookup returns a single row, so first confirm that no two env stages share a
cluster_name, and resolve any that do:Test Plan
InfraClusterOwnershipTest(7 tests) uses the realApplyInfraWorker,EnvironmentHandler, andEnvironswith mocked DAOs and Rodimus.id.EnvironmentHandlerTest(+9) covers each rule.ApplyInfraWorkerTest(+2) checks that a rejected job makes no changes, and an invalid name makes no Rodimus calls.TokenRolesTest, which needs a Docker Hub image unavailable on the test host; master behaves the same.javac. Formatted with google-java-format 1.7 (AOSP). Relying on CI for the Maven build and spotless.🤖 Generated with Claude Code