Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Automate AWS GuardDuty threat detection findings processing using EventBridge and Lambda to enable real-time incident response, automatic quarantine of compromised resources, and security notification workflows.
.claude/skills/detecting-aws-guardduty-findings-automation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-18 | ✗→✓ | ▲ Improved | — | — |
| case-21 | ✗→✓ | ▲ Improved | — | — |
| case-20 | ✗→✓ | ▲ Improved | — | — |
| case-07 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✓ | ▲ Improved | — | — |
Amazon GuardDuty is a threat detection service that continuously monitors AWS accounts for malicious activity and unauthorized behavior. By integrating GuardDuty with Amazon EventBridge and AWS Lambda, security teams achieve automated, real-time responses to threats, reducing mean time to response (MTTR) from hours to seconds. GuardDuty analyzes VPC Flow Logs, CloudTrail management and data events, DNS logs, EKS audit logs, and S3 data events.
bash# Enable GuardDuty aws guardduty create-detector --enable --finding-publishing-frequency FIFTEEN_MINUTES # Enable additional data sources aws guardduty update-detector \ --detector-id DETECTOR_ID \ --data-sources '{ "S3Logs": {"Enable": true}, "Kubernetes": {"AuditLogs": {"Enable": true}}, "MalwareProtection": {"ScanEc2InstanceWithFindings": {"EbsVolumes": true}}, "RuntimeMonitoring": {"Enable": true} }'
json{ "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "severity": [{"numeric": [">=", 7.0]}] } }
bashaws events put-rule \ --name "guardduty-high-severity" \ --event-pattern '{ "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "severity": [{"numeric": [">=", 7.0]}] } }' aws events put-targets \ --rule "guardduty-high-severity" \ --targets "Id"="lambda-handler","Arn"="arn:aws:lambda:us-east-1:123456789012:function:guardduty-response"
pythonimport boto3 import json import os ec2 = boto3.client('ec2') sns = boto3.client('sns') QUARANTINE_SG = os.environ.get('QUARANTINE_SECURITY_GROUP') SNS_TOPIC = os.environ.get('SNS_TOPIC_ARN') def lambda_handler(event, context): finding = event['detail'] finding_type = finding['type'] severity = finding['severity'] account_id = finding['accountId'] region = finding['region'] # Extract resource information resource = finding.get('resource', {}) resource_type = resource.get('resourceType', '') if resource_type == 'Instance': instance_id = resource['instanceDetails']['instanceId'] instance_tags = {t['key']: t['value'] for t in resource['instanceDetails'].get('tags', [])} # Skip if already quarantined if instance_tags.get('SecurityStatus') == 'Quarantined': return {'statusCode': 200, 'body': 'Already quarantined'} # Get current security groups for forensics instance = ec2.describe_instances(InstanceIds=[instance_id]) current_sgs = [sg['GroupId'] for sg in instance['Reservations'][0]['Instances'][0]['SecurityGroups']] # Tag instance with finding info and original SGs ec2.create_tags( Resources=[instance_id], Tags=[ {'Key': 'SecurityStatus', 'Value': 'Quarantined'}, {'Key': 'GuardDutyFinding', 'Value': finding_type}, {'Key': 'OriginalSecurityGroups', 'Value': ','.join(current_sgs)}, {'Key': 'QuarantineTime', 'Value': finding['updatedAt']} ] ) # Move to quarantine security group (blocks all traffic) if QUARANTINE_SG: ec2.modify_instance_attribute( InstanceId=instance_id, Groups=[QUARANTINE_SG] ) # Create EBS snapshots for forensics volumes = ec2.describe_volumes( Filters=[{'Name': 'attachment.instance-id', 'Values': [instance_id]}] ) for vol in volumes['Volumes']: ec2.create_snapshot( VolumeId=vol['VolumeId'], Description=f'GuardDuty forensic snapshot - {finding_type}', TagSpecifications=[{ 'ResourceType': 'snapshot', 'Tags': [ {'Key': 'Purpose', 'Value': 'ForensicCapture'}, {'Key': 'SourceInstance', 'Value': instance_id}, {'Key': 'FindingType', 'Value': finding_type} ] }] ) # Notify security team sns.publish( TopicArn=SNS_TOPIC, Subject=f'[GuardDuty] {finding_type} - Instance {instance_id} Quarantined', Message=json.dumps({ 'action': 'instance_quarantined', 'instance_id': instance_id, 'finding_type': finding_type, 'severity': severity, 'account': account_id, 'region': region, 'original_security_groups': current_sgs, 'description': finding.get('description', '') }, indent=2) ) return { 'statusCode': 200, 'body': f'Instance {instance_id} quarantined and snapshots created' } return {'statusCode': 200, 'body': 'Non-EC2 finding processed'}
pythonimport boto3 import json import os iam = boto3.client('iam') sns = boto3.client('sns') SNS_TOPIC = os.environ.get('SNS_TOPIC_ARN') def lambda_handler(event, context): finding = event['detail'] finding_type = finding['type'] if 'IAMUser' not in finding_type and 'UnauthorizedAccess' not in finding_type: return {'statusCode': 200, 'body': 'Not an IAM finding'} resource = finding.get('resource', {}) access_key_details = resource.get('accessKeyDetails', {}) user_name = access_key_details.get('userName', '') access_key_id = access_key_details.get('accessKeyId', '') if not user_name: return {'statusCode': 200, 'body': 'No user identified'} actions_taken = [] # Deactivate the compromised access key if access_key_id and access_key_id != 'GeneratedFindingAccessKeyId': try: iam.update_access_key( UserName=user_name, AccessKeyId=access_key_id, Status='Inactive' ) actions_taken.append(f'Deactivated access key {access_key_id}') except Exception as e: actions_taken.append(f'Failed to deactivate key: {str(e)}') # Attach deny-all policy to user deny_policy = { "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Action": "*", "Resource": "*" }] } try: iam.put_user_policy( UserName=user_name, PolicyName='GuardDuty-DenyAll-Quarantine', PolicyDocument=json.dumps(deny_policy) ) actions_taken.append(f'Applied deny-all policy to {user_name}') except Exception as e: actions_taken.append(f'Failed to apply deny policy: {str(e)}') # Notify sns.publish( TopicArn=SNS_TOPIC, Subject=f'[GuardDuty] IAM Compromise - {user_name}', Message=json.dumps({ 'finding_type': finding_type, 'user': user_name, 'access_key': access_key_id, 'actions_taken': actions_taken, 'severity': finding['severity'] }, indent=2) ) return {'statusCode': 200, 'body': json.dumps(actions_taken)}
hclresource "aws_guardduty_detector" "main" { enable = true finding_publishing_frequency = "FIFTEEN_MINUTES" datasources { s3_logs { enable = true } kubernetes { audit_logs { enable = true } } malware_protection { scan_ec2_instance_with_findings { ebs_volumes { enable = true } } } } } resource "aws_cloudwatch_event_rule" "guardduty_high" { name = "guardduty-high-severity" description = "GuardDuty high severity findings" event_pattern = jsonencode({ source = ["aws.guardduty"] detail-type = ["GuardDuty Finding"] detail = { severity = [{ numeric = [">=", 7.0] }] } }) } resource "aws_cloudwatch_event_target" "lambda" { rule = aws_cloudwatch_event_rule.guardduty_high.name arn = aws_lambda_function.guardduty_response.arn }
| Category | Severity Range | Examples | |----------|---------------|---------| | Backdoor | 5.0 - 8.0 | Backdoor:EC2/C&CActivity | | CryptoCurrency | 5.0 - 8.0 | CryptoCurrency:EC2/BitcoinTool | | Trojan | 5.0 - 8.0 | Trojan:EC2/BlackholeTraffic | | UnauthorizedAccess | 5.0 - 8.0 | UnauthorizedAccess:IAMUser/ConsoleLogin | | Recon | 2.0 - 5.0 | Recon:EC2/PortProbeUnprotected | | Persistence | 5.0 - 8.0 | Persistence:IAMUser/AnomalousBehavior |
bash# Designate GuardDuty administrator aws guardduty enable-organization-admin-account \ --admin-account-id 111111111111 # Auto-enable for new accounts aws guardduty update-organization-configuration \ --detector-id DETECTOR_ID \ --auto-enable
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +41 percentage points is the difference between those two pass rates over the 21 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.