Join our Newsletter — 33% off our NHI Course

How should security teams hunt for compromised AWS credentials in CloudTrail logs?

Start by looking for anomalous role assumptions that do not match normal automation patterns. A useful signal is an AssumeRole event with an unexpected user agent, such as a Python SDK where a CI/CD pipeline normally uses a Java SDK. Combine that with scheduled queries, review the surrounding activity, and investigate any role that shows unusual access patterns before assuming the behavior is legitimate.

How CloudTrail helps you distinguish compromise from normal automation

CloudTrail hunting works best when you treat AWS credential compromise as a behavioural anomaly problem, not a single-event alert. The strongest signal is often a role assumption that looks technically valid but breaks the pattern of the workload that normally uses it, especially when the user agent, calling service, region, timing, or source account deviates from expected automation.

That means the hunt should begin with the Guide to the Secret Sprawl Challenge mindset: assume the credential may have originated from exposed CI/CD material, hardcoded config, or a leaked token, then trace whether the surrounding CloudTrail activity matches the known control plane behaviour. If a role is normally assumed by a Java SDK in a pipeline and suddenly appears through a Python SDK from an unfamiliar path, that is a meaningful lead, not proof by itself.

CloudTrail gives you the timeline needed to separate a single suspicious assumption from a broader compromise chain. Review the events before and after the first unusual AssumeRole, including subsequent API calls, privilege expansion, and any access to services that the role does not normally touch. When the role is legitimate but the access pattern is not, the problem is often stolen credentials or an abused session rather than a broken application.

What to review around the suspicious role assumption

Once you have a candidate role, broaden the hunt from one event to one session. Compare the role’s normal access pattern against the current sequence: which principals assumed it, from which IP ranges or source services, at what hours, and with what user agents. Sudden changes in geography, automation identity, or toolchain fingerprints matter because they often reveal a compromised credential being used outside its usual operational lane.

It is also useful to check whether the role starts touching resources that align with known credential abuse patterns. For example, the Amazon AWS Hacked Accounts Crypto-Mining case shows how compromised IAM credentials can be quickly repurposed for abuse after initial access, while the Codefinger AWS S3 ransomware attack illustrates how stolen AWS credentials can be used for destructive follow-on activity. Those patterns are valuable because they remind hunters to look past the first sign-in and into the attacker’s next likely move.

When the evidence is thin, use correlation rather than certainty. A single odd user agent may simply reflect a library upgrade, but the same event becomes more concerning when it aligns with unusual access depth, a new source location, and API calls the workload has never made before. The surrounding context is what turns CloudTrail noise into a credible compromise hypothesis.

How to operationalise the hunt without drowning in false positives

Security teams get the best results when CloudTrail hunting is built as a repeatable detection workflow. Scheduled queries should baseline the normal role-usage profile first, then flag deviations in user agent, session duration, region, source principal, and action sequence. That approach is more effective than alerting on every AssumeRole event because valid automation will generate lots of benign noise.

For teams that need a broader control lens, the OWASP Non-Human Identity Top 10 is a useful external reference for understanding why compromised machine credentials behave differently from human account abuse, while CSA Cloud Controls Matrix helps map log review, IAM governance, and detection coverage into cloud control expectations. On the practical side, teams often anchor this hunt in the same logic that underpins the Ultimate Guide to NHIs, Static vs Dynamic Secrets: long-lived credentials and weak visibility make compromise much harder to distinguish from routine activity.

Practitioner takeaway: The goal is not to hunt every AssumeRole event, it is to identify sessions whose behaviour no longer matches the workload that normally owns them, then prove whether the deviation is operational drift or credential abuse.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-01 — Secrets and Credential Management CloudTrail hunts hinge on compromised non-human credentials and leaked keys.
NHI-03 — Identity Lifecycle and Rotation Long-lived AWS credentials are easier to abuse and harder to spot in logs.
Recommendation — Correlate suspicious role assumptions with secret exposure paths and rotate compromised credentials immediately. Shorten credential lifetimes and enforce rotation for roles that show anomalous use.
NIST CSF 2.0 DE.CM — Continuous Monitoring CloudTrail hunting is a continuous monitoring activity over cloud identity events.
DE.AE — Anomalies and Events The hunt depends on identifying anomalous user agents, timing, and access sequences.
Recommendation — Monitor AWS identity events continuously and tune detections around abnormal access patterns. Alert on anomalous role assumptions and investigate them with surrounding event context.
CIS Controls v8 5.1 — Establish and Maintain an Inventory of Accounts Hunting requires knowing which AWS roles and automation accounts should exist.
8.2 — Audit Log Management CloudTrail is the audit log source for tracing suspicious credential use.
Recommendation — Inventory AWS roles and service principals so unusual assumptions stand out quickly. Centralise and retain CloudTrail logs so investigators can reconstruct role activity accurately.
MITRE ATT&CK T1078 — Valid Accounts Stolen AWS credentials are abused as valid accounts to blend into normal activity.
T1580 — Cloud Infrastructure Discovery Attackers often follow credential use with cloud discovery after initial access.
T1528 — Steal Application Access Token Cloud credential theft commonly involves tokens, keys, and session material.
Recommendation — Hunt for valid-account abuse by comparing each session to the role’s expected behaviour. Check for follow-on discovery calls after the first suspicious role assumption. Investigate how the AWS credential was obtained and look for adjacent token theft activity.