Identity and Access Management Quiz
Quiz
iam:CreateUser?Identity-Based Policy:
Allow: s3:*, ec2:*, iam:*
Permissions Boundary:
Allow: s3:*, ec2:*
Request: iam:CreateUserThe Confused Deputy Problem occurs when a trusted third-party service (the “deputy”) can be tricked into accessing resources on behalf of the wrong customer.
Solution: Use External ID in cross-account trust policies. This adds a secret value that must be provided when assuming the role, ensuring the service acts on behalf of the correct customer.
Example: Without External ID, a malicious customer could trick Datadog into accessing another customer’s AWS account by providing their account ID.
Did you get it right?
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"Service": "_____"
},
"Action": "sts:AssumeRole"
}]
}ec2.amazonaws.com as the service principal. This allows the EC2 service to request temporary credentials on behalf of instances.ec2.amazonaws.com as the service principal. This allows the EC2 service to request temporary credentials on behalf of instances.Policy 1 (Identity):
Effect: Allow
Action: s3:*
Resource: *
Policy 2 (Boundary):
Effect: Deny
Action: s3:DeleteBucket
Resource: *
Request: s3:DeleteBucketTrust Policy (Assume Role Policy):
- Defines WHO can assume the role
- Contains
Principalelement - Uses
sts:AssumeRoleaction - Attached only to IAM roles
- Always inline (cannot be reused)
Permissions Policy (IAM Policy):
- Defines WHAT actions are allowed
- No
Principalelement - Uses service-specific actions (s3:, ec2:, etc.)
- Can attach to users, groups, or roles
- Can be managed (reusable) or inline
Together: Trust policy controls access to the role, permissions policy controls what the role can do.
Did you get it right?
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"_____"
],
"Resource": [
"arn:aws:s3:::my-bucket/*",
"arn:aws:s3:::my-bucket"
]
}]
}s3:ListBucket allows listing the contents of the bucket. Together with s3:GetObject (which retrieves objects), this provides complete read-only access. Note that ListBucket applies to the bucket itself, while GetObject applies to objects within it.s3:ListBucket allows listing the contents of the bucket. Together with s3:GetObject (which retrieves objects), this provides complete read-only access. Note that ListBucket applies to the bucket itself, while GetObject applies to objects within it.Principle of Least Privilege means granting only the minimum permissions necessary to perform required tasks.
Implementation:
- Start with no permissions (deny by default)
- Add permissions only as needed
- Regularly review and revoke unused permissions
- Use specific actions and resources instead of wildcards
Benefits:
- Reduces security risk from compromised credentials
- Limits blast radius of accidents or mistakes
- Improves compliance and auditability
- Forces intentional permission design
Example: Give a developer read-only S3 access to specific buckets, not full S3 admin access to all buckets.
Did you get it right?
Account A (111111111111):
User: Alice
Identity Policy: Allow s3:GetObject on bucket-B/*
Account B (222222222222):
Bucket: bucket-B
Resource Policy: (no policy exists)
Request: Alice tries to get object from bucket-B1. IAM Users
- For: Individual people or applications
- Credentials: Long-term (username/password, access keys)
- Use when: Need persistent human access or dedicated application credentials
2. IAM Groups
- For: Collections of IAM users with similar permissions
- Credentials: None (users have credentials)
- Use when: Managing permissions for multiple users (teams, roles)
3. IAM Roles
- For: Temporary access for services, cross-account, or federated users
- Credentials: Temporary (STS-generated, auto-rotated)
- Use when: EC2/Lambda need AWS access, cross-account access, or federated identity
Best Practice: Prefer roles over users for services; use groups to manage user permissions.
Did you get it right?