security(info): bind the real tenant ServiceAccount without OIDC

The RoleBinding subject was built as tenant-<namespace> in namespace
tenant-<namespace>, but the release namespace already starts with
tenant-, so the binding did not name the tenant's own ServiceAccount.
The name it did form is one another tenant can claim: a child named
root of a tenant named tenant owns the ServiceAccount
tenant-tenant-root, which would then be granted the token Secret of
tenant-root. Bind the tenant's own ServiceAccount instead.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Myasnikov Daniil authored and Andrei Kvapil committed 2026-11-27 13:48:47 +01:00
1 parent 9c9958a4ca
commit ec5c5474a3
2 files changed
+46 -2

No files matched your search

@@ -25,8 +25,8 @@ subjects:
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "view" .Release.Namespace) }}
{{- else }}
- kind: ServiceAccount
name: tenant-{{ .Release.Namespace }}
namespace: tenant-{{ .Release.Namespace }}
name: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}
roleRef:
kind: Role
@@ -0,0 +1,44 @@
suite: info dashboard resource access
templates:
- templates/dashboard-resourcemap.yaml
release:
name: info
namespace: tenant-root
# The tenant ServiceAccount is named after the namespace, which already starts
# with "tenant-". Without OIDC the dashboard signs in with that ServiceAccount's
# token, so the RoleBinding has to name exactly that subject.
tests:
- it: binds the tenant ServiceAccount by its real name without OIDC
set:
_cluster:
oidc-enabled: "false"
documentIndex: 1
asserts:
- isKind:
of: RoleBinding
- contains:
path: subjects
content:
kind: ServiceAccount
name: tenant-root
namespace: tenant-root
- notContains:
path: subjects
content:
kind: ServiceAccount
name: tenant-tenant-root
namespace: tenant-tenant-root
- it: grants the token Secret by name without OIDC
set:
_cluster:
oidc-enabled: "false"
documentIndex: 0
asserts:
- equal:
path: rules[0].resourceNames
value:
- tenant-root