Advanced Threat Detection with AWS Security Hub and Amazon GuardDuty
?? Vasileios Sofroni CRISC, CISM
?? Amazon Champion Authorized Instructor (AAI) | AWS Community Builder | 9x AWS Certified | Cloud Security Enthusiast ?? | ? Cloud Compliance & Governance Specialist ??
Introduction
In today’s rapidly and dynamically changing cloud environments, robust security is more critical than ever. Advanced threat detection is a cornerstone of effective cloud security which helps organizations identify, prioritize, and mitigate security risks before they escalate, both proactively. AWS Security Hub and Amazon GuardDuty, two powerful security services from Amazon Web Services (AWS), work together to provide unparalleled visibility into your AWS environment.
In this article we are having a deep dive on how to integrate AWS Security Hub and Amazon GuardDuty for enhanced threat detection. We will explore the features, benefits, and best practices of using these services, providing not only actionable insights but also real world examples for effective implementation. In addition, we will also offer tips on how to scale these solutions for the most complex of environments, and discuss how automation and customization can improve your organization’s security strategy.
AWS Security Hub and GuardDuty: Key Features
Let's meet our two guests today, shall we?
Meet firstly AWS Security Hub and its features
And now meet Amazon GuardDuty
When combined, Security Hub and GuardDuty give you a centralized, correlated view of threats across your AWS environment. This integration enhances visibility, reduces manual efforts and accelerates incident response times. Correlating findings from GuardDuty, Config and Macie, organizations can adopt a proactive, layered security approach, so that threats are addressed before they become problems that need fixing.
Setting Up GuardDuty and Security Hub Integration
Any organization wishing to enhance its security posture should consider integrating AWS Security Hub and Amazon GuardDuty. These services not only provide for advanced threat detection but also make sure that the centralized management of findings across accounts and regions is available. Thus, security teams have actionable insights and enhanced visibility with AWS Security Hub aggregating data from GuardDuty and other services like AWS Config and Macie. GuardDuty continuously monitors data sources for proactive threat detection, and Security Hub offers a unified platform on which findings can be correlated and responses automated.
The combination of these tools brings - as we will explore further together - significant benefits:
Prerequisites:
Now let's make sure we have everything we need to start "cooking".
Step-by-Step Setup:
Now the fun part!
Enable GuardDuty:
In AWS CLI:
aws guardduty create-detector --enable --region us-east-1
In Terraform:
resource "aws_guardduty_detector" "main" {
enable = true
}
In the console:
Enable Security Hub:
In AWS CLI:
aws securityhub enable-security-hub --region us-east-1
In Terraform:
resource "aws_securityhub_account" "main" {}
resource "aws_securityhub_standards_subscription" "cis" {
standards_arn = "arn:aws:securityhub:::standards/cis-aws-foundations-benchmark/v/1.2.0"
}
In the console:
Integrate GuardDuty Findings into Security Hub:
aws events put-rule --name "HighSeverityGuardDutyFinding" --event-pattern '{
"source": ["aws.guardduty"],
"detail": {"severity": [{"numeric": [7]}]}
}'
Multi-Account and Multi-Region Setup:
In AWS CLI:
aws organizations register-delegated-administrator \
--account-id <delegated-admin-account-id> \
--service-principal securityhub.amazonaws.com
In Terraform:
resource "aws_securityhub_organization_admin_account" "main" {
admin_account_id = var.delegated_admin_account_id
}
resource "aws_guardduty_organization_admin_account" "main" {
admin_account_id = var.delegated_admin_account_id
}
You are going to need multiple accounts in order to implement this solution.
Aggregate Findings:
Configure Security Hub to aggregate findings from all linked accounts and regions to the management account:
In AWS CLI:
aws securityhub update-finding-aggregation-configuration \
--region-linking-mode ALL_REGIONS \
--account-aggregation-source '{"AccountIds":["<linked-account-id>"], "AllRegions":true}'
In Terraform:
resource "aws_securityhub_finding_aggregation" "example" {
region_linking_mode = "ALL_REGIONS"
account_aggregation_source {
account_ids = var.linked_account_ids
all_regions = true
}
}
To ensure a scalable and centralized approach to security monitoring and management across your AWS environment, these steps should be followed. This configuration is particularly important for visibility across multiple accounts and regions, and is useful for organizations with a complex topology of distributed operations.
Understanding GuardDuty Findings in Security Hub
To be successful with GuardDuty we have to understand first and foremost how GuardDuty works and how it classifies findings.
GuardDuty generates findings based on suspicious activities, classified by threat types and severity levels:
Types of Threats Detected:
Severity Levels:
Correlation of Findings: AWS Security Hub consolidates GuardDuty findings with insights from services like Amazon Macie and AWS Config, providing a unified security posture. For example:
By combining findings from these services, Security Hub provides security teams with actionable insights and a comprehensive view of their AWS environment’s security posture, enabling faster remediation and improved compliance tracking.
领英推荐
Creating Custom Insights in Security Hub for GuardDuty Findings
What Are Custom Insights? Custom insights are the tailored views of security findings based on certain criteria such as threat types, affected resources or regions in AWS Security Hub. These insights support security teams to identify and take action on high priority issues without having to dig through unnecessary data.
Some Examples of Custom Insights:
{
"Filters": {
"Severity": [{ "Comparison": "GREATER_THAN_OR_EQUALS", "Value": "7" }],
"Region": [{ "Comparison": "EXISTS" }]
}
}
{
"Filters": {
"ResourceType": [{ "Comparison": "EQUALS", "Value": "AWS::S3::Bucket" }],
"FindingType": [{ "Comparison": "EQUALS", "Value": "SensitiveData:S3" }]
}
}
{
"Filters": {
"FindingType": [{ "Comparison": "EQUALS", "Value": "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration" }],
"Severity": [{ "Comparison": "GREATER_THAN_OR_EQUALS", "Value": "6" }]
}
}
Through these tailored views, security teams can focus their efforts on the most critical security issues, thus ensuring faster responses and more efficient resource allocation.
Steps to Create Custom Insights:
Some more complicated examples of Custom Insights:
Example EventBridge Rule:
{
"Name": "HighSeverityGuardDutyEventRule",
"EventPattern": {
"source": ["aws.guardduty"],
"detail-type": ["GuardDuty Finding"],
"detail": {
"severity": [{"numeric": [7]}],
"type": ["UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration"]
}
},
"State": "ENABLED",
"Targets": [
{
"Id": "LambdaFunctionTarget",
"Arn": "arn:aws:lambda:us-east-1:123456789012:function:DisableCompromisedUser",
"InputPath": "$.detail"
}
]
}
{
"source": ["aws.guardduty"],
"detail-type": ["GuardDuty Finding"],
"detail": {
"severity": [{"numeric": [7]}],
"type": ["UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration"]
}
}
Example AWS Lambda Automation:
import boto3
def lambda_handler(event, context):
# Extract IAM User details from the event
iam_user = event['detail']['resource']['accessKeyDetails']['userName']
# Initialize IAM client
iam = boto3.client('iam')
# Disable the user and their associated access keys
access_keys = iam.list_access_keys(UserName=iam_user)
for key in access_keys['AccessKeyMetadata']:
iam.update_access_key(
UserName=iam_user,
AccessKeyId=key['AccessKeyId'],
Status='Inactive'
)
# Log the action
print(f"Disabled access for user: {iam_user}")
Custom Insight Filter Example for S3 Data Anomalies:
{
"Filters": {
"ResourceType": [{ "Comparison": "EQUALS", "Value": "AWS::S3::Bucket" }],
"FindingType": [{ "Comparison": "CONTAINS", "Value": "SensitiveData:S3" }],
"Severity": [{ "Comparison": "GREATER_THAN_OR_EQUALS", "Value": "6" }]
}
}
Automating Incident Response
Incident response automation is an important step for keeping your AWS environment secure and able to withstand threats. Using automation with AWS Security Hub and GuardDuty organizations can cut response times dramatically, reduce the likelihood of manual errors and help to ensure that security incidents are handled consistently.
Why It’s Necessary:
This section describes practical use cases and provides examples of how automation can be effectively used to secure your AWS workloads.
Using AWS Systems Manager Documents (SSM Documents): SSM Documents are JSON or YAML scripts that describe what actions to perform on AWS resources. These are particularly useful for automating the response to security incidents identified by Security Hub and GuardDuty.
Example Use Case: Isolating a Compromised EC2 Instance
There are several times where our resources might become the target of malicious actors. EC2 instances make no exception to that case. We need therefore a plan in order to isolate an instance once we notice that it became compromised. This is where GuardDuty and Security Hub can bring AWS SSM into play.
SSM Document JSON Example:
{
"schemaVersion": "2.2",
"description": "Isolate a compromised EC2 instance and collect forensic data.",
"mainSteps": [
{
"action": "aws:runCommand",
"name": "IsolateInstance",
"inputs": {
"DocumentName": "AWS-RunShellScript",
"Parameters": {
"commands": [
"aws ec2 modify-instance-attribute --instance-id {{InstanceId}} --groups sg-xxxxxxxx"
]
}
}
},
{
"action": "aws:createImage",
"name": "CreateSnapshot",
"inputs": {
"InstanceId": "{{InstanceId}}",
"NoReboot": true
}
}
]
}
Through automation, organizations are able to provide timely and consistent security incident responses with minimal manual effort and reduced risk of human error.
Take this example for instance. Once my instance has been labeled as compromised, I didn't need to do anything. GuardDuty, Security Hub and SSM took care of everything and I got only informed. This demonstrates the power of automation and the promptness of my incident response plan.
Best Practices for Advanced Threat Detection
1. Enable Multi-Region Monitoring:
2. Minimize False Positives:
3. Leverage Third-Party Tools:
If you have already solutions in place where your infrastructure and landscape is being monitored, well this is your lucky day. AWS GuardDuty and Security Hub offer plenty of integrations with SIEM solutions like Splunk, Datadog, or QRadar for extended analytics and advanced threat correlation.
Conclusion
Using AWS Security Hub in conjunction with Amazon GuardDuty allows organizations to get threat detection and a centralized view for all of their AWS environments. Both services can be used to help businesses defend against threats by identifying security risks so they may be remediated, response actions can be automated, and compliance with industry standards can be maintained.
To enhance your implementation, you could build a multi-region Security Hub analytics pipeline or explore integrations with third party tools to extend your capabilities. Furthermore, focus on automation and customization to ensure these tools meet your organization’s needs. Remain vigilant and incorporate these best practices to enhance your cloud security posture for comprehensive threat detection.
And remember; Security can be expensive but have you tried it without it?