v0.10.0: each viewer sees what their own RBAC allows

Until now anyone admitted through Dex saw every namespace and every log,
read with the module's service account. auth.visibility: ViewerRBAC (the
default) asks the API server as the viewer, with the token the
DexAuthenticator forwards: list pods in all namespaces means the whole
cluster; otherwise the namespaces where they can list pods. Logs also
need get pods/log, node cards list nodes, cluster-wide alerts are for
cluster-wide viewers. Traffic to a hidden namespace keeps its counts with
the peer shown as hidden. One minute cache per token hash, SSARs in
parallel (8), a cluster-wide viewer costs two.

Verified against the live cluster with two real tokens: a service
account with view in one namespace got that namespace only (0 nodes, 403
on another namespace's YAML and logs, 403 on node usage); the module's
own account, cluster-wide, got all 56 namespaces and 6 nodes; no token,
401. auth.visibility: Everything keeps the old behaviour. The
DexAuthenticator now forwards the token when either actions or ViewerRBAC
need it (templates/_helpers.tpl).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Виталий Чефанов
2026-09-25 01:03:50 +03:00
co-authored by Claude Opus 5.5
parent ce6dad9a58
commit c50020e420
27 changed files with 791 additions and 26 deletions
+8 -2
View File
@@ -83,7 +83,13 @@ History is kept in memory: after a pod restart the windows fill again. The statu
The web interface reads the cluster through the module's own service account (`d8:cluster-map` ClusterRole): `get`, `list`, `watch` on namespaces, pods, services, nodes, events, deployments, statefulsets, daemonsets, cronjobs, ingresses, Deckhouse `clusteralerts` and operator-trivy `vulnerabilityreports`, `get` and `list` on `metrics.k8s.io` pods and nodes, and `get` on `pods/log`. It never reads Secrets or ConfigMaps and has no write verbs. Changes go through [actions](#actions), which use the viewer's own identity.
This means **anyone admitted to the web interface sees every namespace and can read container logs**, whatever their own RBAC permissions are; what they can change is limited by their own RBAC. Restrict access with `auth.allowedUserGroups` (and optionally `auth.allowedUserEmails` and `auth.whitelistSourceRanges`).
**What a viewer sees follows the viewer's own RBAC** (`auth.visibility: ViewerRBAC`, the default). With every request the DexAuthenticator passes the user's token; the module asks the API server with that token (`SelfSubjectAccessReview`) and caches the answer for a minute:
- `list pods` in all namespaces — the whole cluster;
- otherwise only the namespaces where the user can `list pods`; cards, YAML, events, load and vulnerabilities of other namespaces are not returned, and a traffic peer there is shown as a hidden peer, with its connections but without its name;
- container logs additionally need `get pods/log` in that namespace, node cards and the node view `list nodes`; cluster-wide alerts are shown to cluster-wide viewers only.
With `auth.visibility: Everything`, anyone admitted to the web interface sees every namespace and can read container logs, whatever their own RBAC is. In both modes restrict who is admitted with `auth.allowedUserGroups` (and optionally `auth.allowedUserEmails` and `auth.whitelistSourceRanges`); what a user can change always follows their own RBAC.
The frontend is served with a strict Content Security Policy: only its own scripts, styles and API, no inline code, no framing.
@@ -99,6 +105,6 @@ The pod exposes Prometheus metrics on port `9090` (`cluster_map_*`: Hubble strea
## Limitations
- One replica: traffic history lives in the process. A second replica would keep its own history and double the load on hubble-relay.
- Reading is all-or-nothing, as described in [Security](#security). Showing each user only what their RBAC allows to read is planned; actions already follow the user's RBAC.
- Visibility is by namespace: a user who can list pods in a namespace sees all its cards, including the manifests of its Deployments and Services, even if their role would not let them read those objects one by one.
- Alerts need the `prometheus` module, which creates `ClusterAlert` objects. Without it the map shows problems from object state and events only.
- Traffic is L3/L4. HTTP-level details (paths, status codes) need Cilium L7 visibility and are not shown yet.
+8 -2
View File
@@ -83,7 +83,13 @@ Workload'ы под нестандартными контроллерами то
Веб-интерфейс читает кластер через собственную учётку модуля (ClusterRole `d8:cluster-map`): `get`, `list`, `watch` на namespaces, pods, services, nodes, events, deployments, statefulsets, daemonsets, cronjobs, ingresses, `clusteralerts` Deckhouse и `vulnerabilityreports` operator-trivy, `get` и `list` на pods и nodes из `metrics.k8s.io` и `get` на `pods/log`. Secret и ConfigMap он не читает, прав на запись нет. Изменения идут через [действия](#действия), которые выполняются от имени пользователя.
Отсюда следует: **любой, кого пустили в веб-интерфейс, видит все namespace и может читать логи контейнеров** — независимо от собственных прав RBAC; изменить он может только то, что разрешает его RBAC. Ограничивайте доступ через `auth.allowedUserGroups` (а также `auth.allowedUserEmails` и `auth.whitelistSourceRanges`).
**Что видит пользователь, определяет его собственный RBAC** (`auth.visibility: ViewerRBAC`, по умолчанию). С каждым запросом DexAuthenticator передаёт токен пользователя; модуль спрашивает API-сервер от его имени (`SelfSubjectAccessReview`) и кеширует ответ на минуту:
- `list pods` во всех namespace — виден весь кластер;
- иначе — только namespace, где пользователь может `list pods`; карточки, YAML, события, нагрузка и уязвимости остальных namespace не отдаются, а сосед по трафику оттуда показывается скрытым — с соединениями, но без имени;
- для логов контейнеров нужно ещё `get pods/log` в этом namespace, для карточек нод и вида по нодам — `list nodes`; общекластерные алерты видны только пользователям с доступом ко всему кластеру.
При `auth.visibility: Everything` любой, кого пустили в веб-интерфейс, видит все namespace и может читать логи контейнеров независимо от своего RBAC. В обоих режимах ограничивайте круг допущенных через `auth.allowedUserGroups` (а также `auth.allowedUserEmails` и `auth.whitelistSourceRanges`); изменить пользователь всегда может только то, что разрешает его RBAC.
Фронтенд отдаётся со строгой Content Security Policy: только собственные скрипты, стили и API, без inline-кода, без встраивания во фреймы.
@@ -99,6 +105,6 @@ Workload'ы под нестандартными контроллерами то
## Ограничения
- Одна реплика: история трафика живёт в процессе. Вторая реплика держала бы свою историю и удвоила бы нагрузку на hubble-relay.
- Чтение по принципу «всё или ничего», см. раздел [Безопасность](#безопасность). Показ каждому пользователю только того, что его RBAC разрешает читать, — в планах; действия уже следуют RBAC пользователя.
- Видимость — по namespace: пользователь, который может смотреть поды в namespace, видит все его карточки, включая манифесты Deployment и Service, даже если его роль не дала бы прочитать эти объекты по отдельности.
- Для алертов нужен модуль `prometheus`, он создаёт объекты `ClusterAlert`. Без него карта показывает проблемы только по состоянию объектов и событиям.
- Трафик на уровне L3/L4. Подробности HTTP (пути, коды ответа) требуют L7-видимости Cilium и пока не показываются.