liveBook · Manning

Principle of least privilege

As explained in MongoDB 8.0 in Action, Third Edition

The principle of least privilege is a security practice of granting each identity only the permissions necessary for its tasks.

The principle of least privilege (PoLP) means giving each user, application, or system only the access needed for its tasks. Limiting permissions reduces accidental or intentional misuse and the potential damage from errors or breaches. section 20.3.1

Start with the task, then choose the narrowest appropriate access:

  • For a user who only reads one database, grant read access to that database—not write or administrative access. section 20.3.1 section 20.3.3
  • For a backup service, grant access only to the databases it backs up. section 20.3.1
  • Use a custom role when a built-in role permits more than the task requires. Custom roles can restrict actions to particular collections. section 20.3.3

Apply PoLP both to permissions in Atlas and to roles within MongoDB databases. An atlasAdmin database user has broad administrative privileges, so it is not a default choice for every user. Dedicated users or service accounts for each application keep permissions isolated and make actions easier to track. section 2.4 section 20.8

atlas customDbRoles create customReadUpdateRole \
--privilege 'UPDATE@sample_training.routes' \
--privilege 'FIND@sample_supplies.sales'

This Atlas CLI command creates a custom database role with UPDATE on sample_training.routes and FIND on sample_supplies.sales, illustrating permissions tied to specific actions and collections. section 20.3.3

Check role scope as well as permitted actions. A role created in the admin database is available across databases; a role created in a particular application database is valid only there. Choose the scope that matches the task. section 20.3.3

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines the principle and works through role scope and custom-role choices, without detailing a complete permission-audit procedure.
Examples
Contrasts a database reader and backup service with overbroad access, and creates a collection-specific custom role using Atlas CLI.
What you can do after
Operate/configure Atlas and MongoDB access by selecting narrowly scoped roles and creating custom roles when built-in permissions are too broad.
How it connects
Connects least privilege to role-based access control, built-in roles, custom roles, and dedicated service accounts.

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 MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.