Study Guide: Principle of Least Privilege (PoLP) in AWS
Principle of least privilege access
Principle of Least Privilege (PoLP) Access
This guide explores the foundational security pillar of Least Privilege Access, particularly within the context of AWS Identity and Access Management (IAM) and the SAP-C02 curriculum.
Learning Objectives
- Define the Principle of Least Privilege and its role in reducing the security blast radius.
- Analyze IAM policies to identify over-privileged permissions and suggest scoped-down alternatives.
- Differentiate between the privilege requirements of human users and machine identities.
- Explain advanced data protection techniques including row/column-level filtering and tokenization.
- Apply PoLP within the AWS Well-Architected Framework (SEC 2 and SEC 3).
Key Terms & Glossary
- Principal: An entity (user, role, or application) that can make a request for an action or operation on an AWS resource.
- Blast Radius: The potential impact or damage that could occur if a specific security credential is compromised.
- Tokenization: A data security process where sensitive data (like PII) is replaced by a non-sensitive equivalent (token) that has no extrinsic value.
- IAM Policy: A JSON document that defines permissions, specifying what actions are allowed or denied on which resources.
- Fine-Grained Access: Granular control that limits access to specific rows, columns, or sub-actions rather than whole services.
The "Big Idea"
[!IMPORTANT] If you remember only one security best practice, it is this: Give users and machines only the access they need to perform their specific tasks, and nothing more.
PoLP is not just about stopping malicious actors; it's about minimizing the impact of human error. By restricting the "perimeter of action" for every identity, you ensure that a single compromised set of credentials cannot bring down an entire cloud environment.
Formula / Concept Box
| Component | Description | Example |
|---|---|---|
| Principal | Who is asking? | arn:aws:iam::123456789012:role/AppRole |
| Action | What are they doing? | s3:GetObject (NOT s3:*) |
| Resource | Where is the data? | arn:aws:s3:::my-bucket/logs/* (NOT *) |
| Condition | Under what context? | "IpAddress": {"aws:SourceIp": "10.0.0.0/24"} |
Hierarchical Outline
- Core Philosophy of PoLP
- Scope Down Strategy: Limiting the perimeter of action to exact needs.
- Avoid Administrator Access: Defaulting to no access and adding permissions incrementally.
- Implementation Across Identities
- Human Identities: Behavior is unpredictable; often requires temporary elevated access for testing.
- Machine Identities: Behavior is predictable; easier to define rigid, granular policies.
- Advanced Data Access Control
- Data Filtering: Using row-level or column-level filtering for database access.
- Tokenization: Upfront (pre-processed) vs. On-the-fly (e.g., using S3 Object Lambda).
- Auditing and Governance
- AWS CloudTrail: Logging all API calls to monitor access patterns.
- AWS Config: Using managed rules to ensure encryption and compliance.
Visual Anchors
The Path to Least Privilege
Scoping the Permission Sphere
\begin{tikzpicture} \draw[thick, fill=red!20] (0,0) circle (3cm) node[yshift=2.5cm] {Full Admin Access (Danger)}; \draw[thick, fill=orange!20] (0,0) circle (2cm) node[yshift=1.5cm] {Service-Level Access (Coarse)}; \draw[thick, fill=green!20] (0,0) circle (0.8cm) node {\textbf{PoLP}}; \draw[dashed] (0,0) -- (2.12, 2.12) node[midway, sloped, above] {Blast Radius Reduction}; \end{tikzpicture}
Definition-Example Pairs
- Coarse-Grained Access: Granting access to an entire service.
- Example: Giving a developer
s3:*permissions across the whole account so they can "just get their work done."
- Example: Giving a developer
- Granular Access: Granting access to specific sub-resources and actions.
- Example: Limiting a Lambda function to only
s3:PutObjecton a specific folder:arn:aws:s3:::app-uploads/images/*.
- Example: Limiting a Lambda function to only
- On-the-fly Tokenization: Masking data as it is being retrieved.
- Example: Using Amazon S3 Object Lambda to redact Social Security Numbers in a CSV file before it reaches the requester's browser.
Worked Examples
Scenario: Refactoring an Over-Privileged Policy
The Problem: A developer has attached the following policy to an EC2 instance that only needs to upload logs to a specific bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}The Solution: Apply PoLP by narrowing the action and the resource.
- Identify the Action: The instance only needs to upload, not delete or list. Use
s3:PutObject. - Identify the Resource: The instance only needs one bucket. Use
arn:aws:s3:::my-app-logs/*. - Refactored Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:PutObject"],
"Resource": "arn:aws:s3:::my-app-logs/*"
}
]
}Comparison Tables
Human vs. Machine PoLP Implementation
| Feature | Human Identities | Machine Identities |
|---|---|---|
| Predictability | Low (Varies by task/day) | High (Defined by code/logic) |
| Permissions | Role-Based (RBAC) | Resource-Based or Task-Specific |
| Elevation | Temporary (IAM Identity Center) | Hard-coded or IAM Roles for EC2 |
| Audit Frequency | Periodic Review | Automated (IAM Access Analyzer) |
Upfront vs. On-the-Fly Tokenization
| Aspect | Upfront Tokenization | On-the-Fly Tokenization |
|---|---|---|
| Performance | Faster reads (pre-processed) | Slower (requires compute time) |
| Storage | Requires extra storage for tokens | No extra storage needed |
| Flexibility | Low (Fixed format) | High (Can vary based on requester) |
| AWS Tool | Batch processing (Glue/EMR) | S3 Object Lambda |
Checkpoint Questions
- Why is it easier to apply PoLP to machines than to humans?
- What is the main risk of using
"Resource": "*"in an IAM policy? - When would you choose
s3:PutObjectovers3:*for an application? - How does tokenization differ from simple encryption at rest?
- Which AWS service would you use to audit which principals are accessing your data?
Muddy Points & Cross-Refs
- Admin vs. Power User: Many students confuse "AdministratorAccess" (everything) with "PowerUserAccess" (everything except IAM). Note that PowerUsers can still cause massive data loss even if they can't change permissions.
- Service-Linked Roles: These are predefined by AWS. You cannot modify them to be "more least privilege," which can be confusing. They are exceptions to the rule of manual scoping.
- Cross-Ref: For more on how these permissions are evaluated, see Chapter 5: Determining Security Requirements and Controls and SEC Pillar 3 of the Well-Architected Framework.