Перейти до вмісту
← DevSecOps and software supply chain security

Урок 5 з 7 · 9 хв

Container and Kubernetes security: least privilege, RBAC and image scanning

Containers package applications with everything they need, and Kubernetes runs them at scale. Learn where the risks are and the core controls: trusted images, least privilege, RBAC and Pod Security Standards.

Поки що ця сторінка англійською.

A container bundles an application with its libraries and settings so it runs the same way everywhere. Docker made containers mainstream; Kubernetes became the common way to run many of them across many machines. Both change security in useful ways, because containers are small, disposable and defined in code. They also introduce new risks, because containers share the host’s kernel, images are often pulled from public registries, and orchestration platforms hold enormous power over everything they run.

NIST SP 800-190, the Application Container Security Guide, groups container risks into five areas: images, registries, the orchestrator, the containers themselves and the host operating system. The controls below follow that structure.

Images: know what you run

  • Start from small, maintained base images from trusted publishers; fewer packages means fewer vulnerabilities.
  • Scan images for known vulnerable packages in the pipeline and again in the registry, because new vulnerabilities are published after an image is built.
  • Never bake secrets into images: anyone who can pull the image can extract them.
  • Sign images and verify signatures before deployment, as covered in the previous lesson.
  • Rebuild regularly rather than patching running containers.

Containers: least privilege

By default, many containers run as root inside the container. If an attacker breaks out, or the container is misconfigured to share host resources, that root access can become root on the host. Docker’s security documentation recommends reducing privileges, and its rootless mode runs the Docker daemon and containers as an unprivileged user, which limits the damage of a breakout.

SettingSafer choice
UserRun as a non-root user
Privileged modeOff, except for rare, reviewed system components
Linux capabilitiesDrop all, add back only what is needed
Root filesystemRead-only where possible
Host mounts and host networkAvoid; they break isolation
ResourcesSet CPU and memory limits

Kubernetes: RBAC and Pod Security Standards

Kubernetes role-based access control (RBAC) decides who and what can do which actions on which resources. Roles and ClusterRoles define permissions; RoleBindings and ClusterRoleBindings grant them to users, groups or service accounts. The common mistakes are granting cluster-wide admin rights for convenience, and giving application service accounts permissions they never use. The rule is the same as everywhere else: the smallest set of permissions, in the narrowest scope, for each identity.

Kubernetes also defines three Pod Security Standards: Privileged (unrestricted), Baseline (prevents known privilege escalations) and Restricted (follows current hardening best practice). The built-in Pod Security Admission controller can enforce a standard per namespace, so a workload that asks for dangerous settings is rejected before it runs.

  • Enforce Baseline everywhere and Restricted wherever the workload allows it.
  • Use network policies so pods can only talk to what they need.
  • Keep the control plane and nodes patched, and restrict access to the Kubernetes API.
  • Store secrets in a proper secrets store and enable encryption for them at rest.
  • Collect audit logs from the cluster and watch for unexpected permission changes.

Where FireAI fits

FireAI does not secure clusters or scan images; those controls live in your pipeline and platform. On a developer’s Mac, it works per app: it shows and controls the connections of the container tooling like any other app, and its rules follow that app’s verified code signature.

Головне

  • NIST SP 800-190 groups container risks into images, registries, orchestrator, containers and host.
  • Use small, scanned, signed images, and never put secrets inside them.
  • Run containers as non-root with minimal capabilities; consider rootless mode.
  • Apply least privilege with Kubernetes RBAC and enforce Pod Security Standards.

Перевірте себе

  1. 1. Why is running a container as root risky?

    • It uses more memory
    • If isolation fails, the attacker may gain root on the host — Правильно.
    • It prevents logging
    • Kubernetes refuses to start it

    Containers share the host kernel. Root inside plus a breakout or misconfiguration can mean root on the host.

  2. 2. In Kubernetes RBAC, what grants a Role’s permissions to a user or service account?

    • A RoleBinding — Правильно.
    • A ConfigMap
    • A Deployment
    • A Namespace label

    Roles define permissions; RoleBindings (or ClusterRoleBindings) assign them to identities.

  3. 3. Which Pod Security Standard follows current hardening best practice most closely?

    • Privileged
    • Baseline
    • Restricted — Правильно.
    • Default

    Restricted is the most locked-down standard. Baseline blocks known escalations; Privileged is unrestricted.

Застосуйте на практиці з FireAI

Застосуйте цей урок на своєму Mac.

Джерела

Застосуйте це на своєму Mac

Усі функції безкоштовно на 17 днів, без банківської картки.

Завантажити для Mac Документація