Hunting Agentic AI Intrusions in AWS: CloudTrail Detections for Machine-Speed Recon
An AI-driven intrusion doesn't look like a human operator. It looks like hundreds of API calls across dozens of AWS services in half an hour, most of them denied, and one that isn't. How agentic attack frameworks behave in the cloud, the CloudTrail signals that give them away, and the controls that make a stolen key worthless.
For years, cloud intrusions moved at human speed. An operator with a stolen access key would run aws sts get-caller-identity, poke at S3, list a few roles, then go quiet while they worked out what they had. Detections were tuned for that rhythm.
Agentic attack frameworks don't work like that. Give an AI agent a credential and a goal, and it enumerates everything the key can reach, reasons over the responses, and pivots, all within minutes. In November 2026, Arctic Wolf Labs linked a series of AWS intrusions to infrastructure hosting AntiFox, an open-source agentic penetration-testing platform. In one case the activity generated hundreds of cross-service API calls in about 30 minutes, most of them denied, and ended with a successful read of a production secret from AWS Secrets Manager.
This article breaks down how these intrusions unfold, why their shape makes them easier to catch than a careful human, and the CloudTrail detections and controls that work against them. Queries are given in Amazon Athena SQL and in KQL for Microsoft Sentinel.
Anatomy of an agentic cloud intrusion
The reported AntiFox-linked activity followed two entry paths that converge on the same pattern.
- Web server to cloud key. Attackers compromised internet-facing IIS applications, planted ASPX web shells, and read database and AWS credentials from configuration files such as
web.config. The initial vulnerability wasn't identified. - Key first. In other cases, the intrusion simply began with a valid AWS access key of unknown origin: leaked in a repository, a CI log, or a developer laptop.
From there, the agent works through a recognisable loop:
| Phase | What it does | CloudTrail evidence |
|---|---|---|
| Orient | "Who am I?" | GetCallerIdentity, GetUser |
| Map identity | Users, roles, policies, keys | ListUsers, ListRoles, ListPolicies, ListAccessKeys, ListKeys (KMS) |
| Sweep services | Try every service the model knows about | List* and Describe* across dozens of event sources, mostly AccessDenied |
| Pivot identities | Switch to other credentials it finds | Same burst pattern from a second and third access key |
| Collect | Read whatever the key can reach | ListSecrets, then GetSecretValue; S3 ListBuckets/GetObject |
| Monetise | In some campaigns, AI model access itself is the prize | Bedrock model listing and invocation calls |
The key insight for defenders: an agent doesn't know your environment, so it tries everything. A human attacker who already knows what they want makes ten quiet calls. An agent makes three hundred noisy ones. That breadth, and the wall of denials it produces, is the strongest signal you'll get.
Why the denials matter
Most security teams treat AccessDenied errors as noise: misconfigured apps, developers testing permissions. In an agentic intrusion, the denials are the attack. A legitimate workload calls the same handful of APIs in a stable pattern, day after day. An agent sweeping your account calls many distinct services, gets refused by most of them, and keeps going. Least privilege is doing its job in that moment. Your detections should notice it happening.
The telemetry you need
| Source | Where | Why it matters |
|---|---|---|
| CloudTrail management events | Organisation trail to S3, CloudTrail Lake, or Sentinel AWSCloudTrail |
Every API call, including denied ones, with identity, source IP and user agent |
| CloudTrail data events | Enabled per resource type | S3 object reads and Lambda invocations; off by default and billed separately |
| Amazon GuardDuty | Delegated administrator account | Anomaly findings on IAM behaviour and credential exfiltration |
| Web server and endpoint logs | IIS logs, EDR or Sysmon | The web shell that leads to the key |
| AWS Config / IAM Access Analyzer | Organisation-wide | Which keys exist, how old they are, and what they can reach |
Two gaps to close first. Use an organisation trail covering every region: agents sweep regions you don't use, and a single-region trail misses them. Retain at least 90 days in a queryable store; leaked keys are often used weeks after they're stolen.
Detections that hold up
1. One principal, many services, many denials
This is the core detection: a single access key or role session touching an unusual number of distinct AWS services in a short window, with a high share of denied calls.
Athena (CloudTrail table created from the standard CloudTrail partitioned schema):
-- Principals that touched 15+ services in any 30-minute window, mostly denied
SELECT useridentity.arn AS principal,
useridentity.accesskeyid AS access_key,
date_trunc('hour', from_iso8601_timestamp(eventtime)) AS hour,
count(DISTINCT eventsource) AS services,
count(*) AS calls,
count_if(errorcode IN ('AccessDenied', 'Client.UnauthorizedOperation',
'UnauthorizedOperation', 'AccessDeniedException')) AS denied,
array_agg(DISTINCT sourceipaddress) AS source_ips
FROM cloudtrail_logs
WHERE from_iso8601_timestamp(eventtime) > current_timestamp - INTERVAL '1' DAY
GROUP BY 1, 2, 3
HAVING count(DISTINCT eventsource) >= 15
AND count_if(errorcode IS NOT NULL) * 1.0 / count(*) > 0.5
ORDER BY services DESC;KQL (Microsoft Sentinel):
AWSCloudTrail
| where TimeGenerated > ago(1d)
| summarize Services = dcount(EventSource),
Calls = count(),
Denied = countif(ErrorCode in ("AccessDenied", "Client.UnauthorizedOperation",
"UnauthorizedOperation", "AccessDeniedException")),
IPs = make_set(SourceIpAddress, 10),
Agents = make_set(UserAgent, 5)
by UserIdentityArn, UserIdentityAccessKeyId, bin(TimeGenerated, 30m)
| where Services >= 15 and Denied * 1.0 / Calls > 0.5
| order by Services descStart with a threshold of 15 services and tune from there. Legitimate tools that also sweep accounts, such as CSPM scanners and IaC drift detection, will appear: allow-list them by role ARN and source, never by user agent, which an attacker controls.
2. The needle: a success hidden in a wall of denials
The outcome that matters is the one call that worked. Look for a sensitive read by a principal that was denied many times in the hour before.
let noisy = AWSCloudTrail
| where TimeGenerated > ago(1d) and isnotempty(ErrorCode)
| summarize Denied = count(), FirstDenied = min(TimeGenerated) by UserIdentityArn
| where Denied >= 25;
AWSCloudTrail
| where TimeGenerated > ago(1d) and isempty(ErrorCode)
| where EventName in ("GetSecretValue", "BatchGetSecretValue", "GetParameter", "GetParameters",
"Decrypt", "GetObject", "CreateAccessKey", "AssumeRole")
| join kind=inner noisy on UserIdentityArn
| where TimeGenerated between (FirstDenied .. FirstDenied + 2h)
| project TimeGenerated, UserIdentityArn, EventName, EventSource, SourceIpAddress, Denied,
RequestParameters
| order by TimeGenerated ascA GetSecretValue success after dozens of denials is about as close to a guaranteed true positive as cloud detection gets. Treat it as an incident, not an alert.
3. A key used from somewhere it has never been
Keys that live in application configs are used from a small, stable set of addresses: your servers, your NAT gateways. The first call from a new network, especially a hosting provider, deserves attention.
-- Access keys seen today from a source IP not seen for that key in the previous 30 days
WITH history AS (
SELECT DISTINCT useridentity.accesskeyid AS k, sourceipaddress AS ip
FROM cloudtrail_logs
WHERE from_iso8601_timestamp(eventtime)
BETWEEN current_timestamp - INTERVAL '31' DAY AND current_timestamp - INTERVAL '1' DAY
)
SELECT t.useridentity.accesskeyid AS access_key, t.useridentity.arn AS principal,
t.sourceipaddress, min(t.eventtime) AS first_seen, count(*) AS calls
FROM cloudtrail_logs t
LEFT JOIN history h ON h.k = t.useridentity.accesskeyid AND h.ip = t.sourceipaddress
WHERE from_iso8601_timestamp(t.eventtime) > current_timestamp - INTERVAL '1' DAY
AND t.useridentity.accesskeyid LIKE 'AKIA%' -- long-lived IAM user keys
AND h.k IS NULL
GROUP BY 1, 2, 3
ORDER BY calls DESC;Long-lived keys start with AKIA; temporary session keys start with ASIA. Long-lived keys used from new networks are the highest-risk combination. Enrich the source IP with ASN data and weight hosting providers heavily. GuardDuty's UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS finding covers the related case of instance role credentials used from outside AWS.
4. The web shell that leads to the key
On the IIS side, the classic signal still works: the web server worker process starting a shell.
// Microsoft Defender for Endpoint / Sentinel
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| where InitiatingProcessFileName =~ "w3wp.exe"
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "certutil.exe", "whoami.exe",
"net.exe", "net1.exe", "rundll32.exe")
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessCommandLinePair it with file monitoring for new .aspx, .ashx or .asmx files under web roots, and with reads of web.config by anything other than the web server. Then correlate: a web shell alert on a server, followed by that server's AWS key appearing from a new IP, is a single incident told in two log sources.
5. Somebody else spending your AI budget
Several of these campaigns enumerated Amazon Bedrock. Stolen keys with model access are resold for free LLM usage ("LLMjacking"), and the first sign is often the bill.
AWSCloudTrail
| where TimeGenerated > ago(1d) and EventSource == "bedrock.amazonaws.com"
| summarize Calls = count(), Events = make_set(EventName, 20), IPs = make_set(SourceIpAddress, 10)
by UserIdentityArn
| join kind=leftanti (
AWSCloudTrail
| where TimeGenerated between (ago(30d) .. ago(1d)) and EventSource == "bedrock.amazonaws.com"
| distinct UserIdentityArn
) on UserIdentityArnAny principal calling Bedrock for the first time, especially ListFoundationModels, GetModelInvocationLoggingConfiguration or model invocation calls, should be checked against its owner's intent. Note that InvokeModel is a data event and needs to be enabled to appear.
Controls that make a stolen key worthless
Detection buys time. These controls remove the payoff, roughly in order of impact.
- No long-lived keys in application config. Workloads on EC2, ECS, EKS and Lambda should use IAM roles. On-premises servers can use IAM Roles Anywhere. A
web.configwith no secret in it gives a web shell nothing to steal. Find existing keys with IAM credential reports and remove any older than 90 days. - Enforce IMDSv2 on every instance, so a server-side request forgery on the web tier can't simply read role credentials from the metadata service.
- Data perimeters. Use
aws:SourceVpc,aws:SourceVpceoraws:SourceIpconditions in policies, and resource policies on Secrets Manager secrets and S3 buckets, so a valid key used from outside your network is refused. This is the single control that defeats "valid key, attacker's laptop". - Least privilege, measured. IAM Access Analyzer's unused-access findings show the permissions and keys nobody uses. Remove them: every service an agent can't touch is one fewer path.
- Service control policies that deny regions you don't operate in, and deny Bedrock model access outside approved accounts.
- GuardDuty in every account and region, with findings routed to the same queue as your own detections.
- Secrets hygiene. Rotate secrets automatically, scope each secret's resource policy to the roles that need it, and alert on
GetSecretValueby any principal outside that set.
Incident response checklist
When the detections above fire together, or a successful sensitive read follows a denial burst:
- Disable, don't delete, the access key (
aws iam update-access-key --status Inactive), so evidence stays intact. For roles, revoke active sessions with anaws:TokenIssueTimedeny policy. - Scope the blast radius: pull every CloudTrail event for the key and any identities it pivoted to, across all regions, from first sighting.
- Rotate every secret the principal read, starting with anything returned by
GetSecretValueorGetParameter, then any database credentials found in the compromised server's config. - Check for persistence: new IAM users, access keys, login profiles, roles with external trust policies, Lambda functions, and changes to CloudTrail or GuardDuty settings.
- Clean the entry point: remove web shells, patch the IIS application, and rebuild the server if you can't establish its integrity.
- Check billing for Bedrock, EC2 or other usage spikes the intrusion may have caused.
- Find the source of the key if it didn't come from the web server: secret scanning across repositories, CI logs and developer machines.
MITRE ATT&CK mapping
- T1078.004 Valid Accounts: Cloud Accounts
- T1552.001 Unsecured Credentials: Credentials In Files
- T1505.003 Server Software Component: Web Shell
- T1526 Cloud Service Discovery
- T1580 Cloud Infrastructure Discovery
- T1087.004 Account Discovery: Cloud Account
- T1555.006 Credentials from Password Stores: Cloud Secrets Management Stores
Key takeaways
- Agentic intrusions are loud by nature. An agent doesn't know your environment, so it tries everything: many services, many denials, very little time.
- Stop treating
AccessDeniedas noise. A burst of denials across many services is the attack in progress, and least privilege is buying you time. - The success hidden among the failures is the incident. Alert on sensitive reads by a principal that was just denied dozens of times.
- Remove the prize: no long-lived keys in config files, IMDSv2 everywhere, and data perimeters so a stolen key fails from outside your network.
Further reading
- Cloud Security Alliance: AntiFox in the wild
- The Hacker News: AntiFox linked to attacks that accessed AWS production secrets
- Arctic Wolf detection pack (GitHub)
- AWS: Querying CloudTrail logs with Athena
- AWS: Building a data perimeter
- Microsoft: AWSCloudTrail table reference
- Related on HackersRoot: AiTM phishing and session token theft · Prompt injection in AI agents · Daily Digest, 12 November 2026
Related research
The Key Nobody Retired: How a Forgotten AI-Vendor Credential Breached Barracuda's Cloud in 44 Hours
Barracuda has owned a hard truth: a cloud access key it handed a third-party AI vendor, and never retired when the work ended, was leaked and used to reach around ten of its cloud accounts in 44 hours. It is a textbook non-human identity failure. Here is the timeline, the blast radius, and how to make sure your own forgotten keys can't do this.
AiTM Phishing and Session Token Theft in Microsoft 365: Detection and Defence
Adversary-in-the-middle phishing doesn't break MFA, it walks around it: the victim completes a real sign-in and the attacker keeps the session cookie. How the attack works, the telemetry that exposes it, KQL detections for Entra ID, and the controls that make stolen tokens worthless.
Detecting OAuth Consent Phishing in Microsoft Entra ID
Consent phishing skips passwords and MFA entirely: the victim grants a malicious app access to their mailbox or files. How illicit consent grants work, KQL to find them in Entra ID audit logs, and the tenant settings that stop them.