Sub topic 2
How GuardDuty detects threats
This chapter explains what data Amazon GuardDuty reads, how it turns that data into findings, and what it cannot see. It assumes you know AWS accounts, Regions, and IAM basics. It also assumes you know what AWS CloudTrail, VPC Flow Logs, and Route 53 DNS logs are, and that you can read JSON and run AWS CLI commands.
The core idea
GuardDuty is a managed threat detection service. You turn it on, and it analyzes activity data from your account and produces findings, which are records describing suspicious behavior. You do not deploy agents or sensors for the foundational detection. You do not configure log delivery or buy log storage for GuardDuty to read.
This works because GuardDuty reads its own independent copies of the data streams directly from AWS. That has three consequences:
- You do not need to enable CloudTrail, VPC Flow Logs, or DNS query logging yourself.
- GuardDuty does not change your existing logging configuration. Turning off your own flow logs does not stop GuardDuty from analyzing network traffic.
- GuardDuty does not store the raw logs for you. You cannot query them later, so keep your own logs if you need them for forensics.
Foundational data sources
Three sources are analyzed as soon as GuardDuty is enabled.
| Source | What it contains | Example threats it reveals |
|---|---|---|
| CloudTrail management events | API calls that create, change, or inspect resources, including IAM and console sign-in activity | Credentials used from an unusual location, logging disabled, unusual IAM changes |
| VPC Flow Logs | Network connection metadata for EC2 network interfaces: addresses, ports, protocol, byte counts | Port probing, SSH brute force, traffic to known malicious IPs |
| Route 53 Resolver DNS query logs | DNS lookups made by resources that use the VPC resolver | Queries for known malware or command-and-control domains, DNS tunneling patterns |
Some details matter in practice.
- Flow logs cover network metadata, not payloads. GuardDuty sees who talked to whom, on which port, and how much data moved. It never sees packet contents, so it cannot inspect encrypted or unencrypted payloads.
- DNS analysis depends on the resolver. GuardDuty sees only queries sent to the Route 53 Resolver, which is the default for EC2 instances. If an instance uses a third-party or self-managed DNS server, those queries are invisible to the DNS data source.
- CloudTrail coverage is management events by default. Data events, such as S3 object-level API calls, are analyzed only when you enable the matching protection plan (next chapter).
A single event can be visible to more than one source. An instance that talks to a malicious host appears in flow logs, and the DNS lookup that preceded it appears in the DNS logs. Findings from different sources about the same resource help you judge how serious the activity is.
Detection techniques
GuardDuty combines several techniques. Knowing which one produced a finding helps you decide whether it is a policy problem or real compromise.
- Threat intelligence. GuardDuty compares IP addresses and domains in your activity against lists of known malicious indicators. These come from AWS security research and third-party feeds. A match is high-confidence evidence, though not proof of a breach.
- Anomaly detection and machine learning. GuardDuty builds a behavioral baseline for your account. It learns which APIs, from which locations, by which principals, are normal. It flags deviations, such as an IAM user who normally works from one country suddenly calling APIs from another. The baseline takes time to form, so anomaly findings can be noisy in a new or unusually active account.
- Rule-based and pattern detection. Some findings match known attack shapes, such as repeated failed SSH logins from one source, which becomes an SSH brute force finding.
The finding type name tells you which family you are looking at. Names follow the pattern ThreatPurpose:ResourceTypeAffected/ThreatFamilyName.DetectionMechanism, for example UnauthorizedAccess:EC2/SSHBruteForce. The next chapter covers reading these in detail.
From data to finding
The diagram shows the path from raw activity to the places you act on it.
GuardDuty works on a stream with some delay. It does not evaluate each event the instant it happens. New findings usually appear within minutes of the activity being processed, but you should not expect real-time blocking. GuardDuty detects. It does not prevent traffic or revoke credentials. Prevention and response are jobs for the services and automation you build around it, which later chapters cover.
The detector
The unit of configuration is the detector. A detector is a resource in one account and one Region that represents GuardDuty being on there. Key facts:
- One detector per account per Region. GuardDuty is regional. Enabling it in
us-east-1does nothing foreu-west-1. - Findings belong to the detector's Region. Threats in a Region you never use can go unnoticed if GuardDuty is off there. Attackers often run resources in unused Regions for exactly this reason, so enable GuardDuty in every Region you can.
- The detector holds settings, such as which protection plans are on and how often updated findings are published.
You create and inspect a detector with the CLI:
aws guardduty create-detector --enable --finding-publishing-frequency FIFTEEN_MINUTES
DETECTOR_ID=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text)
aws guardduty get-detector --detector-id "$DETECTOR_ID"The --finding-publishing-frequency setting controls how often GuardDuty sends updates to existing findings to EventBridge. The allowed values are FIFTEEN_MINUTES, ONE_HOUR, and SIX_HOURS. The default is six hours. This setting does not delay the first notification for a new finding. It governs repeat updates, such as an increased occurrence count on a finding that is still happening.
get-detector returns the detector's status, its service role, and its data source or feature settings. Check it after enabling to confirm the status is ENABLED.
What GuardDuty does and does not see
Understanding blind spots prevents false confidence.
- It sees activity visible to the three sources. An attacker who steals credentials and calls AWS APIs is visible through CloudTrail. An attacker who compromises a workload and keeps all activity inside the host, with no unusual network or DNS behavior, may not be.
- It does not inspect data at rest or application logic. Vulnerabilities in your code, misconfigured security groups, and public S3 buckets are not threats it detects. Those are posture problems, which AWS Security Hub and similar checks address later in this tutorial.
- It does not see inside hosts by default. Process and file activity on instances, containers, and servers needs the Runtime Monitoring protection plan.
- Baselines can be wrong. Anomaly detection judges what is unusual for your account. A legitimate new deployment or a new employee location can trigger a finding, and a slow attacker who blends in may not.
- A finding is a lead, not a verdict. Check the resource and actor details before acting. Some findings reflect expected behavior, such as an authorized scan from your security team. The tuning chapter covers handling those.
Common mistakes
- Enabling GuardDuty in one Region only. Threats in other Regions then go undetected.
- Assuming it needs your logs. People sometimes spend time enabling flow logs "for GuardDuty." This is not needed for detection, though you may want those logs for investigation.
- Using a custom DNS resolver and expecting DNS findings. DNS-based findings will not appear for traffic that never reached the Route 53 Resolver.
- Expecting blocking. GuardDuty reports. Nothing is stopped unless you build the response.
- Judging it on day one. The behavioral baseline needs time, so evaluate anomaly findings after the account has run normally for a while.
Exercise
An EC2 instance in your VPC uses a self-managed DNS server instead of the VPC resolver. Which foundational GuardDuty data source loses visibility into that instance's DNS activity, and does GuardDuty still see its network connections?
Show answer
The Route 53 DNS query log source loses visibility, because GuardDuty only analyzes queries sent to the Route 53 Resolver. GuardDuty still sees the instance's network connections through VPC Flow Logs metadata, so traffic to a known malicious IP can still produce a finding, even though the DNS lookup that preceded it cannot.
Exercise
You enabled GuardDuty in us-east-1 and your finding publishing frequency is SIX_HOURS. Name two gaps this setup leaves.
Show answer
First, GuardDuty is regional, so activity in any other Region is not analyzed until you create a detector there. Second, the publishing frequency only controls how often updates to existing findings reach EventBridge, so with SIXHOURS, updates to an ongoing finding can arrive up to six hours late. Setting FIFTEENMINUTES shortens that delay.