Sub topic 14
Investigating with Amazon Detective
This chapter assumes you can read a GuardDuty finding (type, severity, resource, actor) and have GuardDuty enabled in at least one Region. You should also be comfortable running AWS CLI commands.
What Detective adds
GuardDuty tells you that something suspicious happened. Amazon Detective helps you work out what else happened around it. Detective is a service that collects log data from your accounts and builds a behavior graph. A behavior graph is a linked model of entities, such as IAM roles, EC2 instances and IP addresses, and the interactions between them over time.
Detective ingests these sources automatically once you enable it:
- AWS CloudTrail management events
- Amazon VPC Flow Logs
- GuardDuty findings
- Amazon EKS audit logs, when you use EKS
You do not turn these logs on separately for Detective, and Detective does not read them from your own log buckets. Its data is retained for up to a year, which is much longer than most teams keep raw logs searchable.
Prerequisites and scope
- Detective is Regional. Each Region has its own behavior graph.
- GuardDuty must have been enabled in the account for a while, documented as at least 48 hours, before you enable Detective.
- New accounts get a free trial, so check current pricing before you roll it out. Cost is covered in a later chapter.
Enabling Detective
Enabling Detective means creating a behavior graph. The account that creates it becomes the administrator of that graph.
aws detective create-graph
aws detective list-graphscreate-graph returns a GraphArn. You pass that ARN to later commands. In an Organization, you designate a delegated administrator for Detective in the same way as for GuardDuty and Security Hub.
From finding to investigation
The usual path starts in a GuardDuty finding. The console offers an Investigate action that opens the related entity in Detective, so you do not have to search for it by hand.
Inside Detective, three views do most of the work:
- Entity profiles. Each IAM role, user, EC2 instance or IP address has a profile that shows its recent activity against a baseline. A role that normally makes 50 API calls a day and suddenly makes 5,000 stands out.
- Finding groups. Detective clusters related findings, such as several findings from one compromised credential, into one group. This lets you handle one incident instead of ten alerts.
- Investigations. Detective can run an automated investigation on an IAM user or role. It looks for indicators such as impossible travel, new geolocations and unusual API calls, and it reports them with a severity.
Questions to ask
When you pivot, check the following:
- Is this entity's behavior new, or has it done this before?
- Which IP addresses and geolocations did the role use, and are they new?
- Which API calls failed or succeeded, and which resources did they touch?
- Do other findings share the same entity or IP address?
When to use Detective
| Situation | Use |
|---|---|
| Finding is a known sample or a known scanner | Archive or suppress in GuardDuty |
| Finding involves an IAM credential or unexpected API activity | Detective |
| You need a count or trend across many findings | Security Hub |
| You need to act automatically | EventBridge and Lambda |
Exercise
A GuardDuty finding shows that an IAM role called an API from an unfamiliar IP address. Which Detective view helps you tell whether the role normally behaves this way, and why?
Show answer
The entity profile for the role. It compares recent activity, such as API call volume and source IP addresses and geolocations, with the role's baseline, so you can see whether the new address is truly unusual.