Files
cozystack/hack
Andrei Kvapil 6ed0541eb2 fix(apps): stop granting tenants core Secrets through dashboard resource maps
Every app chart rendered a <release>-dashboard-resources Role and a
RoleBinding to the tenant's groups and ServiceAccounts. The Roles began
in 2024 as a resource map that the kubeapps dashboard read to list an
application's objects, and had no bindings. When the tenant roles lost
the core wildcard, the maps were bound so kubeapps kept working, and
they became real grants. The console that replaced kubeapps reads
Secrets through core.cozystack.io/tenantsecrets, which cozystack-api
serves with its own identity and only for what the ApplicationDefinition
admits, yet the bindings stayed.

So any tenant subject at the bound level could read the named Secrets
directly through the API server, bypassing the -rd allowlist: database
credentials, the kubernetes admin kubeconfig, Grafana's admin password.
A bucket with no users rendered an empty resourceNames list, which RBAC
reads as every Secret in the namespace.

Nothing reads these Roles' Secret rules any more. Services, ingresses
and workloadmonitors are already granted namespace-wide by the
cozy:tenant ClusterRoles, and the Secrets tenants need are all in
secrets.include. Remove the Roles and RoleBindings from every chart
except foundationdb. The qdrant and vm-instance WorkloadMonitors that
shared the file move to workloadmonitor.yaml.

foundationdb keeps its resource map and Role: they are the only way a
tenant reads <release>-config, the ConfigMap with the cluster file,
since no cozy:tenant role grants ConfigMaps and tenantsecrets serves
only Secrets. They grant ConfigMaps and no Secrets, and the map now
lists only that ConfigMap, the one entry the console reads. They go
once Cozystack can serve application ConfigMaps to tenants.

The new kubernetes chart ignores computeplane's
withholdAdminKubeconfig pin, but it stays for one more release: until
the ExternalArtifact catches up, the previous kubernetes chart would
otherwise render its admin kubeconfig rule again.

None of these objects carries helm.sh/resource-policy: keep, so Helm
deletes them on upgrade and no migration is needed.

A new bats check renders every chart under packages/apps and
packages/extra and fails if any binds a tenant subject to a Role that
grants core Secrets. The suites and e2e steps that pinned the Roles'
rules are removed with them. The charts that needed cluster state only
to render the Roles now render offline, so they leave the release-size
check's NO_OFFLINE_RENDER list.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-26 10:52:28 +01:00
..