blog
Using Amazon GuardDuty: S ...
15 September 22

Using Amazon GuardDuty: S3 Findings

Posted byINE
facebooktwitterlinkedin
news-featured

In our lab walkthrough series, we go through selected lab exercises on our INE Platform. Subscribe or sign up for a 7-day, risk-free trial with INE and access this lab and a robust library covering the latest in Cyber Security, Networking, Cloud, and Data Science!

Purpose: An attacker can exploit misconfigurations and perform malicious tasks, so it is important to have a system/service that can detect all potential security threats which an attacker can take advantage of. In this article we will look at how we can use AWS GuardDuty to detect potential security threats using S3 Finding types.

Technical difficulty:

|   Novice   |   Beginner   |   Competent   |   Proficient   |   Expert

What is AWS GuardDuty Service?

Amazon GuardDuty is a threat detection service that continuously monitors your AWS Service accounts, workloads, and data stored in Amazon S3 for malicious activity and provides detailed security findings for visibility and remediation.

agd0.png

To identify and prioritize potential threats, the service uses machine learning, anomaly detection, and integrated threat intelligence. Threat intelligence combined with machine learning and behavior models helps in the detection of activity such as cryptocurrency mining, credential compromise, unauthorized and unusual data access, communication with known command-and-control servers, or API calls from known malicious IPs.

Let’s understand Amazon GuardDuty findings

A GuardDuty finding denotes a potential security issue discovered in your network. When GuardDuty detects unexpected and potentially malicious activity in your AWS environment, it generates a finding. You can view and manage your GuardDuty findings via the Findings page in the GuardDuty console, as well as through AWS CLI or API operations.

GuardDuty finding types:

  • S3 finding types
  • EC2 finding types
  • IAM finding types
  • Kubernetes finding types
  • Malware Protection finding types

In this article, we will mainly discuss S3 finding types.

GuardDuty S3 finding types

The S3 finding types are specific to Amazon S3 resources, with a Resource Type of S3 Bucket if the data source is CloudTrail data events for S3, or AccessKey if the data source is CloudTrail management events. The severity and specifics of the findings will vary depending on the type of finding and the permission associated with the bucket.

Now that we have covered all the key terms for the lab, let's carry out the experiment.

Lab Scenario

We have set up the below scenario in our INE labs for our students to practice. The screenshots have been taken from our online lab environment.

Lab Link: GuardDuty

Objective

Enable and use AWS GuardDuty service to detect potential security threats and misconfigurations with using GuardDuty.


Solution

Step 1: Click the lab link button to get access credentials. Login to the AWS account with these credentials.

agd1.png

Step 2: Enable GuardDuty from the console. Search for GuardDuty in the search bar and navigate to the GuardDuty dashboard.

agd2.png

 

Step 3: AWS provides a 30 days free trial for the GuardDuty service. Click on Get Started to use this free trial.

agd3.png

Step 4: To enable the GuardDuty service, click on the Enable GuardDuty button.

agd4.png

 At first, there will not be any findings.

agd5.png

Step 5: Navigate to Usage. This will display the Estimated total daily cost by the data source.

agd6.png

 

Step 6: Configure AWS CLI with given credentials and interact with S3 buckets.

Configure AWS CLI using the following command.

Copy the AWS Access Key Id and AWS Secret Access Key form the lab login credentials page and use the below command to configure the AWS CLI.

 

Command: aws configure

agd7.png

 

Step 7: Let’s try to list the S3 buckets using S3 API. 

Command: aws s3api list-buckets --query "Buckets[].Name"

agd8.png

 

Step 8: Now, let’s fetch the account id and note down the output somewhere. 

Command: aws sts get-caller-identity

agd9.png

 

Step 9: Create an S3 bucket. You need to specify the name and region in which you want to create this bucket.

 Note: The bucket name must be unique globally.

 Command:

aws s3api create-bucket \

    --bucket lab-bucket-343559064700 \

--region us-east-1

agd10.png

Step 10: Allow the public access to the bucket by removing “public block access”.

Command:

aws s3api delete-public-access-block \

    --bucket lab-bucket-343559064700 

agd11.png

 

Step 11: Grant public access to an S3 bucket to all AWS users by changing ACL. 

Command:

aws s3api put-bucket-acl --bucket lab-bucket-343559064700 \

 --grant-full-control uri=http://acs.amazonaws.com/groups/global/AuthenticatedUsers

agd12.png

 

Step 12: Fetch your public IP address and note it down somewhere.

