SecOps Observer
← All labs

Kubernetes RBAC / Intermediate / 25–40 min

The report reader that could read Secrets

A Kubernetes service account can read a report, but its Role also grants access to Secrets. Restrict its permissions without breaking report access.

LAB IDsecops-04-kubernetes-rbac-secretsTRACK / secops.observer
Security analyst monitoring alerts beside a server rack

The scenario

A report reader only needs to get and list ConfigMaps in its namespace. Its Role also permits reading a synthetic Secret. Remove the unnecessary Secret permissions while preserving the report and RoleBinding.

Mission objectives

  • Inspect the real Role, RoleBinding and service-account permissions.
  • Remove Secret access while preserving ConfigMap read access.
  • Verify permissions against the Kubernetes API and remove the disposable cluster.

Lab README

The report reader that could read Secrets

A Kubernetes service account can get and list a report ConfigMap, but its Role also grants access to Secrets. Reduce its permissions without losing report access. The Secret contains only a fixed synthetic value, never a credential.

Before you begin

Use Docker, kind, kubectl, Python 3 and Bash on a disposable machine. The lab creates a single-node kind cluster named breakfix-secops-04 and a separate kubeconfig under ~/.kube. Docker may download the node image. Do not use this cluster for other work or put real credentials in the lab. Kubernetes Secrets are not inherently encrypted just because their values are base64.

./setup.sh

Use the kubeconfig path printed by setup for every kubectl command. Inspect the report-reader Role and RoleBinding in namespace breakfix-secops-04. The verifier uses Kubernetes impersonation and includes the service account's normal groups; no service-account token is minted or mounted.

Remove Secret access from the Role while retaining get and list access to ConfigMaps. Preserve the existing RoleBinding, service account, report and synthetic Secret.

./verify.sh
./teardown.sh

Verification tests the real Kubernetes API's authorization and reads the report as the impersonated account. Teardown verifies the recorded kind node identity before deleting the entire lab cluster and its dedicated kubeconfig. If setup or teardown fails, inspect the cluster and files before manual cleanup.

View Markdown source ↗

Get the lab

Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.

curl -fsSLO https://devops.download/labs/secops-04-kubernetes-rbac-secrets.sh
less secops-04-kubernetes-rbac-secrets.sh
bash secops-04-kubernetes-rbac-secrets.sh
cd labs/secops-04-kubernetes-rbac-secrets
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

Inspect the resources and verbs in the namespaced Role, and use kubectl auth can-i to check the service account.

Hint #2

The report is a ConfigMap; retain get and list for ConfigMaps while removing the Secret resource from the Role.

Hint #3 · Related guide on opsbreakfix.com

Read the related guide ↗

Solved it?

Explore the related guide on opsbreakfix.com.

Continue to opsbreakfix.com ↗

One ecosystem.
Many perspectives.

Follow the connection from a hands-on lab to the knowledge and tools behind it.