How To Use AWS CloudTrail For Intrusion Detection To Monitor Your AWS Account For Unwanted Activity

Published Date Author: , Posted December 30th, 2022 at 11:46:21am

Summary

Use AWS CloudTrail as the basis for a simple Intrusion Detection System to monitor your AWS account for unwanted activity.

Background

While I follow best practices for security, it is always possible that a bad actor could obtain my credentials and gain access to my AWS account.

Once access is gained, such criminals could launch new, maximum-sized instances all over the world and proceed to harness them for nefarious purposes, often for DDoS attacks and crypto-mining.

These instances can accrue enormous charges in a short time given the cost per instance times the quantity launched.

Attacks like this can cripple an organization financially, especially because Amazon Web Services are NOT flexible about refunding such charges if they happen more than once.

AWS-based Solutions

AWS itself offers a number of paid services to assist with account security, including CloudWatch and Trusted Advisor.

While they are no doubt excellent offerings, I was reluctant to pay more than I had to, and the CloudWatch tool seemed like overkill in terms of complexity.

Chosen Solution

While CloudWatch did not work for me, the underlying CloudTrail service in fact was the answer, when used with the aws command-line tool to query the associated event data periodically via cron for non-Read-Only events.

This solution required me to roll my own tool (in Perl) to interpret the data and alert via email under the desired circumstances.

Solution Steps

Example CLI Call

Example Crontab Entry

Example Parsing Logic (Perl)

List of AWS Regions

ap-south-1
eu-north-1
eu-west-3
eu-west-2
eu-west-1
ap-northeast-3
ap-northeast-2
ap-northeast-1
ca-central-1
sa-east-1
ap-southeast-1
ap-southeast-2
eu-central-1
us-east-1
us-east-2
us-west-1
us-west-2

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.