New to Claude Skills? Learn how to install them →

mukul975 on GitHub

Detecting AWS CloudTrail Anomalies

Free

Identify security threats in AWS CloudTrail logs.

Get this skill

Free · Opens the source repo

What Detecting AWS CloudTrail Anomalies does

Detecting AWS CloudTrail Anomalies is a skill designed to help security professionals monitor and analyze AWS CloudTrail logs for unusual API call patterns. By leveraging the boto3 library, this skill enables users to query CloudTrail events, establish baselines of normal API activity, and detect anomalies that may indicate security threats such as credential compromise or unauthorized access. This skill is particularly useful for Security Operations Center (SOC) analysts and incident responders who require structured procedures for identifying and investigating potential security incidents.

The skill operates by first querying recent CloudTrail events using boto3's lookup_events API. This allows users to retrieve a comprehensive view of API activity across their AWS environment. Next, it builds a statistical baseline of normal behavior by aggregating events based on user, source IP, event source, and event name. This baseline serves as a reference point for detecting anomalies.

Once the baseline is established, the skill flags unusual patterns, such as new event sources for a user, first-time API calls, geographic IP changes, and high error rates. These indicators can suggest compromised credentials or insider threats. The output is a detailed JSON report that includes anomaly scores, statistics on suspicious users and IPs, and recommendations for further investigation, making it easier for analysts to prioritize their response efforts.

This skill is ideal for organizations that utilize AWS and need to enhance their cloud security posture by proactively monitoring for potential threats. It is particularly beneficial for teams focused on threat detection and incident response, as it provides actionable insights into API activity and potential vulnerabilities within their AWS infrastructure.

When to use it

Use this skill when investigating security incidents or when building detection rules for AWS CloudTrail anomalies.

When not to use it

This skill may not be suitable for environments without CloudTrail enabled or for users unfamiliar with AWS IAM and API patterns.

What you can build with it

Security Incident Investigation

Use this skill to analyze CloudTrail logs during a security incident to identify unusual API call patterns that may indicate a breach.

Threat Hunting

Employ this skill to proactively hunt for threats by establishing baselines of normal API activity and detecting deviations.

Compliance Monitoring

Utilize this skill to validate security monitoring coverage and ensure compliance with security best practices related to AWS API usage.

How to install Detecting AWS CloudTrail Anomalies

View source

1. Install with the skills CLI

npx skills add mukul975/anthropic-cybersecurity-skills/detecting-aws-cloudtrail-anomalies --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mukul975

Detecting AWS CloudTrail Anomalies

Overview

AWS CloudTrail records API calls across AWS services. This skill covers querying CloudTrail events with boto3's lookup_events API, building statistical baselines of normal API activity, detecting anomalies such as unusual event sources, geographic anomalies, high-frequency API calls, and first-time API usage patterns that indicate compromised credentials or insider threats.

When to Use

  • When investigating security incidents that require detecting aws cloudtrail anomalies
  • When building detection rules or threat hunting queries for this domain
  • When SOC analysts need structured procedures for this analysis type
  • When validating security monitoring coverage for related attack techniques

Prerequisites

  • Python 3.9+ with boto3 library
  • AWS credentials with CloudTrail read permissions (cloudtrail:LookupEvents)
  • Understanding of AWS IAM and common API patterns
  • CloudTrail enabled in target AWS account (management events at minimum)

Steps

Step 1: Query CloudTrail Events

Use boto3 CloudTrail client's lookup_events to retrieve recent API activity with pagination.

Step 2: Build Activity Baseline

Aggregate events by user, source IP, event source, and event name to establish normal behavior patterns.

Step 3: Detect Anomalies

Flag unusual patterns: new event sources per user, first-time API calls, geographic IP changes, high error rates, and sensitive API usage (IAM, KMS, S3 policy changes).

Step 4: Generate Detection Report

Produce a JSON report with anomaly scores, top suspicious users, and recommended investigation actions.

Expected Output

JSON report with event statistics, baseline deviations, anomalous users/IPs, sensitive API calls, and error rate analysis.

Frequently asked questions about Detecting AWS CloudTrail Anomalies

Similar skills