flAWS2.cloud is the continuation of flAWS.cloud, an educational challenge to learn common vulnerabilities and misconfigurations in AWS. This time, the challenge is divided in two parts: offensive and defensive. We are supposed to begin as an attacker and exploit our way through misconfigurations in serverless (Lambda) and containers (ECS Fargate). Once finished, we will continue with the defensive path, where we will take the role of an investigatr trying to understand how an attack happened, while learning common techniques to investigate incidents.
We are prompted to find a 100-digit PIN, brute forcing won't help.
Enter any PIN and capture the request with Burpsuite, we see a GET request to 2rfismmoo8.execute-api.us-east-1.amazonws.com.
Send to repeater to fuzz the application. If we send a PIN made of letters instead of numbers the application dumps all kind of information included in environmental variables.
Here we disclose the AWS credentials as well as the AWS region: us-east-1
Let's use credentials to connect to the bucket and enumerate the secrets.
In the lessons learned the author mentions 3 vulnerabilities:
Developers dumped environmental variables when error conditions occur in order to help them when debugging problems; however, they forgot to deactivate the feature after the application entered in production.
IAM role has permissions to list contents of a bucket.
The image is public so we can download it with docker pull
First log in into the ECR registry.
> aws ecr get-login-password --region us-east-1 | sudo docker login --username AWS --password-stdin 653711331788.dkr.ecr.us-east-1.amazonaws.com
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Now we take the role of a defender investigating the incident.
We have AWS credentials for "security" account as an IAM user. This account contains a copy of the logs and has the ability to assume the "security" role in the target account.
Credentials give access to the security account, and you can also have access to an S3 bucket, named flaws2_logs that contains the CloudTrail logs recorded during the attack.
OBJECTIVE 1: DOWNLOAD THE CLOUDTRAIL LOGS
Start by trying the account credentials and enumerating the user.
Then connect to the S3 bucket, where you find a bunch of logs.
> aws s3 ls s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/
Just download all files.
> aws s3 cp s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/ . --recursive
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2305Z_zKlMhON7EpHala9u.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2305Z_zKlMhON7EpHala9u.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2305Z_83VTWZ8Z0kiEC7Lq.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2305Z_83VTWZ8Z0kiEC7Lq.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2310Z_jJW5HfNtz7kOnvcP.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2310Z_jJW5HfNtz7kOnvcP.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2310Z_A1lhv3sWzzRIBFVk.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2310Z_A1lhv3sWzzRIBFVk.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2310Z_7J9NEIxrjJsrlXSd.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2310Z_7J9NEIxrjJsrlXSd.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2310Z_rp9i9zxR2Vcpqfnz.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2310Z_rp9i9zxR2Vcpqfnz.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2235Z_cR9ra7OH1rytWyXY.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2235Z_cR9ra7OH1rytWyXY.json.gz
download: s3://flaws2-logs/AWSLogs/653711331788/CloudTrail/us-east-1/2018/11/28/653711331788_CloudTrail_us-east-1_20181128T2310Z_jQajCuiobojD8I4y.json.gz to ./653711331788_CloudTrail_us-east-1_20181128T2310Z_jQajCuiobojD8I4y.json.gz
OBJECTIVE 2: ACCESS THE TARGET ACCOUNT
Next step would be to check our access to the target account (653711331788). For this just add another profile in the config file ~/.aws/config
You also need to configure profile "security" since it will be source profile for "target_account". The final AWS config file would be something like this.
This indicates the level3 role is only supposed to be run by the AWS ECS service. However, if we check the previously disclosed IP, we find this address does not belong to the AWS IP range.
> whois 104.102.221.250
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/
#
# Copyright 1997-2025, American Registry for Internet Numbers, Ltd.
#
NetRange: 104.64.0.0 - 104.127.255.255
CIDR: 104.64.0.0/10
NetName: AKAMAI
NetHandle: NET-104-64-0-0-1
Parent: NET104 (NET-104-0-0-0-0)
NetType: Direct Allocation
OriginAS:
Organization: Akamai Technologies, Inc. (AKAMAI)
RegDate: 2014-04-22
Updated: 2014-04-22
Ref: https://rdap.arin.net/registry/ip/104.64.0.0
OrgName: Akamai Technologies, Inc.
OrgId: AKAMAI
Address: 145 Broadway
City: Cambridge
StateProv: MA
PostalCode: 02142
Country: US
RegDate: 1999-01-21
Updated: 2023-10-24
Ref: https://rdap.arin.net/registry/entity/AKAMAI
OrgTechHandle: SJS98-ARIN
OrgTechName: Schecter, Steven Jay
OrgTechPhone: +1-617-274-7134
OrgTechEmail: ip-admin@akamai.com
OrgTechRef: https://rdap.arin.net/registry/entity/SJS98-ARIN
OrgAbuseHandle: NUS-ARIN
OrgAbuseName: NOC United States
OrgAbusePhone: +1-617-444-2535
OrgAbuseEmail: abuse@akamai.com
OrgAbuseRef: https://rdap.arin.net/registry/entity/NUS-ARIN
OrgTechHandle: IPADM11-ARIN
OrgTechName: ipadmin
OrgTechPhone: +1-617-444-0017
OrgTechEmail: ip-admin@akamai.com
OrgTechRef: https://rdap.arin.net/registry/entity/IPADM11-ARIN
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/
#
# Copyright 1997-2025, American Registry for Internet Numbers, Ltd.
So we conclude someone from outside has been able to list the buckets, since the access was made from a non-AWS IP address. Next step will be to determine how this access was possible (maybe because of a misconfigured open resource).
OBJECTIVE 5: IDENTIFY THE PUBLIC RESOURCE
Now we are challenged to identify the public resource that has been abused to initiate the attack.
First we enumerate all events recorded and we see the attacker called ListImages and GetDownloadUrlForLayer.
The principal is set to *, therefore the repository is public for anyone requesting the indicated actions.
So this is the vulnerability exploited by attackers: a overly permissive public policy on the repository.
OBJECTIVE 6: USE ATHENA
In this challenge the author describes how to enumerate the logs using an alternative tool called Athena. This tool is available in the AWS console and is useful for querying the logs. To complete the challenge you will need to use your own AWS account.