Big IAM Challenge
The The Big IAM Challenge is a cloud security Capture The Flag (CTF) event organize by Wiz with the goal of identifying and and exploiting AWS IAM misconfigurations, and learn from real-world scenarios.
Level 1: Buckets of Fun

IAM Policy
Solve
We can see that ased on the IAM Policy, the principal "*" is given the Allow effect on theActions3:ListBucket and s3:GetObject with the scope of thebigiamchallenge-storage-9979f4b
This means that any public user is able to access the bucket and download file from it
In fact, we are able to annoymously access it, even without the preconfigured aws account on the iam challenge website.
Reference:
https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html
Level 2: Google Analytics

IAM Policy
Solve
Since the challenge says it uses tthe analytics sysem on this website, I viewed page source, and managed to get the queue URL. However, we are also able to manually recreate the SQS Queue URL as we have enough information within the IAM Policy.
Next, I try and receive-message and was able ot get the flag.
Based on the meswsage body, theres a URL, and going to the URL gives us the flag.
Flag: {wiz:you-are-at-the-front-of-the-queue}
Reference:
https://docs.aws.amazon.com/cli/latest/reference/sqs/receive-message.html
Level 3: Enable Push Notifications

IAM Policy
Based on the aws cli reference page for sns subscribe. Note that theres a wild card reference for the sns:Endpoint allowing us to point it to any site we control as long as it ends with "@tbic.wiz.io"
In the requestbin output, theres a subscribe url.

Visiting the URL gives us a confirmation response that we have subscribed to the topic.
And we succesfully gotten the flag from our request bin.

Flag: {wiz:always-suspect-asterisks}
Reference:
https://docs.aws.amazon.com/cli/latest/reference/sns/subscribe.html
Level 4: Admin Only

IAM Policy
At a glance, the IAM Policy seems secure, that it scoped to only allow if the aws:PrincipalArn is the arn of the admin account. However, the vulnerabiliy comes in the ForAllValues which will return true if there are no context key in the requests.
We can simply run the s3 command with no-sign-requests to ensure that the PrincipalArn is not being sent in the request and able to retrieve the flag.

Flag: {wiz:principal-arn-is-not-what-you-think}
Level 5: Do I know you?

IAM Policy
Recalling from previous level, there were some cognito credentials in the browser javascript. I viewed the page source and we can see something similar.
The browser gets a cognito identity credentials from the id pool, and use it to retrieve the file cognito1.png using s3 presigned url, which we can see in the browser source. when inspecting element.
Since the AWS.config.credentials is being created by javascript, we can just run the browser console to retrieve the credentials.

With the credentials we are able to then access the AWS S3 bucket normally using AWS CLI.
I tried to run aws configure to configure the account, but as we are in a read only file system, I was not able to create the .aws/credentials file. So I just exported them to environment variable, and tried to retrieve the flag
However, when runnning env we can clearly see that the session token wasnt being modified.

So lets spin up a virtual machine and use it to get the flag.
Flag: {wiz:incognito-is-always-suspicious}
Level 6: One final push

IAM Policy
First, lets figure out what Cognito Identitty really does, as I cheesed level 5 with the credentials from the browser javascript console.
Cognito Federated Identities allow scoped temporary credentials to untrusted environment. Doing further research
First, we will need to get the cognito id, based on the identity-pool-id which is given in the IAM Policy with the aws get-id commands.
With the IdentityId we are then able to get a set of credentials to use. What we doing here is what the JavaScript code at Level5 does.
Now, we just need to asssume the role and get the flag. However, we need an OAuth 2.0 or OCID token to run the assume-role-with-web-identity command. Doing further enumeration shows the aws cognito-identity get-open-id-token commands which returns a OpenID Token.
Now, we just need to assume the roie with the OpenID Token..
Now with the assumed role credentials, we are able to then authenticate and get the flag.
Reference:
https://docs.aws.amazon.com/cli/latest/reference/cognito-identity/
https://docs.aws.amazon.com/cli/latest/reference/cognito-identity/get-id.html
https://docs.aws.amazon.com/cli/latest/reference/cognito-identity/get-credentials-for-identity.html
https://docs.aws.amazon.com/cli/latest/reference/sts/assume-role-with-web-identity.html
Last updated
Was this helpful?

