liveBook · Manning

Principle of least privilege

As explained in Authorization in Action

The principle of least privilege requires each subject to receive only the access necessary to perform its authorized tasks.

A permission that lets every employee view every document can expose financial forecasts to interns who do not need them. The principle of least privilege limits each subject to the permissions necessary for authorized tasks. Its aim is to prevent unnecessary exposure without blocking legitimate work. section 10.1.2 section 10.1

Least privilege depends on precise scope: who can act, which action they can perform, and which resources they can access. Project membership, roles, or relationships can narrow that scope. Fine-grained actions such as view, edit, and share help distinguish different needs. section 10.1.2 section 10.5

From all employees to project members

A broad document-viewing policy grants every employee access to every document. Restricting the resource to a project container and requiring project membership gives access to the people who need those documents instead. section 10.1.2

permit(
    principal is Employee,        // grants to all employees
    action == Action::"doc:view",
    resource is Document        // all documents
);

This Cedar policy permits every employee to view every document; neither the principal nor the resource is narrowly scoped. section 10.1.2

permit(
    principal,
    action == Action::"doc:view",
    resource in Document::"alpha"        // just project docs
)
when{
    Project::"alpha".members.contains(principal) // only project members
};

This alternative limits the resource to project documents and checks that the requester is a project member. section 10.1.2

Scope must remain reliable as people and organizations change. A team or project membership can be more stable than a job-title check, which may fail after a promotion. Policies can reference attributes and relationships held in authoritative systems rather than embedding changing data in the rules. section 10.1.5 section 10.5

Put least privilege into practice:

  • Specify the smallest group, actions, and resource scope needed for the task; avoid blanket permits for all employees. section 10.1.5 section 10.5
  • Externalize shared authorization logic as policies, and review and version policy changes. section 10.1.5 section 10.4
  • Validate policies against a schema and test requests and invariants, such as allowing only project members to view project documents. section 10.1.5
  • Use decision logs and review records to support auditing and accountability. section 10.5

Regulatory requirements can shape the necessary scope. For example, a financial analyst may need access to reports but not their underlying raw data. Dynamic policies can use roles or other attributes for fine-grained decisions and can be updated as requirements change. section 1.3.4

How Authorization in Action covers it

How deep it goes
Defines least privilege and contrasts broad and project-scoped policies, then gives validation and maintenance practices.
Examples
Uses an employee document-access policy and a financial analyst’s report-only access to illustrate restricted scope.
What you can do after
Apply it through Cedar policies scoped by action, resource, and project membership.
How it connects
Connects least privilege to dynamic authorization, policy as code, identity attributes, auditing, and regulatory compliance.

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 Authorization in Action. The section links point to the parts of the book it draws on.