Skip to content

SSZcreate/Pentab_server / .agents/skills/cybersecurity/skills/implementing-cloud-trail-log-analysis

implementing-cloud-trail-log-analysis

Verified

Implementing AWS CloudTrail log analysis for security monitoring, threat detection, and forensic investigation using Athena, CloudWatch Logs Insights, and SIEM integration to identify unauthorized access, privilege escalation, and suspicious API activity.

FileKindSize
LICENSEother11.0 KB
SKILL.mdskill md13.3 KB
references/api-reference.mdmarkdown2.2 KB
scripts/agent.pyscript7.4 KB

references/api-reference.md

View on GitHub
# API Reference: Implementing CloudTrail Log Analysis

## Libraries

### boto3 -- AWS CloudTrail
- **Install**: `pip install boto3`
- **Docs**: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudtrail.html

### Key Methods

| Method | Description |
|--------|-------------|
| `lookup_events()` | Search recent CloudTrail events with filters |
| `describe_trails()` | List configured trails |
| `get_trail_status()` | Check if trail is actively logging |
| `create_trail()` | Create a new CloudTrail trail |
| `start_logging()` / `stop_logging()` | Control trail recording |
| `get_event_selectors()` | View event type configuration |
| `put_event_selectors()` | Configure management/data event capture |

## Lookup Attributes

| AttributeKey | Description |
|-------------|-------------|
| `EventName` | API action name (e.g., `RunInstances`) |
| `Username` | IAM user or role name |
| `ResourceType` | AWS resource type |
| `ResourceName` | Specific resource identifier |
| `EventSource` | AWS service (e.g., `ec2.amazonaws.com`) |
| `ReadOnly` | Filter read vs write events |

## Suspicious Event Names

| Event | Threat Category |
|-------|----------------|
| `StopLogging` / `DeleteTrail` | Anti-forensics |
| `CreateUser` / `CreateAccessKey` | Persistence |
| `AttachUserPolicy` / `PutUserPolicy` | Privilege escalation |
| `ConsoleLogin` (failed) | Brute force |
| `RunInstances` | Resource abuse / cryptomining |
| `AuthorizeSecurityGroupIngress` | Lateral movement |
| `DisableKey` | Ransomware indicator |

## Athena Query Integration
- Create Athena table from CloudTrail S3 logs
- SQL queries for historical analysis beyond 90-day API limit
- Partition by region, year, month for performance

## CloudWatch Logs Insights
- `filter eventName = "ConsoleLogin"` -- Login analysis
- `stats count(*) by eventName` -- API call frequency
- `filter errorCode = "AccessDenied"` -- Permission issues

## External References
- CloudTrail User Guide: https://docs.aws.amazon.com/awscloudtrail/latest/userguide/
- CloudTrail Log Events: https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html
- Athena + CloudTrail: https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 192kUpdated Claude CodeCodexVerifiedInstall