liveBook · Manning

Principle of least privilege

As explained in Developer Experience on Kubernetes

The principle of least privilege is a security practice of granting a process or user only the permissions required for its task.

Run a container process with only the permissions it needs. This reduces the impact of a compromised container, especially when the runtime otherwise defaults to root. section 3.2.1

Apply the principle when building and running container images:

  • Create a non-privileged user in the Dockerfile. section 3.2.1
  • Use that user for the entry point process instead of running the application as root. section 3.2.1
  • Account for runtime defaults: Docker uses root by default, while Podman uses non-root by default and also supports rootful mode. section 3.2.1

Container entry point

A containerized application that needs no administrative access runs its entry point under a newly created non-privileged user rather than the default root user. section 3.2.1

How Developer Experience on Kubernetes covers it

How deep it goes
Explains the root-user risk and gives the practical mitigation of creating and selecting a non-privileged entry-point user.
Examples
Uses Docker's root default and Podman's non-root default to contrast runtime privilege choices.
What it assumes
Assumes familiarity with containerization, Dockerfiles, container runtimes, and entry point processes.
What you can do after
Apply it by creating a non-privileged container user and assigning that user to the entry point process.
How it connects
Connects container images, Dockerfiles, entry points, Docker, Podman, rootless mode, and rootful mode.

Also explained in

Compare how 22 books explain principle of least privilege →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Developer Experience on Kubernetes. The section links point to the parts of the book it draws on.