All hands-on labs

Premium Hands-on labintermediatered teamAWS

IAM AttachRolePolicy PrivEsc

Exploit iam:AttachRolePolicy to grant a role you have access to higher privileges with AWS managed policies. Then, assume this role to gain access to sensitive data in Amazon S3 that your IAM user should not have been able to access. Complete the lab by submitting the credit card number for 'Richard Gibson.'

  • 11 guided tasks
  • Capture the flag
  • Terminal in the browser

Scenario

AWS IAM roles are incredibly useful and powerful, and you can assume them to receive permissions either within your account, or even for cross-account access

You can do that using `AssumeRole` which returns a set of temporary security credentials that can then be used in a similar way to regular access keys, except they are short-term credentials instead of long-term credentials.

If your IAM user has AssumeRole permissions for a particular role (which is dictated by a role's trust policy), you can assume that role and whatever permissions it has. If you have that permission plus the iam:AttachRolePolicy permission, then you can update the permissions for that role.

Your lab user is one that has access to perform support functions by assuming roles with AssumeRole, including a role that has access to a non-sensitive S3 bucket containing generic files for an application that you support.

However, this lab has been misconfigured to grant you iam:AttachRolePolicy. Leverage this misconfiguration to give that role additional S3 permissions that allow you to access a bucket containing PII that you were not intended to have access to.

You've captured the flag when you've successfully downloaded the files contained in that bucket, and submitted the credit card number for 'Richard Gibson.'

What you will learn

  • Configure an AWS CLI profile with your lab user's access keys.
  • Enumerate your IAM user, group, and role permissions with the AWS CLI.
  • Assume the SupportRole and check what S3 access it has.
  • Attach a managed policy to widen the role's S3 access.
  • Read the protected customer data and capture the flag.
Hands-on lab

IAM AttachRolePolicy PrivEsc

Included in Cybr Premium.