This document provides an overview of techniques for wrangling security events in the AWS cloud. It discusses how to leverage AWS services like CloudTrail, CloudWatch, and Config to detect, investigate, and respond to potential security incidents. Specific example events covered include CloudTrail logging being disabled, MFA removal, S3 object deletions, anomalous logins, open security groups, and use of unapproved AMIs. For each, it outlines approaches for detection, recovery, investigation, and protecting against future occurrences. The document emphasizes the ability of AWS' programmatic interfaces to automate security monitoring and incident response.
2. What to expect from this session
• Tactical follow-on to previous talks
• Concrete examples of potential events and how you can
handle them
• Ideas for increasing security agility
• Specific AWS mechanisms to leverage
• More than 1 way to catch a cat burglar, so reinvent as
needed
• Relevant resources, including docs, code, and partners
3. “Intrusion Detection in the Cloud” redux
• AWS-specific areas to monitor for security-concerning
events
• Prerequisites
• Key concepts, such as security role, write-once storage
• Key services to leverage, events and behaviors to look
for
• Example detection of key configuration changes,
resource usage anomalies
• YouTube search “Intrusion Detection in the Cloud”
4. “Incident Response (IR) in the Cloud” redux
• Ensuring your existing IR process considers AWS
• More prerequisites
• Mechanisms for mitigation and investigation
• Tactics specific to AWS IR, such as constraining exposed
AWS credentials
• Tactics analogous to traditional IR, modified for AWS, such as
Amazon EC2 instance memory dumping, analysis
• YouTube search “Incident Response in the Cloud”
5. Security event wrangling = Response in depth
• Types of security events
• Detect -> Recover
• Investigate -> Protect
• Leveraging AWS mechanisms for increased security
agility
6. Example events of concern, signatures
• Configuration changes that impact ability to detect or
understand events
• Activities that are inconsistent with expectations
• Activities that violate policy
• Resources no longer available
• Resources more available than desired
• Event detection signatures != commercial product, and
may require careful thought vs. operations to develop
8. AWS = Agility for security geeks
• Ability to programmatically inventory environment—
knowing what you need to protect is key
• Awareness of what’s happening, what’s changing, from
AWS API activity to application behavior
• Detection and alerting mechanisms, freedom to create
and flexibility to configure and tune what’s appropriate
for YOU
• Analysis and response, via the same platform, natively
or with AWS partner solutions
9. AWS CloudTrail
• Records AWS API calls for your account and delivers log
files to you.
• Turn it ON!
http://docs.aws.amazon.com/awscloudtrail/latest/usergui
de/cloudtrail-user-guide.html
10.
11.
12.
13.
14. CloudTrail events
• A record in JSON format that contains information about
requests for resources in your account.
• Describes which service was accessed, what action was
performed, and any parameters for the action.
• Helps you determine who made the request.
• The event data is enclosed in a Records array.
http://docs.aws.amazon.com/awscloudtrail/latest/usergui
de/send-cloudtrail-events-to-cloudwatch-logs.html
20. Amazon CloudWatch Logs
• Monitor, store, and access your log files from Amazon
EC2 instances, AWS CloudTrail, or other sources.
• Enable in the AWS Management Console, CLI, or via
AWS CloudFormation.
• Monitor and alarm for specific phrases, values, or
patterns.
http://docs.aws.amazon.com/AmazonCloudWatch/latest/
DeveloperGuide/WhatIsCloudWatchLogs.html
21.
22.
23.
24.
25. CloudFormation -> CloudWatch alarms
• Downloadable and editable example CloudFormation template from
AWS
• Contains predefined CloudWatch metric filters and alarms that
enable you to receive email notifications when certain security-
related API calls are made in your AWS account
• Amazon S3 bucket events, network events, Amazon EC2 events,
AWS CloudTrail, and AWS Identity and Access Management (IAM)
events
http://docs.aws.amazon.com/awscloudtrail/latest/userguide/use-
cloudformation-template-to-create-cloudwatch-alarms.html
30. CloudTrail OFF event – Protect
Deny permissions for CloudTrail in IAM groups or roles
{
"Sid": "Stmt0001",
"Effect": "Deny",
"Action": [
"cloudtrail:DeleteTrail",
"cloudtrail:StopLogging"
],
"Resource": [
"*"
]
}
31. Multi-Factor Authentication (MFA)
• Require unique authentication codes to access AWS
websites or services
• Hardware or virtual authentication device generates
codes
• Enter codes manually via AWS Management Console or
accompany API requests
• Configure via IAM
http://docs.aws.amazon.com/IAM/latest/UserGuide/id_cr
edentials_mfa.html
61. S3 object deletion event – Detect
• Bucket logging? Check.
• Bucket versioning? Check.
• Continuously reviewing logs …? NO
• We can enable push notifications for S3 events that
might concern us (for example, deletions)
• Configure S3 to detect events like ObjectRemoved
• S3 sends alert to the Amazon SNS topic of your choosing
• SNS topic sends message to subscribers, such as an email
to your security_team@yourcompany.com
62.
63.
64.
65.
66.
67.
68.
69.
70. S3 object deletion event – Recover
• Restore deleted file from previous version.
• Via AWS Management Console, just a couple clicks to
download/upload deleted version.
• Via CLI/API, just an S3 copy object request, specifying
version ID with copy source.
• If you enabled versioning AFTER initial object put,
version ID will be “NULL”. OK, you can still specify
“NULL” as a version to restore from.
81. S3 object deletion event – Protect
• Bucket versioning protects against inadvertent delete or
overwrite of objects.
• Consider more restrictive policies for credentials, such
as specifically disallow S3 object removal.
• Additional layer of protection; enable MFA Delete on a
versioned S3 bucket.
http://docs.aws.amazon.com/AmazonS3/latest/dev/Versi
oning.html#MultiFactorAuthenticationDelete
86. Open security group
• 0.0.0.0/0 ingress has limited validity, but commonly used.
• Web server = Likely OK for the Internet to access 80/443.
• All of the web server’s OTHER ports? Likely NOT OK to
access the Internet.
• Policies can vary. No admin ports open to the world? OK.
• Creation and change velocity among security groups
should be LOW.
87. AWS Config
• AWS resource inventory, configuration history, and
configuration change notifications
• Discover existing AWS resources
• Export inventory of your AWS resources with all configuration
details
• Determine how a resource was configured at any point in
time
• Security geeks should LOVE it!
http://aws.amazon.com/documentation/config/
88.
89.
90.
91.
92.
93.
94.
95.
96. Open security group event – Detect
• Subscribe to AWS Config notification topic.
• Filter notifications for creation of security groups that
might be concerning. You could look for the following,
individually or combined:
• “SecurityGroup” and “Created” within subject
• changeType : “CREATE” within body
• resourceType: "AWS::EC2::SecurityGroup” within body
99. Open security group event – Recover
• If responding soon enough to the creation of a new
security group and no instances, simply delete the
security group.
• Otherwise, assign running instances to another security
group, and then delete the offending security group.
• You can’t delete a default security group, but you can
change its rules back to something sane, including no
rules.
100.
101.
102.
103. Delete open security group – AWS CLI
aws ec2 delete-security-group --no-dry-run --group-
id sg-d3bda2b4
104. Open security group event – Investigate
• Revisit the AWS Config change notification.
• Note time, action, and security group ID to correlate to
principal and source IP of EC2 API call via AWS
CloudTrail.
• If possible, engage principal to understand intent or
determine if unexplained, such as by external actor and
potentially malicious.
105. Open security group event – Protect
• Appropriately constrain or deactivate associated
credentials as warranted.
• Security group changes, particularly within production,
should not be a frequent event, so maintain high
vigilance.
107. Unapproved AMI event – Detect
• Compare launched EC2 instances against a whitelist.
• What is a good method to compare against a whitelist?
108. Let’s use AWS Lambda!
• Runs your code in response to events.
• Automatically manages compute resources for you.
• Create new back-end services where compute
resources are automatically triggered based on custom
requests.
• You can read CloudTrail events with AWS Lambda.
http://docs.aws.amazon.com/lambda/latest/dg/welcome.html
109. Unapproved AMI event - Recover
matchingRecords,
function(record, complete) {
var params = {
InstanceIds: []
};
// List each instance ID
for (var i = 0; i < record.responseElements.instancesSet.items.length; i++){
params.InstanceIds.push(record.responseElements.instancesSet.items[i].instanceId);
}
// Terminate the enumerated instances
ec2.terminateInstances(params, complete);
110. Unapproved AMI event – Investigate
Interrogate CloudTrail logs as before
• Who launched it?
• Where did the request come from?
• Which subnet was it being launched into?
112. Automate IR?
• Most, if not all, of the pieces to automate IR exist in AWS
• Automated IR = Even greater security agility
• Detect -> Protect programmatically
• Lambda-fy your IR!
113. Detecting events in Lambda
…
var EVENT_SOURCE_TO_TRACK = /cloudtrail.amazonaws.com/;
var EVENT_NAME_TO_TRACK = /StopLogging/;
var matchingRecords = records
.Records
.filter(function(record) {
return record.eventSource.match(EVENT_SOURCE_TO_TRACK)
&& record.eventName.match(EVENT_NAME_TO_TRACK);
});
…
Source: http://docs.aws.amazon.com/lambda/latest/dg/wt-cloudtrail-events-
adminuser.html
114. Responding to events in Lambda
…
if (matchingRecords.length >= 1) {
console.log(’StopLogging detected! Reverting...');
cloudtrail.startLogging(cloudtrailParams, function(err, data) {
….
117. Building a “Lambda Responder”
1. Turn on AWS CloudTrail – Choose an S3 bucket.
2. Create an SNS topic.
3. Update the topic policy to allow event notifications from your
S3 bucket.
4. Configure your S3 bucket to send event notifications to the
SNS topic.
5. Create an IAM role for the Lambda functions.
6. Create the Lambda functions and process SNS messages.
https://aws.amazon.com/blogs/compute/fanout-s3-event-
notifications-to-multiple-endpoints/ by John Stamper
118. Building a “Lambda Responder”
• What could you automatically respond to?
119. Lambda – Automated S3 object recovery
...
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var backup = ’your-backup-bucket/' + key;
var params = {
Bucket: bucket,
CopySource: backup,
Key: key,
};
s3.copyObject(params, function(err, data) {
// removed for brevity
});
...
120. Lambda – Automated open security group delete
var snsMsgString = JSON.stringify(event.Records[0].Sns.Message);
var snsMsgObject = getSNSMessageObject(snsMsgString);
if (snsMsgObject.configurationItemDiff.changeType == 'CREATE' &&
snsMsgObject.configurationItem.resourceType == 'AWS::EC2::SecurityGroup' &&
snsMsgObject.configurationItem.configuration.ipPermissions[0].ipProtocol == '-1' &&
snsMsgObject.configurationItem.configuration.ipPermissions[0].ipRanges == '0.0.0.0/0')
{
var params = {
DryRun: false,
GroupId: snsMsgObject.configurationItem.resourceId,
};
ec2.deleteSecurityGroup(params, function(err, data) {
context.succeed(snsMsgObject);
});
}
121. AWS Config -> Lambda … IR aaS? AWS Config
Rules!
• Extends AWS Config with a powerful new rule system
• Use existing rules from AWS and from partners
• You can also define your own custom rules
• SEC314 - NEW LAUNCH! AWS Config/Config Rules:
Use AWS Config Rules to Improve Governance over
Configuration Changes to Your Resources
122.
123. Practice makes perfect
• IR game day…YAY!
• Tabletop first…yay?
• See SEC316 – Harden Your Architecture with Security
Incident Response Simulations (SIRS), Jon Miller and
Armando Leite
124. AWS Partner, Dell SecureWorks, IR Support
• Customer IR case example
• Our IR preparedness “Wish List” for AWS customers
• How to contact us
125. IR Case Example – Background, Event
• Dell SecureWorks contacted by an AWS customer, a provider of cloud-
based collaboration software
• Customer investigated abnormally high CPU usage on Internet-facing
servers hosting their customers’ applications
• Customer’s review of system logs identified unauthorized logins from a wide
array of IP addresses using compromised credentials
• Threat actors leveraged the Customer’s compromised web app credentials
to gain unauthorized entry and propagate to a multitude of connected
resources within the Customer’s AWS environment
• Dell SecureWorks performed digital forensics on the Customer’s web
applications, AWS instances and snapshots, AWS CloudTrail logs, and
suspected on-premise systems
126. IR Case Example - Response
• Dell SecureWorks prepared forensic analysis environment:
• Launched forensic EC2 instances within Dell SecureWorks’ VPC
• Created S3 bucket for event data storage and transfer of forensic artifacts
• Using IAM, Customer provided appropriate access for Dell
SecureWorks to:
• Acquire snapshots of the affected Customer’s EC2 instances
• Transfer snapshots to Dell SecureWorks’ S3 bucket for forensic analysis
• Receive access to Customer’s CloudTrail logs for forensic analysis
• Using rapidly-deployed forensic toolsets, Dell SecureWorks
conducted forensic exam of:
• File systems of the Customer’s Internet-facing EC2 instances
• Customer’s AMIs
• Customer’s AWS CloudTrail logs
• Dell SecureWorks provided comprehensive analysis of the incident
and affected AWS resources
127. IR Case Example - Takeaways
• AWS enables shorter response times for security events vs. on-premise
• Time between engagement kickoff and commencing analysis was drastically reduced
• Security event data can be rapidly acquired, staged, and analyzed all within AWS
• Appropriate access can be quickly granted to security event responders via AWS IAM
• The ability to collaborate on configuration activities directly within AWS minimized time
taken for troubleshooting
• Creating effective environments for sharing incident response resources and
data within AWS is straight-forward
• Versus traditional IR, cost savings are also realized via IR within AWS
through reduction of the investigation timeline (minimized time to data
acquisition, resource setup, and initial analysis)
128. Our IR Prep “Wish List” for AWS Customers
• Take snapshots of all affected or suspected instances
• Collect network and instance metadata
• Create a restricted-access VPC, Security Group, and/or
separate AWS account
• Be ready to create temporary users / credentials via IAM
• Enable and centralize CloudTrail and CloudWatch logs
• Create a dedicated S3 bucket for sharing incident
response artifacts
129. How to Contact Dell SecureWorks
• Incident Response Hotline (24x7x365)
1-877-884-1110
• Website
http://www.secureworks.com/incident-response/
• Booth: #446 (next to Docker)
Flag me down and/or visit our booth to learn more about Dell
SecureWorks’ experience and capabilities and how we are partnered
with AWS to provide Incident Response for AWS customers!
130.
131. AWS Security Best Practices whitepaper
• Help for designing security infrastructure and
configuration of your AWS environment
• High-level guidance for:
• Managing accounts, users, groups, and roles
• Managing OS-level access to instances
• Securing your data, OS, apps, and infrastructure
• Managing security monitoring, auditing, alerting, and incident
response
https://media.amazonwebservices.com/AWS_Security_Best_Practices.pdf
132.
133. External resources – Reading, training
• SANS Reading Room, Incident Response
http://www.sans.org/reading-room/whitepapers/incident
• FIRST
http://www.first.org/resources/guides
• CERT, Incident Management
http://www.cert.org/incident-management/publications/
135. Other relevant talks this week
• SEC403 - Timely Security Alerts and Analytics: Diving
into AWS CloudTrail Events by Using Apache Spark on
Amazon EMR, Will Kruse
• SEC303 – Architecting for End-to-End Security in the
Enterprise, Hart Rossman and Bill Shinn
• If you miss(ed) any of them live, they will be on
YouTube, just like this talk.
• Don’t forget last year’s “Intrusion Detection in the Cloud”
and “Incident Response in the Cloud” that are already on
YouTube!
136. AWS Support for security concerns
• AWS Support is the one-stop shop for AWS customers,
for any concerns, including security related.
• If AWS Support cannot immediately address your
concerns, they will escalate internally to the appropriate
technical team, AWS Security included.
https://aws.amazon.com/support
137. AWS security resources
• AWS Security Blog
http://blogs.aws.amazon.com/security/
• AWS Security Center
https://aws.amazon.com/security
• Contact the AWS security team
aws-security@amazon.com
138. Summary
• Security agility with AWS
• Threat vs. policy-driven concerns, enumerate, create
signatures, detection mechanisms
• Automate IR where you can
• Two ways to get more practice: you only get to choose
one
• We (AWS and our technology partners) are here to help!