Skip to content
Luigi Carpio
← Labs

One Line of IAM Policy: Investigating a CloudTrail Breach

· 7 min read
cloudtrail incident-response iam nist-800-53

Last verified: 2026-11

One S3 GetObject call took a disaster recovery plan out of the account. The plan held plaintext credentials for an ERP system, a warehouse system, an AWS workload, and an Azure service principal. One leaked AWS key became four systems.

The key that started it had one permission: sts:AssumeRole on an admin role.

I worked this as Breach in the Cloud, a beginner blue team lab from Pwned Labs. A fictional logistics company hands over the AWS keys of a user that “saw unusual activity” and 45 minutes of CloudTrail logs. The job is to confirm the breach, name the compromised service, and name what left.

Pwned Labs lab card for Breach in the Cloud. The overview describes a cloud security incident built on suspicious CloudTrail activity, with case files handed out through the Pwned Labs Discord and the case file name blacked out. Tags read aws, cloudtrail, s3, iam, and CTF.

Three failures made the breach work:

  • A throwaway IAM user held standing sts:AssumeRole on an admin role.
  • The role’s trust policy didn’t require MFA.
  • Credentials for four systems sat in plaintext in an S3 object.

A fourth let it run. 463 denied calls from one key, and nothing fired.

Reading the logs

The case file is seven CloudTrail files from one account, written over 45 minutes. The timestamp is in each filename, so name order is time order.

CloudTrail writes each file as one line of JSON. I made them readable first:

for file in *.json; do jq . "$file" > "$file.tmp" && mv "$file.tmp" "$file"; done

One IAM user in the logs had a name that read like a throwaway account. I started there and grepped each file for it in order, beginning with the earliest:

grep -h -A 10 <USER> *T2035Z*.json

The timeline

StepEventIdentityResult
1GetCallerIdentityIAM userSuccess
2ListObjects on the target bucketIAM userAccessDenied
3463 calls across iam, datapipeline, comprehend, dax, route53, ssm, waf, and moreIAM userAccessDenied
4AssumeRole into the admin roleIAM userSuccess, ASIA key issued
5GetCallerIdentityAdmin role sessionSuccess, mfaAuthenticated: false
6ListObjects on the target bucketAdmin role sessionSuccess
7GetObject on the DR planAdmin role sessionSuccess

GetCallerIdentity is the AWS whoami. It’s the first call anyone makes with keys they didn’t create. I looked up the source IP:

curl ipinfo.io/<SOURCE_IP>

It belonged to a hosting provider the company doesn’t use. The user agent was the AWS CLI on WSL2, so a person was typing.

The attacker asked for the bucket by name before they could read it. They already knew what they wanted.

Then came 463 denials across two log files:

grep errorMessage *T2050Z*.json | wc -l   # 13
grep errorMessage *T2055Z*.json | wc -l   # 450

They hit services as unrelated as comprehend, dax, and route53. Nobody does that by hand. It’s a tool like aws-enumerator or Pacu trying every read call to map what the key is allowed to do.

The AssumeRole response holds the new temporary key, prefixed ASIA. AWS documents the key prefixes: AKIA is a long-lived user key, ASIA is temporary. Every later event from the role session carries that same key in userIdentity.accessKeyId, with sessionContext.sessionIssuer pointing at the role. That key is what links the user to everything the role did after.

The source IP changed on almost every call, five addresses in all, every one inside the same hosting provider’s /24. Blocking one IP would not have stopped it.

Walking it as the attacker

The lab then hands you the user’s keys so you can confirm the path. I listed the user’s inline policies and read the only one:

aws iam list-user-policies --user-name <USER>
aws iam get-user-policy --user-name <USER> --policy-name <POLICY>

It has one statement:

{
  "Effect": "Allow",
  "Action": "sts:AssumeRole",
  "Resource": "arn:aws:iam::<ACCOUNT_ID>:role/<ADMIN_ROLE>"
}

That’s the whole policy.

aws sts assume-role --role-arn arn:aws:iam::<ACCOUNT_ID>:role/<ADMIN_ROLE> --role-session-name <SESSION>

The response has three parts: AccessKeyId, SecretAccessKey, and SessionToken. On my first try I set only the token. My profile still had the user’s long-lived AKIA key, and STS rejected the call with InvalidClientTokenId. A session token is only valid with the ASIA key it was issued alongside. I set all three:

aws configure set aws_access_key_id ASIA****
aws configure set aws_secret_access_key ****
aws configure set aws_session_token "****"
aws sts get-caller-identity

This time get-caller-identity returned the assumed-role ARN, and the bucket listing that had been denied now worked.

What an access review would see

In a user access review, this user’s row would show one inline policy with one statement. No managed admin policy, no * in the action. Read on its own, it looks low risk.

It isn’t. The user’s real permissions are whatever the admin role has. A review that reads each identity’s attached policies in isolation never sees that path. To find it, the review has to follow sts:AssumeRole grants across to the trust policies on the roles they point at.

The role’s trust policy also didn’t require MFA. The session context reads mfaAuthenticated: false, and the call still went through.

Control mappings

NIST 800-53 Rev 5What happenedWhat would have stopped it
AC-6 Least PrivilegeA throwaway user held standing sts:AssumeRole on an admin roleRemove the grant, or scope the role to what the user actually needs
AC-2(2) Automated Temporary and Emergency Account ManagementA user named as temporary was still active with live keysExpire temporary accounts automatically
IA-2(1) Multi-Factor Authentication to Privileged AccountsAdmin role assumed with mfaAuthenticated: falseaws:MultiFactorAuthPresent condition in the role trust policy
IA-5 Authenticator ManagementCredentials for four systems stored in plaintext in an S3 objectA secrets manager, with the DR plan referencing it instead of the values
SI-4 System Monitoring463 AccessDenied events from one key went unansweredAn alert on bursts of denied calls from a single principal
AU-12 Audit Record GenerationS3 data events were enabledNothing failed here. This is the control that proved the file left

All six controls are in the FedRAMP High baseline.

What I’d check next time

The last row matters most to me. ListObjects and GetObject are S3 data events, and CloudTrail doesn’t log them by default. Without them, this investigation ends at “AssumeRole succeeded,” and nobody can say what was taken.

The lab is Breach in the Cloud on Pwned Labs.