Command: echo $(curl -s https://api.ipify.org)

This will output the public IP address. 

agd13.png

 

Step 13: Add the IP to a plain text file and name it as “ip_list.txt”. 

Command: echo “103.177.252.62” > ip_list.txt

agd14.png

 This command will create a file with name “ip_list.txt” and overwrite it with the given ip address.

  

Step 14: Upload the “ip_list.txt” to the created S3 bucket.

Command: aws s3 cp ip_list.txt s3://lab-bucket-343559064700/ 

agd15.png

We got an S3 URI as an output. Convert the URI to an object URL using this syntax.

Syntax: https://<bucket-name>.s3.amazonaws.com/<object or key name>

So finally the object URL will be similar to the following one.

Object URL: https://lab-bucket-343559064700.s3.amazonaws.com/ip_list.txt

 

Step 15: Navigate back to the GuardDuty dashboard click on “Lists” from side navigation bar.

agd16.png

 

Step 16: Click on “Add a threat IP list”. 

Threat lists consist of known malicious IP addresses. These lists can be supplied by third party threat intelligence or created specifically for your organization. GuardDuty generates findings based on threat lists. You can include a maximum of 250,000 IP addresses and CIDR ranges in a single threat list. GuardDuty only generates findings based on activity that involves IP addresses and CIDR ranges in your threat lists, findings will not be generated based on domain names. At any given time, you can have up to six uploaded threat lists per AWS account per Region.

agd17.png

 

Step 17: Enter the “List name” as “ip_list”. Paste object URL in the “Location” field and choose “Plaintext” as format.

agd18.png

Step 18: After adding the list, activate the list by checking the checkbox.

agd19.png

Step 19: Go back to the console and try to interact with S3 buckets. List S3 buckets.

Command: aws s3api list-buckets --query "Buckets[].Name"

agd20.png

Step 20: Now, let’s list the objects inside the buckets.

Command: aws s3api list-objects --bucket lab-bucket-343559064700 --query 'Contents[].{Key: Key, Size: Size}' 

agd21.png

 

Step 21: Download the object. 

Command:

aws s3api get-object --bucket lab-bucket-343559064700 --key ip_list.txt out.txt

agd22.png

 

Step 21: Navigate back to the GuardDuty dashboard and check the findings. 

Note: Refresh the findings page if the findings are empty. Detecting findings might get delayed. 

Each GuardDuty finding has an assigned severity level and value that reflects the potential risk. GuardDuty breaks down this range into High, Medium, and Low severity levels.

agd23.png

 

Step 22: Click on finding with the name “PenTest:IAMUser/KaliLinux”.

This finding informs you that a machine running Kali Linux is making API calls using credentials that belong to the listed AWS account in your environment. 

agd24.png

This finding will provide the details about the affected resource. Here the affected resources are IAM role and S3 bucket.  It will also provide the action done by the attacker. Here the action was to change bucket ACL and it is listed as “PutBucketAcl”

agd25.png

Step 23: Click on finding with the name “Policy:S3/BucketPublicAccessGranted”.

This finding informs you that the listed S3 bucket has been publicly exposed to all authenticated AWS users because an IAM entity has changed a bucket policy or ACL on that S3 bucket. 

agd26.png

Here the affected resources are IAM role and S3 bucket. 

agd27.png

It will also provide the action done. Here the action was to change bucket ACL and it is listed as “PutBucketAcl”.

agd28.png

 

Step 24: Click on finding with the name “Policy:S3/BucketBlockPublicAccessDisabled”

 This finding informs you that Block Public Access was disabled for the listed S3 bucket. When enabled, S3 Block Public Access settings are used to filter the policies or access control lists (ACLs) applied to buckets as a security measure to prevent inadvertent public exposure of data. 

Typically, S3 Block Public Access is turned off on a bucket to allow public access to the bucket or to the objects within. When S3 Block Public Access is disabled for a bucket, access to the bucket is controlled by the policies or ACLs applied to it. This does not mean that the bucket is shared publicly, but you should audit the policies and ACLs applied to the bucket to confirm that appropriate permissions are applied.

agd29.png

Here the affected resources are IAM role and S3 bucket. The action was to disable Block Public Access .

agd30.png

Step 25: Click on finding with the name “Recon:IAMUser/MaliciousIPCaller.Custom”

This finding informs you that an API operation that can list or describe AWS resources in an account within your environment was invoked from an IP address that is included on a custom threat list. The threat list used will be listed in the finding's details. An attacker might use stolen credentials to perform this type of reconnaissance of your AWS resources in order to find more valuable credentials or determine the capabilities of the credentials they already have.

agd31.png

agd32.png

Step 26: Click on finding with the name “UnauthorizedAccess:IAMUser/

MaliciousIPCaller.Custom”.

 This finding informs you that an API operation was invoked from an IP address that is included on a threat list that you uploaded. In , a threat list consists of known malicious IP addresses. This can indicate unauthorized access to AWS resources within your environment.

agd33.png

agd34.png


Thus GuardDuty generates a finding whenever it detects unexpected and potentially malicious activity in your AWS environment.

References: 

Conclusion

Congratulations! You have successfully enabled and used AWS GuardDuty service and detected the possible security threats using Amazon GuardDuty.

Try out AWS GuardDuty hands-on in our lab! Subscribe or sign up for a 7-day, risk-free trial with INE to access this lab and a robust library covering the latest in Cyber Security, Networking, Cloud, and Data Science!

Need training for your entire team?

Schedule a Demo

Hey! Don’t miss anything - subscribe to our newsletter!

© 2022 INE. All Rights Reserved. All logos, trademarks and registered trademarks are the property of their respective owners.
instagram Logofacebook Logotwitter Logolinkedin Logoyoutube Logo