liveBook · Manning

Principle of least privilege

As explained in Grokking Web Application Security

Least privilege is a security principle in which each software component and process receives only the permissions required to perform its intended functions.

The principle of least privilege means giving each component, process, and person only the permissions needed for its intended task. The practical question is simple: if an attacker takes over this account or process, what damage can it actually do? Limiting permissions will not necessarily stop the initial compromise, but it limits what happens next. section 4.15 section 4.16

Limit access at every layer

An airport illustrates the idea: travelers, pilots, and maintenance staff can each enter only the areas required for their roles; nobody has unlimited access. Apply the same boundary to an application: prevent browser JavaScript from reading cookies and set a CSP; use a database account that can read and update data but cannot alter table structures; and run the web server as a nonroot user able to reach only its assets, configuration, and code. section 4.15

Use least privilege as a damage-control checklist:

  • Separate organizational responsibilities across roles when practical, so one stolen or misused account cannot make every destructive change. section 5.2
  • Time-box sensitive permissions, such as changing servers or upgrading database structures, rather than leaving them available indefinitely. section 5.2
  • Keep private-key directories accessible only to the web server process or elevated users; do not expose keys in public static-asset directories. section 7.12
  • Restrict the database account used by application code to the data-reading and data-updating permissions it needs, reducing SQL-injection impact. section 12.6

Least privilege complements defense in depth. Escaping input, parameterized database statements, and other controls aim to prevent attacks; permission boundaries reduce the harm when one of those controls is bypassed. For example, injected browser code may still be unable to steal cookies if JavaScript cannot access them, and injected SQL has less reach when the database account cannot change schema. section 4.15 section 12.6

Treat unexpected server access as a probable compromise. Restricting access is not the final step: review access logs, use intrusion detection review, and if TLS keys may be compromised, revoke certificates, regenerate keys, and make required disclosures. section 7.12

How Grokking Web Application Security covers it

How deep it goes
Explains the principle through concrete browser, database, server, and organizational permission boundaries without formal access-control models.
Examples
Uses airport roles, nonroot web servers, limited database accounts, private-key directories, and time-boxed server permissions.
What it assumes
Introduces least privilege from zero using an airport analogy and practical application-security examples.
What you can do after
Apply it by restricting browser, database, server, key-directory, and organizational permissions to required tasks.
How it connects
Connects defense in depth, content security policy, cookies, database accounts, SQL injection, command injection, and TLS keys.

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 Grokking Web Application Security. The section links point to the parts of the book it draws on.