Principle of least privilege
Принцип наименьших привилегий
Give each person or program only the permissions it needs for its task. This limits what can go wrong if someone makes a mistake or an account is compromised.
Also known as: least privilege
What least privilege means
A support agent who looks up delivery dates needs to read shipping information, not issue refunds. A reporting job may need to read sales totals, but it does not need to update orders. Least privilege is the rule you use to decide how much access to grant after you know who or what is making the request.
The goal is to limit the damage from a mistake or a compromised account. Read-only access, for instance, can protect records from being changed through that account. It cannot protect information the account is allowed to read, which is why the scope of read access matters too.
How to put it into practice
Start with the work, not the role names. List the actions a person or workload must take, the resources those actions apply to, and when access is needed. Give a reporting job access to the dataset it queries, not every dataset in the account. If an engineer needs elevated access for a production repair, make the grant expire when the work window ends rather than keeping it available permanently.
Enforce those decisions through authorization controls such as database grants, file permissions, or cloud IAM policies. Role-based access control (RBAC) can make grants easier to manage, but a role called viewer is not necessarily narrow: it might expose every project. Review effective permissions, including access inherited through groups, and remove grants that no longer serve a task.
Example: build and deployment in CI/CD
A build job compiles the app and publishes an artifact to a registry. A deployment job pulls that artifact and updates the application in production. If both jobs use one identity, the build job gets production deployment rights it never needs.
Use separate identities. Give the build job permission to publish to the application's repository, but not to deploy. Give the deployment job permission to pull the artifact and update the intended production workload, but not to publish new artifacts or administer unrelated workloads. Verify that both jobs still succeed and that the build identity is denied when it requests a deployment.
Where it comes up and what people miss
The same reasoning applies to Linux service accounts, database users, and API tokens. A common shortcut is to grant administrator access to get past a permission error and leave it in place. Instead, identify the missing action and resource, then test with the narrower grant. Short-lived credentials help limit how long access can be used, but they do not make an overly broad grant safe while it is active.
Interview angle
An interviewer might ask what database access a web app should have if releases also run schema migrations. Separate the runtime identity from the migration identity. Say which tables and operations the app needs, what schema changes the migration job must make, and how you would verify that the running app cannot make those changes.