Skip to main content

CloudTrail anomaly detection

How an AI SOC detects risky AWS activity in CloudTrail, such as access keys created outside Terraform, and investigates every alert it raises.

Use case
Updated

The short answer

CloudTrail anomaly detection watches AWS management events for actions that should be rare, such as access keys created outside infrastructure as code. Cotool ingests CloudTrail into an aws_cloudtrail table, Python detections run on it, and an agent investigates every alert they raise.[1][2]

The problem

Adversaries add credentials to cloud accounts to keep access, for example new keys or passwords for service principals and applications.[8]

CloudTrail's LookupEvents covers one Region's management events from the last 90 days, so longer history and cross-account search need the logs stored.[9]

How an AI SOC handles it

  1. Ingest CloudTrail

    CloudTrail files land in S3, S3 notifies an SQS queue dedicated to Cotool, and Cotool unwraps the Records envelope into the aws_cloudtrail table.[1]

  2. Write the detection

    From an editor connected to Cotool's MCP server, a coding agent searched 30 days of CreateAccessKey events, created a detection for keys made outside Terraform, tested it, and deployed it.[2]

  3. Investigate each hit

    The agent pulls the principal's recent calls and attached policies through the AWS CLI integration and looks for a change ticket that explains the key.[3][4][9]

  4. Close the loop

    Each verdict feeds back into the detection, so expected automation gets tuned out.[2]

Example

Access keys created in the last daysql
SELECT event_time, actor, actor_type, ip_address, account_id, region, outcome
FROM aws_cloudtrail
WHERE action = 'CreateAccessKey'
  AND event_time > now() - INTERVAL 1 DAY
ORDER BY event_time DESC
LIMIT 100

A Log Search query in ClickHouse SQL over Cotool's CloudTrail table. Column names follow Cotool's CloudTrail mapping; confirm them in your workspace.[1][5]

What people approve

  • Deactivating a key or changing IAM is a state-changing action that can require a person's approval.[6]
  • Response agents cannot close an alert as True Positive. When an agent confirms malicious activity, it escalates the alert and a person closes it.[7]

How Cotool handles it

  • Cotool's CloudTrail and GCP audit log tables share actor, action, and resource columns, so one query can follow an identity across both clouds.[1]

Integrations used

Sources

  1. AWS S3/SQS log ingest (Cotool docs) · accessed November 16, 2026
  2. Detection engineering (Cotool Detect) · accessed November 16, 2026
  3. Changelog (Cotool docs) · accessed November 16, 2026
  4. Respond to every signal (Cotool Respond) · accessed November 16, 2026
  5. Search logs (Cotool docs) · accessed November 16, 2026
  6. AI SOC (Cotool) · accessed November 16, 2026
  7. Alerts (Cotool docs) · accessed November 16, 2026
  8. Additional Cloud Credentials, T1098.001 (MITRE ATT&CK) · accessed November 16, 2026
  9. LookupEvents (AWS CloudTrail API Reference) · accessed November 16, 2026

Related use cases

All use cases

Related reading

Attackers are scaling with tokens

Cotool helps defenders operate at machine speed. See how security teams are scaling Detection & Response.

Book a demo