What is the principle of least privilege?
BeginnerConceptSecurity basics for DevOps
Answer
In one line: Least privilege means every person, service and pipeline gets only the minimum permissions it needs to do its job — and only for as long as it needs them.
Why it matters:
- If an account, key or server is compromised, the attacker can only do what that identity was allowed to do. Small permissions = small damage (a small "blast radius").
- It also prevents accidents: a developer can't delete the production database if they don't have permission to.
Examples in DevOps:
- IAM roles — a CI pipeline that only deploys to one ECS service gets permission for that service and its ECR repository, not
AdministratorAccess. - Kubernetes RBAC — the payments team can manage the
paymentsnamespace only; Argo CD gets only the permissions it needs. - Service accounts — each microservice has its own identity (IRSA on EKS, Workload Identity on AKS/GKE) with access only to the AWS/Azure resources it uses.
- Databases — the app user can read/write its tables but can't drop the database or create users.
- Humans — read-only access to production by default; elevated access only when needed (just-in-time access with approval and expiry).
- Short-lived credentials — OIDC tokens and temporary roles instead of long-lived access keys.
Bad vs good IAM:
// Bad
{ "Effect": "Allow", "Action": "*", "Resource": "*" }
// Better
{ "Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::invoices-prod/*" }
How to apply it in practice:
- Start with no permissions and add what's needed.
- Use tools like IAM Access Analyzer to find unused permissions.
- Review access regularly and remove what's no longer needed (for example when people change teams).
- Separate accounts/subscriptions for dev, staging and prod.
Tip for interviews: give one concrete example of tightening a permission — such as replacing a pipeline's admin role with a scoped deploy role.
More on Security basics for DevOps
What is SAST, DAST and SCA?BeginnerWhat is a CVE, and how do you handle vulnerabilities found by scanners?BeginnerWhat is container image scanning, and where should it happen?BeginnerWhat is software supply chain security (SBOM, image signing, SLSA)?IntermediateWhat is secrets management, and why shouldn't secrets be in code?BeginnerWhat is encryption in transit and encryption at rest?Beginner