Getting started with GuardDuty
This tutorial provides a hands-on introduction to GuardDuty. The minimum requirements for enabling GuardDuty as a standalone account or as a GuardDuty administrator with AWS Organizations are covered in Step 1. Steps 2 through 5 cover using additional features recommended by GuardDuty to get the most out of your findings.
Topics
Before you begin
GuardDuty is a threat detection service that monitors GuardDuty foundational data sources such as AWS CloudTrail event logs, AWS CloudTrail management events, Amazon VPC Flow Logs, and DNS logs. GuardDuty also analyzes features associated with its protection types only if you enable them separately. Features include Kubernetes audit logs, RDS login activity, S3 logs, EBS volumes, Runtime monitoring, and Lambda network activity logs. Using these data sources and features (if enabled), GuardDuty generates security findings for your account.
After you enable GuardDuty, it starts monitoring your environment. You can disable GuardDuty for any account in any Region, at any time. This will stop GuardDuty from processing the foundational data sources and any features that were enabled separately.
You do not need to enable any of the GuardDuty foundational data sources explicitly. When you enable S3 Protection, you don't need to enable Amazon S3 data event logging explicitly. Similarly, when you enable EKS Protection, you don't need to enable Amazon EKS audit logs explicitly. Amazon GuardDuty pulls independent streams of data directly from these services. For a new GuardDuty account, some of the available protection types that are supported in an AWS Region are enabled and included in the 30-day free trial period by default. You can opt out of any or all of them. If you've an existing AWS account with GuardDuty enabled, you can choose to enable any or all of the protection plans that are available in your Region. For an overview of protection plans and which protection plans will be enabled by default, see Pricing in GuardDuty.
When enabling GuardDuty, consider the following items:
-
GuardDuty is a Regional service, meaning any of the configuration procedures you follow on this page must be repeated in each Region that you want to monitor with GuardDuty.
We highly recommend that you enable GuardDuty in all supported AWS Regions. This enables GuardDuty to generate findings about unauthorized or unusual activity even in Regions that you are not actively using. This also enables GuardDuty to monitor AWS CloudTrail events for global AWS services such as IAM. If GuardDuty is not enabled in all supported Regions, its ability to detect activity that involves global services is reduced. For a full list of Regions where GuardDuty is available, see Regions and endpoints.
-
Any user with administrator privileges in an AWS account can enable GuardDuty, however, following the security best practice of least privilege, it is recommended that you create an IAM role, user, or group to manage GuardDuty specifically. For information about the permissions required to enable GuardDuty see Permissions required to enable GuardDuty.
-
When you enable GuardDuty for the first time in any AWS Region, by default, it also enables all the available protection types that are supported in that Region, including Malware Protection for EC2. GuardDuty creates a service–linked role for your account called
AWSServiceRoleForAmazonGuardDuty
. This role includes the permissions and the trust policies that allow GuardDuty to consume and analyze events directly from the GuardDuty foundational data sources to generate security findings. Malware Protection for EC2 creates another service–linked role for your account calledAWSServiceRoleForAmazonGuardDutyMalwareProtection
. This role includes the permissions and trust policies that allow Malware Protection for EC2 perform agentless scans to detect malware in your GuardDuty account. It allows GuardDuty to create an EBS volume snapshot in your account, and share that snapshot with the GuardDuty service account. For more information, see Service-linked role permissions for GuardDuty. For more information about service-linked roles, see Using service-linked roles. -
When you enable GuardDuty for the first time in any Region your AWS account is automatically enrolled in a 30-day GuardDuty free trial for that Region.
The following video explains how an administrator account can get started with GuardDuty and enable it in multiple member accounts.
Step 1: Enable Amazon GuardDuty
The first step to using GuardDuty is to enable it in your account. Once enabled, GuardDuty will immediately begin to monitor for security threats in the current Region.
If you want to manage GuardDuty findings for other accounts within your organization as a GuardDuty administrator, you must add member accounts and enable GuardDuty for them as well.
Note
If you want to enable GuardDuty Malware Protection for S3 without enabling GuardDuty, then for steps, see GuardDuty Malware Protection for S3.
Step 2: Generate sample findings and explore basic operations
When GuardDuty discovers a security issue, it generates a finding. A GuardDuty finding is a dataset containing details relating to that unique security issue. The finding's details can be used to help you investigate the issue.
GuardDuty supports generating sample findings with placeholder values, which can be used to test GuardDuty functionality and familiarize yourself with findings before needing to respond to a real security issue discovered by GuardDuty. Follow the guide below to generate sample findings for each finding type available in GuardDuty, for additional ways to generate sample findings, including generating a simulated security event within your account, see Sample findings.
To create and explore sample findings
-
In the navigation pane, choose Settings.
-
On the Settings page, under Sample findings, choose Generate sample findings.
-
In the navigation pane, choose Summary to view the insights about the findings generated in your AWS environment. For more information about the components of the Summary dashboard, see Summary dashboard in Amazon GuardDuty.
-
In the navigation pane, choose Findings. The sample findings are displayed on the Current findings page with the prefix [SAMPLE].
-
Select a finding from the list to display details for the finding.
-
You can review the different information fields available in the finding details pane. Different types of findings can have different fields. For more information about the available fields across all finding types see Finding details. From the details pane you can take the following actions:
-
Select the finding ID at the top of the pane to open the complete JSON details for the finding. The complete JSON file can also be downloaded from this panel. The JSON contains some additional information not included in the console view and is the format that can be ingested by other tools and services.
-
View the Resource affected section. In a real finding, the information here will help you identify a resource in your account that should be investigated and will include links to the appropriate AWS Management Console for actionable resources.
-
Select the + or - looking glass icons to create an inclusive or exclusive filter for that detail. For more information about finding filters see Viewing filtered findings in GuardDuty.
-
-
-
Archive all your sample findings
-
Select all findings by selection the check box at the top of the list.
-
Deselect any findings that you wish to keep.
-
Select the Actions menu and then select Archive to hide the sample findings.
Note
To view the archived findings select Current and then Archived to switch the findings view.
-
Step 3: Configure exporting GuardDuty findings to an Amazon S3 bucket
GuardDuty recommends configuring settings to export findings because it allows you to export your findings to an S3 bucket for indefinite storage beyond the GuardDuty 90-day retention period. This allows you to keep records of findings or track issues within your AWS environment over time. GuardDuty encrypts the findings data in your S3 bucket by using AWS Key Management Service (AWS KMS key). To configure the settings, you must give GuardDuty the permission a KMS key. For more detailed steps, see Exporting generated findings to Amazon S3.
To export GuardDuty findings to Amazon S3 bucket
Attach policy to KMS key
-
Sign in to the AWS Management Console and open the AWS Key Management Service (AWS KMS) console at https://console.aws.amazon.com/kms
. -
To change the AWS Region, use the Region selector in the upper-right corner of the page.
-
In the navigation pane, choose Customer managed keys.
-
Select an existing KMS key, or perform the steps to Create a symmetric encryption KMS key in the AWS Key Management Service Developer Guide.
The Region of your KMS key and Amazon S3 bucket must be the same.
Copy the key ARN to a notepad for use in the later steps.
-
In the Key policy section of your KMS key, choose Edit. If Switch to policy view is displayed, choose it to display the Key policy, and then choose Edit.
-
Copy the following policy block to your KMS key policy:
{ "Sid": "AllowGuardDutyKey", "Effect": "Allow", "Principal": { "Service": "guardduty.amazonaws.com" }, "Action": "kms:GenerateDataKey", "Resource": "
KMS key ARN
", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012", "aws:SourceArn": "arn:aws:guardduty:Region2
:123456789012
:detector/SourceDetectorID
" } } }Edit the policy by replacing the following values that are formatted in
red
in the policy example:-
Replace
KMS key ARN
with the Amazon Resource Name (ARN) of the KMS key. To locate the key ARN, see Finding the key ID and ARN in the AWS Key Management Service Developer Guide. -
Replace
123456789012
with the AWS account ID that owns the GuardDuty account exporting the findings. -
Replace
Region2
with the AWS Region where the GuardDuty findings are generated. -
Replace
SourceDetectorID
with thedetectorID
of the GuardDuty account in the specific Region where the findings generated.To find the
detectorId
for your account and current Region, see the Settings page in the https://console.aws.amazon.com/guardduty/console, or run the ListDetectors API.
-
-
Attach policy to Amazon S3 bucket
If you do not already have an Amazon S3 bucket where you want to export these findings, see Creating a bucket in the Amazon S3 User Guide.
-
Perform the steps under To create or edit a bucket policy in the Amazon S3 User Guide, until the Edit bucket policy page appears.
-
The example policy shows how grant GuardDuty permission to export findings to your Amazon S3 bucket. If you change the path after you configure export findings, then you must modify the policy to grant permission to the new location.
Copy the following example policy and paste it into the Bucket policy editor.
If you added the policy statement before the final statement, add a comma before adding this statement. Make sure that the JSON syntax of your KMS key policy is valid.
S3 bucket example policy
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Allow GetBucketLocation", "Effect": "Allow", "Principal": { "Service": "guardduty.amazonaws.com" }, "Action": "s3:GetBucketLocation", "Resource": "
Amazon S3 bucket ARN
", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012
", "aws:SourceArn": "arn:aws:guardduty:Region2
:123456789012
:detector/SourceDetectorID
" } } }, { "Sid": "Allow PutObject", "Effect": "Allow", "Principal": { "Service": "guardduty.amazonaws.com" }, "Action": "s3:PutObject", "Resource": "Amazon S3 bucket ARN/[optional prefix]
/*", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012
", "aws:SourceArn": "arn:aws:guardduty:Region2
:123456789012
:detector/SourceDetectorID
" } } }, { "Sid": "Deny unencrypted object uploads", "Effect": "Deny", "Principal": { "Service": "guardduty.amazonaws.com" }, "Action": "s3:PutObject", "Resource": "Amazon S3 bucket ARN/[optional prefix]
/*", "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "aws:kms" } } }, { "Sid": "Deny incorrect encryption header", "Effect": "Deny", "Principal": { "Service": "guardduty.amazonaws.com" }, "Action": "s3:PutObject", "Resource": "Amazon S3 bucket ARN/[optional prefix]
/*", "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption-aws-kms-key-id": "KMS key ARN
" } } }, { "Sid": "Deny non-HTTPS access", "Effect": "Deny", "Principal": "*", "Action": "s3:*", "Resource": "Amazon S3 bucket ARN/[optional prefix]
/*", "Condition": { "Bool": { "aws:SecureTransport": "false" } } } ] } -
Edit the policy by replacing the following values that are formatted in
red
in the policy example:-
Replace
Amazon S3 bucket ARN
with the Amazon Resource Name (ARN) of the Amazon S3 bucket. You can find the Bucket ARN on the Edit bucket policy page in the https://console.aws.amazon.com/s3/console. -
Replace
123456789012
with the AWS account ID that owns the GuardDuty account exporting the findings. -
Replace
Region2
with the AWS Region where the GuardDuty findings are generated. -
Replace
SourceDetectorID
with thedetectorID
of the GuardDuty account in the specific Region where the findings generated.To find the
detectorId
for your account and current Region, see the Settings page in the https://console.aws.amazon.com/guardduty/console, or run the ListDetectors API. -
Replace
[optional prefix]
part of theS3 bucket ARN/[optional prefix]
placeholder value with an optional folder location to which you want to export the findings. For more information about the use of prefixes, see Organizing objects using prefixes in the Amazon S3 User Guide.When you provide an optional folder location that doesn't exist already, GuardDuty will create that location only if the account associated with the S3 bucket is the same as the account exporting the findings. When you export findings to an S3 bucket that belongs to another account, the folder location must exist already.
-
Replace
KMS key ARN
with the Amazon Resource Name (ARN) of the KMS key associated with the encryption of the findings exported to the S3 bucket. To locate the key ARN, see Finding the key ID and ARN in the AWS Key Management Service Developer Guide.
-
-
Steps in GuardDuty console
Open the GuardDuty console at https://console.aws.amazon.com/guardduty/
. -
In the navigation pane, choose Settings.
-
On the Settings page, under Findings export options, for S3 bucket, choose Configure now (or Edit, as needed).
-
For S3 bucket ARN, enter the
bucket ARN
to which you want to send the findings. To view the bucket ARN, see Viewing the properties for an S3 bucket in the Amazon S3 User Guide. -
For KMS key ARN, enter the
key ARN
. To locate the key ARN, see Find the key ID and key ARN in the AWS Key Management Service Developer Guide. -
Choose Save.
Step 4: Set up GuardDuty finding alerts through SNS
GuardDuty integrates with Amazon EventBridge, which can be used to send findings data to other applications and services for processing. With EventBridge you can use GuardDuty findings to initiate automatic responses to your findings by connecting finding events to targets such as AWS Lambda functions, Amazon EC2 Systems Manager automation, Amazon Simple Notification Service (SNS) and more.
In this example you will create an SNS topic to be the target of an EventBridge rule, then you'll use EventBridge to create a rule that captures findings data from GuardDuty. The resulting rule forwards the finding details to an email address. To learn how you can send findings to Slack or Amazon Chime, and also modify the types of findings alerts are sent for, see Setup an Amazon SNS topic and endpoint.
To create an SNS topic for your findings alerts
-
Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home
. -
In the navigation pane, choose Topics.
-
Choose Create Topic.
-
For Type, select Standard.
-
For Name, enter
GuardDuty
. -
Choose Create Topic. The topic details for your new topic will open.
-
In the Subscriptions section, choose Create subscription.
-
For Protocol, choose Email.
-
For Endpoint, enter the email address to send notifications to.
-
Choose Create subscription.
After you create your subscription, you must confirm the subscription through email.
-
To check for a subscription message, go to your email inbox, and in the subscription message, choose Confirm subscription.
Note
To check the email confirmation status, go to the SNS console and choose Subscriptions.
To create an EventBridge rule to capture GuardDuty findings and format them
-
Open the EventBridge console at https://console.aws.amazon.com/events/
. -
In the navigation pane, choose Rules.
-
Choose Create rule.
-
Enter a name and description for the rule.
A rule can't have the same name as another rule in the same Region and on the same event bus.
-
For Event bus, choose default.
-
For Rule type, choose Rule with an event pattern.
-
Choose Next.
-
For Event source, choose AWS events.
-
For Event pattern, choose Event pattern form.
-
For Event source, choose AWS services.
-
For AWS service, choose GuardDuty.
-
For Event Type, choose GuardDuty Finding.
-
Choose Next.
-
For Target types, choose AWS service.
-
For Select a target, choose SNS topic, and for Topic, choose the name of the SNS topic you created earlier.
-
In the Additional settings section, for Configure target input, choose Input transformer.
Adding an input transformer formats the JSON finding data sent from GuardDuty into a human-readable message.
-
Choose Configure input transformer.
-
In the Target input transformer section, for Input path, paste the following code:
{ "severity": "$.detail.severity", "Finding_ID": "$.detail.id", "Finding_Type": "$.detail.type", "region": "$.region", "Finding_description": "$.detail.description" }
-
To format the email, for Template, paste the following code and make sure to replace the text in red with the values appropriate to your Region:
"You have a severity
severity
GuardDuty finding typeFinding_Type
in theRegion_Name
Region." "Finding Description:" "Finding_Description
." "For more details open the GuardDuty console at https://console.aws.amazon.com/guardduty/home?region=region
#/findings?search=id%3DFinding_ID
" -
Choose Confirm.
-
Choose Next.
-
(Optional) Enter one or more tags for the rule. For more information, see Amazon EventBridge tags in the Amazon EventBridge User Guide.
-
Choose Next.
-
Review the details of the rule and choose Create rule.
-
(Optional) Test your new rule by generating sample findings with the process in Step 2. You will receive an email for each sample finding generated.
Next steps
As you continue to use GuardDuty, you will come to understand the types of findings that are relevant to your environment. Whenever you receive a new finding, you can find information, including remediation recommendations about that finding, by selecting Learn more from the finding description in the finding details pane, or by searching for the finding name on GuardDuty finding types.
The following features will help you tune GuardDuty so that it can provide the most relevant findings for your AWS environment:
-
To easily sort findings based on specific criteria, such as instance ID, account ID, S3 bucket name, and more, you can create and save filters within GuardDuty. For more information, see Viewing filtered findings in GuardDuty.
-
If you are receiving findings for expected behavior in your environment, you can automatically archive findings based on the criteria you define with suppression rules.
-
To prevent findings from being generated from a subset of trusted IPs, or to have GuardDuty monitor IPs outside it's normal monitoring scope, you can set up Trusted IP and threat lists.