liveBook · Manning

Principle of least privilege

As explained in Build Financial Software with Generative AI (From Scratch)

The principle of least privilege is a security practice of granting only the permissions necessary to perform required work and removing elevated permissions when they are no longer needed.

The principle of least privilege (PoLP) grants only the permissions needed for current work, elevates access when necessary, and restores the original level afterward. Avoiding default root or administrator access limits both attacker impact and accidental damage from mistakes such as deleting files in the wrong directory. section 3.5

Apply the principle in containerized applications by narrowing access and limiting what a compromised process can do:

  • Use Docker's no-new-privileges setting to prevent an application from gaining additional privileges, including root privileges. section 3.5
  • Constrain container memory and CPU so one container cannot consume resources needed by the wider system. section 3.5
  • Configure API access narrowly: allow only required origins, HTTP methods, headers, and credentials instead of relying on broad wildcards. section 3.4
  • Combine least privilege with defense in depth, including application security, data protection, authentication, authorization, and vulnerability scanning. section 3.5 section 3.9

Narrowing API permissions

An API serving a local frontend allows only the required frontend origin and the GET method. Keeping those settings narrow avoids granting future or unused callers access before the application needs it. section 3.4

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Explains the rationale and demonstrates container and CORS settings, but stops short of a complete permissions-management workflow.
Examples
Uses no-new-privileges, container resource limits, and a CORS policy allowing one origin and GET requests.
What it assumes
Assumes familiarity with containers and APIs while introducing privilege escalation, root access, CORS, and defense in depth.
What you can do after
Apply it via Docker and API settings to restrict privileges, resources, origins, and methods to current requirements.
How it connects
Connects least privilege with Docker, container security, defense in depth, authentication, authorization, CORS, and vulnerability scanning.

Also explained in

Compare how 17 books explain principle of least privilege →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.