SlideShare uma empresa Scribd logo
1 de 55
An Engineer’s Introduction
to AWS Security Auditing
using CIS and the CLI
richard@lateralblast.com.au
Caveat:
I’m an Engineer, not a developer.
I script, I don’t code, this won’t be pretty...
Goals of this presentation
▷Introduction
▷Quick overview of CIS
▷Quick overview of security and AWS
▷Pass on some lessons learned
▷Provide some CLI examples
▷Save you some time and pain
▷Recommendations based on these
So why write your own tool?
Besides CLI Naming inconsistencies…
Besides being a good way to
learn AWS Security…
▷I didn’t want to have to go to the web
interface or a document every time I wanted
to do a security review
▷AWS has Trusted Advisor, but charges for
more than basic checks
▷Although the CLI has quite good help, the
naming and use of tags and switches is
frustratingly inconsistent
▷No source (including me) is perfect, more
than one source of verification is good
I already had a Security
Auditing tool of my own… [1]
▷Supported a number of UNIX OS,
including Amazon Linux
▷Used the CIS Benchmarks already
▷Was free (apart from my time) and
required minimal additional software
▷Had a number of people using it, so
would get some additional testing
▷I could add additional tests as I
discovered new security
recommendations and tips[1] https://github.com/lateralblast/lunar
Security Benchmarks
Why choose the CIS Benchmark?
It’s good to have a common
point of reference as a start…
▷Used by a lot of people and places as a
basis for their own security processes
▷Has a long track record
▷Well trusted, and has industry support
▷Mentioned on AWS Security Blog [1]
▷Semi regularly updated
▷Has explanation and implementation
notes as well as the standard checkbox
▷Has GUI and CLI remediation steps
[1] https://aws.amazon.com/blogs/security/tag/cis-aws-foundations-benchmark/
But it’s only a start…
▷It’s not perfect (e.g. typos in remediation)
▷Not everything is going to be applicable to
your organisation / application
▷You’ll have your own processes on top of it
▷Sometimes lags with updates
▷It’s always good to have more than one
source of verification, especially for security
▷It’s a paper document, needs to be
automated to reduce work and human error
Security Fundamentals
An Engineers attempt to explain security…
Traditional:
Security in layers
Network, Application, OS, Users, etc.
Least access / privilege by default
Restrict access to privileged
accounts
Monitor usage of privileged accounts
Use Multifactor Authentication
Enable password complexity
Enable password / credential rotation
Create roles and add users to them
Enable and manage logging
Generate alerts
Encrypt at rest and in transit
What is old is new again…
AWS:
Security in layers
Network, Application, OS, Users, etc.
Least access / privilege by default
Restrict access to “root” account
Monitor use of IAM
Use Multifactor Authentication
Enable password complexity
Enable password / credential rotation
Create roles and add users to them
Enable and manage logging
Generate alerts
Encrypt at rest and in transit
AWS CLI Security Auditing
An Engineers attempt to audit via the CLI…
What does this involve?
▷An overview of key areas:
▷IAM (Users, Groups, Roles, Policies, MFA)
▷Monitoring (Logging, Metrics, Alerting)
▷Encryption (at rest and in flight)
▷Networking (VPCs and Security Groups)
▷Some CLI examples of how to get and set
security parameters where appropriate
AWS CLI Security Auditing
IAM (Users, Groups, Roles, Policies, MFA)
Avoid use of the “root” account
▷Attach IAM policies to groups and roles and
use them to delegate responsibility to
management accounts [1]
▷Minimise use of “root” account to those
functions that require it e.g. requesting a
penetration test of creating a CloudFront
private key
[1] http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
IAM Account Security (MFAs etc.)
▷Ensure MFA is enabled for “root” account
▷Ensure MFA is enabled for other IAM
users
▷Consider hardware MFA for ”root” account
▷Use MFA devices where applicable and
lock the device away in the case of the
root user
▷Delegate management of MFA devices [1]
▷Hardware, Virtual and SMS based MFA [2]
[1] https://aws.amazon.com/blogs/security/how-to-delegate-management-of-multi-factor-authentication-to-aws-iam-users/
[2] http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html
Checking MFAs
$ aws iam generate-credential-report
{
"State": "STARTED",
"Description": "No report exists. Starting a new report generation task”
}
$ aws iam get-credential-report --query 'Content' --output text |base64 –D 
|cut -d, f1,4,8
user,password_enabled,mfa_active
<root_account>,not_supported,true
spindler,false,false
$ aws iam list-virtual-mfa-devices –-query “VirtualMFADevices”
[
{
"SerialNumber": "arn:aws:iam::123456789012:mfa/ExampleMFADevice”
}
]
$ aws iam get-account-summary | grep "AccountMFAEnabled”
"AccountMFAEnabled": 1,
Managing Credentials
▷Manage Access and Secret keys used for
programmatic access via SDK and HTTP [1]
▷Ensure credentials unused for 90 days or
greater are removed
▷Ensure keys are rotated every 90 days or
less
▷Done manually, or better programmatically
▷Only create keys for users that need them,
and do not have keys for “root” account [2]
[1] http://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html
[2] http://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html
Checking Credentials
$ aws iam generate-credential-report
{
"State": "STARTED",
"Description": "No report exists. Starting a new report generation task”
}
$ aws iam get-credential-report --query 'Content' --output text |base64 –D 
|cut -d, -f1,4,9,11,14,16 |grep -v '<root_account>’
user,password_enabled,access_key_1_active,access_key_1_last_used_date, 
access_key_2_active,access_key_2_last_used_date
spindler,false,true,2017-01-22T00:11:00+00:00,false,N/A
$ aws iam list-access-keys --user-name spindler --query 
"AccessKeyMetadata[].{AccessKeyId:AccessKeyId, Status:Status}” 
[
{
"Status": "Active",
"AccessKeyId": "AKIAISKTDTHXSGFO5ZFQ”
}
]
$ aws iam delete-access-key --access-key AKIAISKTDTHXSGFO5ZFQ –-user-name spindler
IAM Password Policies
▷At least one uppercase letter
▷At least one lowercase letter
▷At least one symbol
▷At least one number
▷Minimum length of 14
▷Prevent password reuse
▷Expires within 90 days
Getting and Setting Password Policies
$ aws iam get-account-password-policy
{
"PasswordPolicy": {
"AllowUsersToChangePassword": true,
"RequireLowercaseCharacters": true,
"RequireUppercaseCharacters": true,
"MinimumPasswordLength": 14,
"RequireNumbers": true,
"RequireSymbols": true,
"ExpirePasswords": true
}
}
$ aws iam update-account-password-policy --require-uppercase-characters
$ aws iam update-account-password-policy --require-lowercase-characters
$ aws iam update-account-password-policy --require-symbols
$ aws iam update-account-password-policy --require-numbers
$ aws iam update-account-password-policy --minimum-password-length 14
$ aws iam update-account-password-policy --password-reuse-prevention 24
$ aws iam update-account-password-policy --max-password-age 90
IAM Policies
▷ Ensure IAM policies are attached only to
groups or roles [1] [2]
▷Ensure IAM Master and Manager roles are
active (like RBAC, use with EC2 and
Lambda)
▷Ensure IAM instance roles are used for AWS
resource access for instances [3][4]
▷Ensure there are no policies that allow full
“*:*” administrative privileges[1] http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
[2] http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html
[3] http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html
[4] http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon- ec2.html
IAM Policies
$ aws iam list-users --query 'Users[*].UserName' --output text
$ aws iam list-attached-user-policies --user-name <iam_user>
$ aws iam list-user-policies --user-name <iam_user>
$ aws iam list-policies --output text |awk '{print $2","$5}' 
|grep -v "arn:aws:iam::aws:policy”
arn:aws:iam::XXXXXXXXXXXX:policy/cloudformationcreatestack,v2
arn:aws:iam::XXXXXXXXXXXX:policy/IAM-Manager,v1
$ aws iam get-policy-version --policy-arn <arn> --version <version> 
--query "PolicyVersion.Document.Statement[?Effect == 'Allow' && 
contains(Resource, '*') && contains (Action, '*')]”
$ aws iam list-entities-for-policy --policy-arn <arn>
$ aws iam detach-role-policy --role-name <role> --policy-arn <arn>
Interfacing with AWS Support
▷Consider enabling security questions for
AWS support calls
▷Maintain security and current contact details
▷Ensure a support role has been created to
manage incidents with AWS support
▷Support does not allow you to allow or deny
access to individual actions so assign
allowing access to all cases, so assign
appropriately
Interfacing with AWS Support
$ aws iam list-policies --query "Policies[?PolicyName == 'AWSSupportAccess']”
[
{
"PolicyName": "AWSSupportAccess",
"CreateDate": "2015-02-06T18:41:11Z",
"AttachmentCount": 0,
"IsAttachable": true,
"PolicyId": "ANPAJSNKQX2OW67GF4S7E",
"DefaultVersionId": "v1",
"Path": "/",
"Arn": "arn:aws:iam::aws:policy/AWSSupportAccess",
"UpdateDate": "2015-02-06T18:41:11Z”
}
]
AWS CLI Security Auditing
Logging (and some Log Management)
Logging
▷Ensure CloudTrail is enabled in all regions
▷Ensure CloudTrail log file validation is
enabled
▷Ensure the S3 bucket CloudTrail logs to is
not publicly accessible
▷Ensure CloudTrail trails are integrated with
CloudWatch Logs
▷Ensure VPC flow logging is enabled in all
VPCs [1]
[1] http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/flow-logs.html
Logging
$ aws cloudtrail describe-trails --query "trailList[].IsMultiRegionTrail" --output text
True
$ aws cloudtrail create-trail --name <trail_name> --bucket-name 
<s3_bucket_for_cloudtrail> --is-multi-region-trail
$ aws cloudtrail update-trail --name <trail_name> --is-multi-region-trail
$ aws cloudtrail describe-trails --query "trailList[].LogFileValidationEnabled” --output text
True
$ aws cloudtrail update-trail --name <trail_name> --enable-log-file-validation
$ aws cloudtrail describe-trails --query 'trailList[*].S3BucketName' --output text
$ aws s3api get-bucket-acl --bucket <bucket_name> |grep URI |grep AllUsers
$ aws cloudtrail describe-trails --query "trailList[].CloudWatchLogsLogGroupArn" --output text
$ aws cloudtrail get-trail-status --name <trail_name>
$ aws ec2 describe-flow-logs --query FlowLogs[].FlowLogId --output text
$ aws ec2 describe-flow-logs --query FlowLogs[].ResourceId --output text
$ aws ec2 describe-flow-logs --filter "Name=resource-id,Values=<vpc>" |grep FlowLogStatus
Log and Key Management
▷Ensure S3 bucket access logging is enabled
on the CloudTrail S3 bucket
▷Adjust log retention according to
requirements [1]
▷Ensure AWS Config is enabled in all regions
▷Consider encrypting CloudTrail logs at rest
using KMS and ensure keys are rotated [2]
[1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/SettingLogRetention.html
[2] https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html
Log and Key Management
$ aws s3api get-bucket-logging --bucket <s3_bucket_for_cloudtrail>
$ aws configservice describe-configuration-recorders
$ aws cloudtrail describe-trails |grep KmsKeyId
$ aws cloudtrail update-trail --name <trail_name> --kms-id <cloudtrail_kms_key> 
aws kms put-key-policy --key-id <cloudtrail_kms_key> 
--policy <cloudtrail_kms_key_policy>
$ aws kms list-keys
$ aws kms get-key-rotation-status --key-id <kms_key_id>
AWS CLI Security Auditing
IAM Monitoring (Logging, Metrics, Alerting)
IAM Monitoring
▷Unauthorized API calls
▷Management Console sign-in without MFA
▷Usage of "root" account
▷IAM policy changes
▷AWS Management Console authentication
failures
▷Set thresholds accordingly [1]
[1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
IAM Monitoring – Unauthorised API Calls
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.errorCode = "*UnauthorizedOperation") || ($.errorCode = "AccessDenied*") }”
$ aws cloudwatch describe-alarms –-query 
'MetricAlarms[?MetricName==`<unauthorized_api_calls_metric>`]'
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <unauthorized_api_calls_metric> --metric-transformations 
metricName=<unauthorized_api_calls_metric>,metricNamespace='Audit',
metricVal ue=1 --filter-pattern '{ ($.errorCode = "*UnauthorizedOperation") 
|| ($.errorCode = "AccessDenied*") }'
$ aws sns create-topic --name <sns_topic_name>
$ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> 
-- notification-endpoint <sns_subscription_endpoints>
$ aws cloudwatch put-metric-alarm --alarm-name <unauthorized_api_calls_alarm> 
--metric-name <unauthorized_api_calls_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – Login Without MFA
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = "ConsoleLogin") && ($.additionalEventData.MFAUsed
!= "Yes") }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<no_mfa_console_signin_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <no_mfa_console_signin_metric> --metric-transformations 
metricName=<no_mfa_console_signin_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = "ConsoleLogin") && 
($.additionalEventData.MFAUsed != "Yes") }’
$ aws sns create-topic --name <sns_topic_name>
$ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> 
-- notification-endpoint <sns_subscription_endpoints>
$ aws cloudwatch put-metric-alarm --alarm-name <no_mfa_console_signin_alarm> 
--metric-name <no_mfa_console_signin_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – “root” Account Usage
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ $.userIdentity.type = "Root" && $.userIdentity.invokedBy
NOT EXISTS && $.eventType != "AwsServiceEvent" } ”
$ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<root_usage_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <root_usage_metric> --metric-transformations 
metricName=<root_usage_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ $.userIdentity.type = "Root" && $.userIdentity.invokedBy NOT EXISTS 
&& $.eventType != "AwsServiceEvent" }’
$ aws sns create-topic --name <sns_topic_name>
$ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> 
-- notification-endpoint <sns_subscription_endpoints>
$ aws cloudwatch put-metric-alarm --alarm-name <root_usage_alarm> 
--metric-name <root_usage_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' -- alarm-actions <sns_topic_arn>
IAM Monitoring – IAM Policy Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern":
"{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)||($.eventName=Delete
UserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)||($.eventName=P
utUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy)||($.eventName=Cr
eatePolicyVersion)||($.eventName=DeletePolicyVersion)||($.eventName=AttachRolePolicy)|
|($.eventName=DetachRolePolicy)||($.eventName=AttachUserPolicy)||($.eventName=DetachUs
erPolicy)||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}"
$ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<iam_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <iam_changes_metric> --metric-transformations 
metricName=<iam_changes_metric>,metricNamespace='Audit',metricValue=1
--filter-pattern '{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)
||($.eventName=DeleteUserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)
||($.eventName=PutUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy)
||($.eventName=CreatePolicyVersion)||($.eventName=DeletePolicyVersion)
||($.eventName=AttachRolePolicy)||($.eventName=DetachRolePolicy)
||($.eventName=AttachUserPolicy)||($.eventName=DetachUserPolicy)
||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}'
IAM Monitoring – Authentication Failures
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = ConsoleLogin) && ($.errorMessage = "Failed
authentication") }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<console_signin_failure_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <console_signin_failure_metric> --metric-transformations 
metricName=<console_signin_failure_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = ConsoleLogin) && 
($.errorMessage = ""Failed authentication"") }’
$ aws sns create-topic --name <sns_topic_name>
$ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> 
-- notification-endpoint <sns_subscription_endpoints>
$ aws cloudwatch put-metric-alarm --alarm-name <console_signin_failure_alarm> 
--metric-name <console_signin_failure_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
AWS CLI Security Auditing
Config Monitoring (Logging, Metrics, Alerting)
CloudTrail, Config, S3, and Key
Monitoring
▷CloudTrail configuration changes
▷AWS Config configuration changes
▷S3 bucket policy changes
▷Disabling or scheduled deletion of customer
created CMKs
▷Set thresholds accordingly [1]
[1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
Monitoring – CloudTrail Config Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = CreateTrail) || ($.eventName = UpdateTrail) ||
($.eventName = DeleteTrail) || ($.eventName = StartLogging) || ($.eventName =
StopLogging) }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<cloudtrail_cfg_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <cloudtrail_cfg_changes_metric> --metric-transformations 
metricName=<cloudtrail_cfg_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = CreateTrail) || ($.eventName = UpdateTrail) 
|| ($.eventName = DeleteTrail) || ($.eventName = StartLogging) 
|| ($.eventName = StopLogging) }'
$ aws cloudwatch put-metric-alarm --alarm-name <cloudtrail_cfg_changes_alarm> 
--metric-name <cloudtrail_cfg_changes_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
Monitoring – AWS Config Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{($.eventSource = config.amazonaws.com) &&
(($.eventName=StopConfigurationRecorder)||($.eventName=DeleteDeliveryChannel)
||($.eventName=PutDeliveryChannel)||($.eventName=PutConfigurationRecorder))}”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<aws_config_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <aws_config_changes_metric> --metric-transformations 
metricName=<aws_config_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{($.eventSource = config.amazonaws.com) && 
(($.eventName=StopConfigurationRecorder)||($.eventName=DeleteDeliveryChannel) 
||($.even tName=PutDeliveryChannel)||($.eventName=PutConfigurationRecorder))}’
$ aws cloudwatch put-metric-alarm --alarm-name <aws_config_changes_alarm> 
--metric-name <aws_config_changes_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
Monitoring – S3 Bucket Policy Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventSource = s3.amazonaws.com) && (($.eventName =
PutBucketAcl) || ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) ||
($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) ||
($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) || ($.eventName
= DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<s3_bucket_policy_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <s3_bucket_policy_changes_metric> --metric-transformations 
metricName=<s3_bucket_policy_changes_metric>,metricNamespace='Audit',metric Value=1 
--filter-pattern '{ ($.eventSource = s3.amazonaws.com) && (($.eventName = PutBucketAcl)
|| ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) 
|| ($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) 
|| ($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) 
|| ($.eventName = DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }’
$ aws cloudwatch put-metric-alarm --alarm-name <s3_bucket_policy_changes_alarm> 
--metric-name <s3_bucket_policy_changes_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
Monitoring – Customer Created CMKs
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{($.eventSource = kms.amazonaws.com) &&
(($.eventName=DisableKey)||($.eventName=ScheduleKeyDeletion))} }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<disable_or_delete_cmk_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <disable_or_delete_cmk_metric> --metric-transformations 
metricName=<disable_or_delete_cmk_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{($.eventSource = kms.amazonaws.com) && 
(($.eventName=DisableKey)||($.eventName=ScheduleKeyDeletion))}’
$ aws cloudwatch put-metric-alarm --alarm-name <disable_or_delete_cmk_alarm> 
--metric-name <disable_or_delete_cmk_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
-- namespace 'Audit' --alarm-actions <sns_topic_arn>
AWS CLI Security Auditing
VPC Monitoring (Logging, Metrics, Alerting)
Security Group and VPC Monitoring
▷Security Group changes
▷NACL changes
▷Network Gateway changes
▷Route changes
▷VPC changes
▷SNS subscribers
▷Set thresholds accordingly [1]
[1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
IAM Monitoring – Security Group Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = AuthorizeSecurityGroupIngress) || ($.eventName =
AuthorizeSecurityGroupEgress) || ($.eventName = RevokeSecurityGroupIngress) ||
($.eventName = RevokeSecurityGroupEgress) || ($.eventName = CreateSecurityGroup) ||
($.eventName = DeleteSecurityGroup)}”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<security_group_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <security_group_changes_metric> --metric-transformations 
metricName=<security_group_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = AuthorizeSecurityGroupIngress)
|| ($.eventName = AuthorizeSecurityGroupEgress) 
|| ($.eventName = RevokeSecurityGroupIngress) || ($.eventName = RevokeSecurityGroupEgress) 
|| ($.eventName = CreateSecurityGroup) || ($.eventName = DeleteSecurityGroup)}'
$ aws cloudwatch put-metric-alarm --alarm-name <security_group_changes_alarm> 
--metric-name <security_group_changes_metric> --statistic Sum --period 300 
--threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – NACL Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = CreateNetworkAcl) || ($.eventName =
CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName =
DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName =
ReplaceNetworkAclAssociation) }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<nacl_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <nacl_changes_metric> --metric-transformations 
metricName=<nacl_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = CreateNetworkAcl) 
|| ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) 
|| ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) 
|| ($.eventName = ReplaceNetworkAclAssociation) }’
$ aws cloudwatch put-metric-alarm --alarm-name <nacl_changes_alarm> 
--metric-name <nacl_changes_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – Gateway Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = CreateCustomerGateway) || ($.eventName =
DeleteCustomerGateway) || ($.eventName = AttachInternetGateway) || ($.eventName =
CreateInternetGateway) || ($.eventName = DeleteInternetGateway) || ($.eventName =
DetachInternetGateway) }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<network_gw_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <network_gw_changes_metric> --metric-transformations 
metricName=<network_gw_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = CreateCustomerGateway)
|| ($.eventName = DeleteCustomerGateway) || ($.eventName = AttachInternetGateway)
|| ($.eventName = CreateInternetGateway) || ($.eventName = DeleteInternetGateway)
|| ($.eventName = DetachInternetGateway) }’
$ aws cloudwatch put-metric-alarm --alarm-name <network_gw_changes_alarm> 
--metric-name <network_gw_changes_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – Route Table Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = CreateRoute) || ($.eventName = CreateRouteTable) ||
($.eventName = ReplaceRoute) || ($.eventName = ReplaceRouteTableAssociation) ||
($.eventName = DeleteRouteTable) || ($.eventName = DeleteRoute) || ($.eventName =
DisassociateRouteTable) }”
$ aws cloudwatch describe-alarms 
--query 'MetricAlarms[?MetricName==`<route_table_changes_metric>`]’
$ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn>
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <route_table_changes_metric> --metric-transformations 
metricName=<route_table_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = CreateRoute) || ($.eventName = CreateRouteTable) 
|| ($.eventName = ReplaceRoute) || ($.eventName = ReplaceRouteTableAssociation) 
|| ($.eventName = DeleteRouteTable) || ($.eventName = DeleteRoute) 
|| ($.eventName = DisassociateRouteTable) }’
$ aws cloudwatch put-metric-alarm --alarm-name <route_table_changes_alarm> 
--metric-name <route_table_changes_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
IAM Monitoring – VPC Changes
$ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name>
"filterPattern": "{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) ||
($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) ||
($.eventName = CreateVpcPeeringConnection) || ($.eventName =
DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) ||
($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) ||
($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }”
$ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<vpc_changes_metric>`]’
$ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> 
--filter-name <vpc_changes_metric> --metric-transformations 
metricName=<vpc_changes_metric>,metricNamespace='Audit',metricValue=1 
--filter-pattern '{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) 
|| ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) 
|| ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection)
|| ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) 
|| ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) 
|| ($.eventName = EnableVpcClassicLink) }’
$ aws cloudwatch put-metric-alarm --alarm-name <vpc_changes_alarm> 
--metric-name <vpc_changes_metric> --statistic Sum --period 300 --threshold 1 
--comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 
--namespace 'Audit' --alarm-actions <sns_topic_arn>
Monitoring – SNS subscribers
$ aws sns list-topics
$ aws sns list-subscriptions-by-topic --topic-arn <topic_arn>
AWS CLI Security Auditing
Networking (VPCs and Security Groups)
Networking and Security Groups
▷Ensure SSH is not open to the world
▷Ensure RDP is not open to the world
▷Ensure the default security group of every
VPC restricts all traffic [1]
▷Ensure routing tables for VPC peering are
"least access” [2]
[1] http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
[2] http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/peering- configurations-partial-access.html
Networking and Security Groups
$ aws ec2 describe-security-groups --filters "Name=ip-permission.to-port,Values=22" "Name=ip-
permission.cidr,Values=0.0.0.0/0"$
$ aws ec2 describe-security-groups --filters "Name=ip-permission.to-port,Values=3389" "Name=ip-
permission.cidr,Values=0.0.0.0/0”
$ aws ec2 describe-security-groups --filters Name=group-name,Values='default' 
--query 'SecurityGroups[].{IpPermissions:IpPermissions,GroupId:GroupId}’
$ aws ec2 describe-security-groups --filters Name=group-name,Values='default' 
--query 'SecurityGroups[].{IpPermissionsEgress:IpPermissionsEgress 
,GroupId:GroupId}’
$ aws ec2 describe-route-tables --query 
"RouteTables[*].{RouteTableId:RouteTableId, VpcId:VpcId, Routes:Routes,
AssociatedSubnets:Associations[*].SubnetId}" |grep GatewayID |grep pcx-
Thanks for your patience
richard@lateralblast.com.au

Mais conteúdo relacionado

Mais procurados

Building Secure Architectures on AWS
Building Secure Architectures on AWSBuilding Secure Architectures on AWS
Building Secure Architectures on AWSAmazon Web Services
 
Practical Steps to Hack-Proofing AWS
Practical Steps to Hack-Proofing AWSPractical Steps to Hack-Proofing AWS
Practical Steps to Hack-Proofing AWSAmazon Web Services
 
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013Amazon Web Services
 
Network Security and Access Control in AWS
Network Security and Access Control in AWSNetwork Security and Access Control in AWS
Network Security and Access Control in AWSAmazon Web Services
 
Aws security overview q3 2010 v2
Aws security overview q3 2010 v2Aws security overview q3 2010 v2
Aws security overview q3 2010 v2ReadMaloney
 
Aws security best practices
Aws security best practicesAws security best practices
Aws security best practicesSundeep Roxx
 
AWS 201 - A Walk through the AWS Cloud: AWS Security Best Practices
AWS 201 - A Walk through the AWS Cloud: AWS Security Best PracticesAWS 201 - A Walk through the AWS Cloud: AWS Security Best Practices
AWS 201 - A Walk through the AWS Cloud: AWS Security Best PracticesAmazon Web Services
 
(SEC303) Architecting for End-To-End Security in the Enterprise
(SEC303) Architecting for End-To-End Security in the Enterprise(SEC303) Architecting for End-To-End Security in the Enterprise
(SEC303) Architecting for End-To-End Security in the EnterpriseAmazon Web Services
 
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYC
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYCAWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYC
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYCAmazon Web Services
 
What's (nearly) new | AWS Security Roadshow Dublin
What's (nearly) new | AWS Security Roadshow DublinWhat's (nearly) new | AWS Security Roadshow Dublin
What's (nearly) new | AWS Security Roadshow DublinAmazon Web Services
 
In Depth: AWS Shared Security Model
In Depth: AWS Shared Security ModelIn Depth: AWS Shared Security Model
In Depth: AWS Shared Security ModelAmazon Web Services
 
Security Architecture recommendations for your new AWS operation - Pop-up Lof...
Security Architecture recommendations for your new AWS operation - Pop-up Lof...Security Architecture recommendations for your new AWS operation - Pop-up Lof...
Security Architecture recommendations for your new AWS operation - Pop-up Lof...Amazon Web Services
 
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...Amazon Web Services
 
Security Day What's (nearly) New
Security Day What's (nearly) NewSecurity Day What's (nearly) New
Security Day What's (nearly) NewAmazon Web Services
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
Crypto-Options on AWS | Security Roadshow Dublin
Crypto-Options on AWS | Security Roadshow DublinCrypto-Options on AWS | Security Roadshow Dublin
Crypto-Options on AWS | Security Roadshow DublinAmazon Web Services
 

Mais procurados (20)

Building Secure Architectures on AWS
Building Secure Architectures on AWSBuilding Secure Architectures on AWS
Building Secure Architectures on AWS
 
Practical Steps to Hack-Proofing AWS
Practical Steps to Hack-Proofing AWSPractical Steps to Hack-Proofing AWS
Practical Steps to Hack-Proofing AWS
 
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013
AWS Security – Keynote Address (SEC101) | AWS re:Invent 2013
 
AWS Security Best Practices
AWS Security Best PracticesAWS Security Best Practices
AWS Security Best Practices
 
Intro to AWS: Security
Intro to AWS: SecurityIntro to AWS: Security
Intro to AWS: Security
 
Network Security and Access Control in AWS
Network Security and Access Control in AWSNetwork Security and Access Control in AWS
Network Security and Access Control in AWS
 
Aws security overview q3 2010 v2
Aws security overview q3 2010 v2Aws security overview q3 2010 v2
Aws security overview q3 2010 v2
 
Aws security best practices
Aws security best practicesAws security best practices
Aws security best practices
 
Aws security Fundamentals
Aws security Fundamentals Aws security Fundamentals
Aws security Fundamentals
 
AWS 201 - A Walk through the AWS Cloud: AWS Security Best Practices
AWS 201 - A Walk through the AWS Cloud: AWS Security Best PracticesAWS 201 - A Walk through the AWS Cloud: AWS Security Best Practices
AWS 201 - A Walk through the AWS Cloud: AWS Security Best Practices
 
Understanding AWS Security
Understanding AWS SecurityUnderstanding AWS Security
Understanding AWS Security
 
(SEC303) Architecting for End-To-End Security in the Enterprise
(SEC303) Architecting for End-To-End Security in the Enterprise(SEC303) Architecting for End-To-End Security in the Enterprise
(SEC303) Architecting for End-To-End Security in the Enterprise
 
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYC
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYCAWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYC
AWS Security Overview - AWS CISO Steve Schmidt - AWS Summit 2012 - NYC
 
What's (nearly) new | AWS Security Roadshow Dublin
What's (nearly) new | AWS Security Roadshow DublinWhat's (nearly) new | AWS Security Roadshow Dublin
What's (nearly) new | AWS Security Roadshow Dublin
 
In Depth: AWS Shared Security Model
In Depth: AWS Shared Security ModelIn Depth: AWS Shared Security Model
In Depth: AWS Shared Security Model
 
Security Architecture recommendations for your new AWS operation - Pop-up Lof...
Security Architecture recommendations for your new AWS operation - Pop-up Lof...Security Architecture recommendations for your new AWS operation - Pop-up Lof...
Security Architecture recommendations for your new AWS operation - Pop-up Lof...
 
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...
Architecting for End-to-End Security in the Enterprise (ARC308) | AWS re:Inve...
 
Security Day What's (nearly) New
Security Day What's (nearly) NewSecurity Day What's (nearly) New
Security Day What's (nearly) New
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Crypto-Options on AWS | Security Roadshow Dublin
Crypto-Options on AWS | Security Roadshow DublinCrypto-Options on AWS | Security Roadshow Dublin
Crypto-Options on AWS | Security Roadshow Dublin
 

Destaque

You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...Amazon Web Services
 
AWS Security Best Practices and Design Patterns
AWS Security Best Practices and Design PatternsAWS Security Best Practices and Design Patterns
AWS Security Best Practices and Design PatternsAmazon Web Services
 
Webcast: AWS account setup tips for audit, governance, and security
Webcast:  AWS account setup tips for audit, governance, and securityWebcast:  AWS account setup tips for audit, governance, and security
Webcast: AWS account setup tips for audit, governance, and securityApplatix
 
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014(SEC201) AWS Security Keynote Address | AWS re:Invent 2014
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014Amazon Web Services
 
Getting Started with AWS Security
 Getting Started with AWS Security Getting Started with AWS Security
Getting Started with AWS SecurityAmazon Web Services
 
Introduction to Three AWS Security Services - November 2016 Webinar Series
Introduction to Three AWS Security Services - November 2016 Webinar SeriesIntroduction to Three AWS Security Services - November 2016 Webinar Series
Introduction to Three AWS Security Services - November 2016 Webinar SeriesAmazon Web Services
 
Advanced Security Best Practices Masterclass
Advanced Security Best Practices MasterclassAdvanced Security Best Practices Masterclass
Advanced Security Best Practices MasterclassAmazon Web Services
 
Accenture Security Framework for AWS: Monetary Authority of Singapore Guidelines
Accenture Security Framework for AWS: Monetary Authority of Singapore GuidelinesAccenture Security Framework for AWS: Monetary Authority of Singapore Guidelines
Accenture Security Framework for AWS: Monetary Authority of Singapore GuidelinesAccenture Operations
 
Journey Through The Cloud - Security Best Practices
Journey Through The Cloud - Security Best Practices Journey Through The Cloud - Security Best Practices
Journey Through The Cloud - Security Best Practices Amazon Web Services
 
Getting Started with AWS Security
Getting Started with AWS SecurityGetting Started with AWS Security
Getting Started with AWS SecurityAmazon Web Services
 
Introduction to AWS IAM
Introduction to AWS IAMIntroduction to AWS IAM
Introduction to AWS IAMKnoldus Inc.
 

Destaque (18)

You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
 
AWS Security Best Practices and Design Patterns
AWS Security Best Practices and Design PatternsAWS Security Best Practices and Design Patterns
AWS Security Best Practices and Design Patterns
 
Webcast: AWS account setup tips for audit, governance, and security
Webcast:  AWS account setup tips for audit, governance, and securityWebcast:  AWS account setup tips for audit, governance, and security
Webcast: AWS account setup tips for audit, governance, and security
 
Intro to AWS: Security
Intro to AWS: SecurityIntro to AWS: Security
Intro to AWS: Security
 
Shared Security in AWS
Shared Security in AWSShared Security in AWS
Shared Security in AWS
 
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014(SEC201) AWS Security Keynote Address | AWS re:Invent 2014
(SEC201) AWS Security Keynote Address | AWS re:Invent 2014
 
A guide on Aws Security Token Service
A guide on Aws Security Token ServiceA guide on Aws Security Token Service
A guide on Aws Security Token Service
 
Getting Started with AWS Security
 Getting Started with AWS Security Getting Started with AWS Security
Getting Started with AWS Security
 
Security on AWS
Security on AWSSecurity on AWS
Security on AWS
 
Introduction to Three AWS Security Services - November 2016 Webinar Series
Introduction to Three AWS Security Services - November 2016 Webinar SeriesIntroduction to Three AWS Security Services - November 2016 Webinar Series
Introduction to Three AWS Security Services - November 2016 Webinar Series
 
Advanced Security Best Practices Masterclass
Advanced Security Best Practices MasterclassAdvanced Security Best Practices Masterclass
Advanced Security Best Practices Masterclass
 
Introduction to AWS Security
Introduction to AWS SecurityIntroduction to AWS Security
Introduction to AWS Security
 
Accenture Security Framework for AWS: Monetary Authority of Singapore Guidelines
Accenture Security Framework for AWS: Monetary Authority of Singapore GuidelinesAccenture Security Framework for AWS: Monetary Authority of Singapore Guidelines
Accenture Security Framework for AWS: Monetary Authority of Singapore Guidelines
 
Networking and Security
Networking and SecurityNetworking and Security
Networking and Security
 
Journey Through The Cloud - Security Best Practices
Journey Through The Cloud - Security Best Practices Journey Through The Cloud - Security Best Practices
Journey Through The Cloud - Security Best Practices
 
Getting Started with AWS Security
Getting Started with AWS SecurityGetting Started with AWS Security
Getting Started with AWS Security
 
Introduction to AWS IAM
Introduction to AWS IAMIntroduction to AWS IAM
Introduction to AWS IAM
 
Security Best Practices
Security Best PracticesSecurity Best Practices
Security Best Practices
 

Semelhante a AWS Security - An Engineer’s Introduction to AWS Security Auditing using CIS and the CLI

Aws iam best practices to live by
Aws iam best practices to live byAws iam best practices to live by
Aws iam best practices to live byJohn Varghese
 
Introduction to 2FA on AWS
Introduction to 2FA on AWSIntroduction to 2FA on AWS
Introduction to 2FA on AWSOlinData
 
AWS Security Essentials
AWS Security EssentialsAWS Security Essentials
AWS Security EssentialsAaron Bedra
 
It's 10pm, Do You Know Where Your Access Keys Are?
It's 10pm, Do You Know Where Your Access Keys Are?It's 10pm, Do You Know Where Your Access Keys Are?
It's 10pm, Do You Know Where Your Access Keys Are?Ken Johnson
 
Advanced security best practices - Masterclass - Pop-up Loft Tel Aviv
Advanced security best practices - Masterclass - Pop-up Loft Tel AvivAdvanced security best practices - Masterclass - Pop-up Loft Tel Aviv
Advanced security best practices - Masterclass - Pop-up Loft Tel AvivAmazon Web Services
 
Advanced Security Masterclass - Tel Aviv Loft
Advanced Security Masterclass - Tel Aviv LoftAdvanced Security Masterclass - Tel Aviv Loft
Advanced Security Masterclass - Tel Aviv LoftIan Massingham
 
External Security Services Round: Security Week at the San Francisco Loft
External Security Services Round: Security Week at the San Francisco LoftExternal Security Services Round: Security Week at the San Francisco Loft
External Security Services Round: Security Week at the San Francisco LoftAmazon Web Services
 
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...Amazon Web Services
 
Controlling Access to your Resources
Controlling Access to your ResourcesControlling Access to your Resources
Controlling Access to your ResourcesAmazon Web Services
 
Security Day IAM Recommended Practices
Security Day IAM Recommended PracticesSecurity Day IAM Recommended Practices
Security Day IAM Recommended PracticesAmazon Web Services
 
(SEC302) IAM Best Practices To Live By
(SEC302) IAM Best Practices To Live By(SEC302) IAM Best Practices To Live By
(SEC302) IAM Best Practices To Live ByAmazon Web Services
 
Security Day IAM Recommended Practices
Security Day IAM Recommended PracticesSecurity Day IAM Recommended Practices
Security Day IAM Recommended PracticesAmazon Web Services
 
Automating Security in Cloud Workloads with DevSecOps
Automating Security in Cloud Workloads with DevSecOps Automating Security in Cloud Workloads with DevSecOps
Automating Security in Cloud Workloads with DevSecOps Kristana Kane
 
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)Amazon Web Services
 
Tips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramTips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramBeyondTrust
 
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014Amazon Web Services
 
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...Amazon Web Services
 

Semelhante a AWS Security - An Engineer’s Introduction to AWS Security Auditing using CIS and the CLI (20)

Aws iam best practices to live by
Aws iam best practices to live byAws iam best practices to live by
Aws iam best practices to live by
 
Introduction to 2FA on AWS
Introduction to 2FA on AWSIntroduction to 2FA on AWS
Introduction to 2FA on AWS
 
AWS Security by Design
AWS Security by Design AWS Security by Design
AWS Security by Design
 
AWS Security Essentials
AWS Security EssentialsAWS Security Essentials
AWS Security Essentials
 
It's 10pm, Do You Know Where Your Access Keys Are?
It's 10pm, Do You Know Where Your Access Keys Are?It's 10pm, Do You Know Where Your Access Keys Are?
It's 10pm, Do You Know Where Your Access Keys Are?
 
Advanced security best practices - Masterclass - Pop-up Loft Tel Aviv
Advanced security best practices - Masterclass - Pop-up Loft Tel AvivAdvanced security best practices - Masterclass - Pop-up Loft Tel Aviv
Advanced security best practices - Masterclass - Pop-up Loft Tel Aviv
 
Advanced Security Masterclass - Tel Aviv Loft
Advanced Security Masterclass - Tel Aviv LoftAdvanced Security Masterclass - Tel Aviv Loft
Advanced Security Masterclass - Tel Aviv Loft
 
External Security Services Round: Security Week at the San Francisco Loft
External Security Services Round: Security Week at the San Francisco LoftExternal Security Services Round: Security Week at the San Francisco Loft
External Security Services Round: Security Week at the San Francisco Loft
 
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...
SEC309 Secure Your Cloud Investment: Mastering AWS Identity Access Management...
 
Controlling Access to your Resources
Controlling Access to your ResourcesControlling Access to your Resources
Controlling Access to your Resources
 
Security Day IAM Recommended Practices
Security Day IAM Recommended PracticesSecurity Day IAM Recommended Practices
Security Day IAM Recommended Practices
 
(SEC302) IAM Best Practices To Live By
(SEC302) IAM Best Practices To Live By(SEC302) IAM Best Practices To Live By
(SEC302) IAM Best Practices To Live By
 
Security Day IAM Recommended Practices
Security Day IAM Recommended PracticesSecurity Day IAM Recommended Practices
Security Day IAM Recommended Practices
 
Automating Security in Cloud Workloads with DevSecOps
Automating Security in Cloud Workloads with DevSecOps Automating Security in Cloud Workloads with DevSecOps
Automating Security in Cloud Workloads with DevSecOps
 
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
 
Tips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramTips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management Program
 
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014
(SEC402) Intrusion Detection in the Cloud | AWS re:Invent 2014
 
Toward Full Stack Security
Toward Full Stack SecurityToward Full Stack Security
Toward Full Stack Security
 
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...
Operational Excellence for Identity & Access Management (SEC334) - AWS re:Inv...
 
IAM Recommended Practices
IAM Recommended PracticesIAM Recommended Practices
IAM Recommended Practices
 

Último

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

AWS Security - An Engineer’s Introduction to AWS Security Auditing using CIS and the CLI

  • 1. An Engineer’s Introduction to AWS Security Auditing using CIS and the CLI richard@lateralblast.com.au
  • 2. Caveat: I’m an Engineer, not a developer. I script, I don’t code, this won’t be pretty...
  • 3. Goals of this presentation ▷Introduction ▷Quick overview of CIS ▷Quick overview of security and AWS ▷Pass on some lessons learned ▷Provide some CLI examples ▷Save you some time and pain ▷Recommendations based on these
  • 4. So why write your own tool? Besides CLI Naming inconsistencies…
  • 5. Besides being a good way to learn AWS Security… ▷I didn’t want to have to go to the web interface or a document every time I wanted to do a security review ▷AWS has Trusted Advisor, but charges for more than basic checks ▷Although the CLI has quite good help, the naming and use of tags and switches is frustratingly inconsistent ▷No source (including me) is perfect, more than one source of verification is good
  • 6. I already had a Security Auditing tool of my own… [1] ▷Supported a number of UNIX OS, including Amazon Linux ▷Used the CIS Benchmarks already ▷Was free (apart from my time) and required minimal additional software ▷Had a number of people using it, so would get some additional testing ▷I could add additional tests as I discovered new security recommendations and tips[1] https://github.com/lateralblast/lunar
  • 7. Security Benchmarks Why choose the CIS Benchmark?
  • 8. It’s good to have a common point of reference as a start… ▷Used by a lot of people and places as a basis for their own security processes ▷Has a long track record ▷Well trusted, and has industry support ▷Mentioned on AWS Security Blog [1] ▷Semi regularly updated ▷Has explanation and implementation notes as well as the standard checkbox ▷Has GUI and CLI remediation steps [1] https://aws.amazon.com/blogs/security/tag/cis-aws-foundations-benchmark/
  • 9. But it’s only a start… ▷It’s not perfect (e.g. typos in remediation) ▷Not everything is going to be applicable to your organisation / application ▷You’ll have your own processes on top of it ▷Sometimes lags with updates ▷It’s always good to have more than one source of verification, especially for security ▷It’s a paper document, needs to be automated to reduce work and human error
  • 10. Security Fundamentals An Engineers attempt to explain security…
  • 11. Traditional: Security in layers Network, Application, OS, Users, etc. Least access / privilege by default Restrict access to privileged accounts Monitor usage of privileged accounts Use Multifactor Authentication Enable password complexity Enable password / credential rotation Create roles and add users to them Enable and manage logging Generate alerts Encrypt at rest and in transit What is old is new again… AWS: Security in layers Network, Application, OS, Users, etc. Least access / privilege by default Restrict access to “root” account Monitor use of IAM Use Multifactor Authentication Enable password complexity Enable password / credential rotation Create roles and add users to them Enable and manage logging Generate alerts Encrypt at rest and in transit
  • 12. AWS CLI Security Auditing An Engineers attempt to audit via the CLI…
  • 13. What does this involve? ▷An overview of key areas: ▷IAM (Users, Groups, Roles, Policies, MFA) ▷Monitoring (Logging, Metrics, Alerting) ▷Encryption (at rest and in flight) ▷Networking (VPCs and Security Groups) ▷Some CLI examples of how to get and set security parameters where appropriate
  • 14. AWS CLI Security Auditing IAM (Users, Groups, Roles, Policies, MFA)
  • 15. Avoid use of the “root” account ▷Attach IAM policies to groups and roles and use them to delegate responsibility to management accounts [1] ▷Minimise use of “root” account to those functions that require it e.g. requesting a penetration test of creating a CloudFront private key [1] http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
  • 16. IAM Account Security (MFAs etc.) ▷Ensure MFA is enabled for “root” account ▷Ensure MFA is enabled for other IAM users ▷Consider hardware MFA for ”root” account ▷Use MFA devices where applicable and lock the device away in the case of the root user ▷Delegate management of MFA devices [1] ▷Hardware, Virtual and SMS based MFA [2] [1] https://aws.amazon.com/blogs/security/how-to-delegate-management-of-multi-factor-authentication-to-aws-iam-users/ [2] http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html
  • 17. Checking MFAs $ aws iam generate-credential-report { "State": "STARTED", "Description": "No report exists. Starting a new report generation task” } $ aws iam get-credential-report --query 'Content' --output text |base64 –D |cut -d, f1,4,8 user,password_enabled,mfa_active <root_account>,not_supported,true spindler,false,false $ aws iam list-virtual-mfa-devices –-query “VirtualMFADevices” [ { "SerialNumber": "arn:aws:iam::123456789012:mfa/ExampleMFADevice” } ] $ aws iam get-account-summary | grep "AccountMFAEnabled” "AccountMFAEnabled": 1,
  • 18. Managing Credentials ▷Manage Access and Secret keys used for programmatic access via SDK and HTTP [1] ▷Ensure credentials unused for 90 days or greater are removed ▷Ensure keys are rotated every 90 days or less ▷Done manually, or better programmatically ▷Only create keys for users that need them, and do not have keys for “root” account [2] [1] http://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html [2] http://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html
  • 19. Checking Credentials $ aws iam generate-credential-report { "State": "STARTED", "Description": "No report exists. Starting a new report generation task” } $ aws iam get-credential-report --query 'Content' --output text |base64 –D |cut -d, -f1,4,9,11,14,16 |grep -v '<root_account>’ user,password_enabled,access_key_1_active,access_key_1_last_used_date, access_key_2_active,access_key_2_last_used_date spindler,false,true,2017-01-22T00:11:00+00:00,false,N/A $ aws iam list-access-keys --user-name spindler --query "AccessKeyMetadata[].{AccessKeyId:AccessKeyId, Status:Status}” [ { "Status": "Active", "AccessKeyId": "AKIAISKTDTHXSGFO5ZFQ” } ] $ aws iam delete-access-key --access-key AKIAISKTDTHXSGFO5ZFQ –-user-name spindler
  • 20. IAM Password Policies ▷At least one uppercase letter ▷At least one lowercase letter ▷At least one symbol ▷At least one number ▷Minimum length of 14 ▷Prevent password reuse ▷Expires within 90 days
  • 21. Getting and Setting Password Policies $ aws iam get-account-password-policy { "PasswordPolicy": { "AllowUsersToChangePassword": true, "RequireLowercaseCharacters": true, "RequireUppercaseCharacters": true, "MinimumPasswordLength": 14, "RequireNumbers": true, "RequireSymbols": true, "ExpirePasswords": true } } $ aws iam update-account-password-policy --require-uppercase-characters $ aws iam update-account-password-policy --require-lowercase-characters $ aws iam update-account-password-policy --require-symbols $ aws iam update-account-password-policy --require-numbers $ aws iam update-account-password-policy --minimum-password-length 14 $ aws iam update-account-password-policy --password-reuse-prevention 24 $ aws iam update-account-password-policy --max-password-age 90
  • 22. IAM Policies ▷ Ensure IAM policies are attached only to groups or roles [1] [2] ▷Ensure IAM Master and Manager roles are active (like RBAC, use with EC2 and Lambda) ▷Ensure IAM instance roles are used for AWS resource access for instances [3][4] ▷Ensure there are no policies that allow full “*:*” administrative privileges[1] http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html [2] http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html [3] http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html [4] http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon- ec2.html
  • 23. IAM Policies $ aws iam list-users --query 'Users[*].UserName' --output text $ aws iam list-attached-user-policies --user-name <iam_user> $ aws iam list-user-policies --user-name <iam_user> $ aws iam list-policies --output text |awk '{print $2","$5}' |grep -v "arn:aws:iam::aws:policy” arn:aws:iam::XXXXXXXXXXXX:policy/cloudformationcreatestack,v2 arn:aws:iam::XXXXXXXXXXXX:policy/IAM-Manager,v1 $ aws iam get-policy-version --policy-arn <arn> --version <version> --query "PolicyVersion.Document.Statement[?Effect == 'Allow' && contains(Resource, '*') && contains (Action, '*')]” $ aws iam list-entities-for-policy --policy-arn <arn> $ aws iam detach-role-policy --role-name <role> --policy-arn <arn>
  • 24. Interfacing with AWS Support ▷Consider enabling security questions for AWS support calls ▷Maintain security and current contact details ▷Ensure a support role has been created to manage incidents with AWS support ▷Support does not allow you to allow or deny access to individual actions so assign allowing access to all cases, so assign appropriately
  • 25. Interfacing with AWS Support $ aws iam list-policies --query "Policies[?PolicyName == 'AWSSupportAccess']” [ { "PolicyName": "AWSSupportAccess", "CreateDate": "2015-02-06T18:41:11Z", "AttachmentCount": 0, "IsAttachable": true, "PolicyId": "ANPAJSNKQX2OW67GF4S7E", "DefaultVersionId": "v1", "Path": "/", "Arn": "arn:aws:iam::aws:policy/AWSSupportAccess", "UpdateDate": "2015-02-06T18:41:11Z” } ]
  • 26. AWS CLI Security Auditing Logging (and some Log Management)
  • 27. Logging ▷Ensure CloudTrail is enabled in all regions ▷Ensure CloudTrail log file validation is enabled ▷Ensure the S3 bucket CloudTrail logs to is not publicly accessible ▷Ensure CloudTrail trails are integrated with CloudWatch Logs ▷Ensure VPC flow logging is enabled in all VPCs [1] [1] http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/flow-logs.html
  • 28. Logging $ aws cloudtrail describe-trails --query "trailList[].IsMultiRegionTrail" --output text True $ aws cloudtrail create-trail --name <trail_name> --bucket-name <s3_bucket_for_cloudtrail> --is-multi-region-trail $ aws cloudtrail update-trail --name <trail_name> --is-multi-region-trail $ aws cloudtrail describe-trails --query "trailList[].LogFileValidationEnabled” --output text True $ aws cloudtrail update-trail --name <trail_name> --enable-log-file-validation $ aws cloudtrail describe-trails --query 'trailList[*].S3BucketName' --output text $ aws s3api get-bucket-acl --bucket <bucket_name> |grep URI |grep AllUsers $ aws cloudtrail describe-trails --query "trailList[].CloudWatchLogsLogGroupArn" --output text $ aws cloudtrail get-trail-status --name <trail_name> $ aws ec2 describe-flow-logs --query FlowLogs[].FlowLogId --output text $ aws ec2 describe-flow-logs --query FlowLogs[].ResourceId --output text $ aws ec2 describe-flow-logs --filter "Name=resource-id,Values=<vpc>" |grep FlowLogStatus
  • 29. Log and Key Management ▷Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket ▷Adjust log retention according to requirements [1] ▷Ensure AWS Config is enabled in all regions ▷Consider encrypting CloudTrail logs at rest using KMS and ensure keys are rotated [2] [1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/SettingLogRetention.html [2] https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html
  • 30. Log and Key Management $ aws s3api get-bucket-logging --bucket <s3_bucket_for_cloudtrail> $ aws configservice describe-configuration-recorders $ aws cloudtrail describe-trails |grep KmsKeyId $ aws cloudtrail update-trail --name <trail_name> --kms-id <cloudtrail_kms_key> aws kms put-key-policy --key-id <cloudtrail_kms_key> --policy <cloudtrail_kms_key_policy> $ aws kms list-keys $ aws kms get-key-rotation-status --key-id <kms_key_id>
  • 31. AWS CLI Security Auditing IAM Monitoring (Logging, Metrics, Alerting)
  • 32. IAM Monitoring ▷Unauthorized API calls ▷Management Console sign-in without MFA ▷Usage of "root" account ▷IAM policy changes ▷AWS Management Console authentication failures ▷Set thresholds accordingly [1] [1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
  • 33. IAM Monitoring – Unauthorised API Calls $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.errorCode = "*UnauthorizedOperation") || ($.errorCode = "AccessDenied*") }” $ aws cloudwatch describe-alarms –-query 'MetricAlarms[?MetricName==`<unauthorized_api_calls_metric>`]' $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <unauthorized_api_calls_metric> --metric-transformations metricName=<unauthorized_api_calls_metric>,metricNamespace='Audit', metricVal ue=1 --filter-pattern '{ ($.errorCode = "*UnauthorizedOperation") || ($.errorCode = "AccessDenied*") }' $ aws sns create-topic --name <sns_topic_name> $ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> -- notification-endpoint <sns_subscription_endpoints> $ aws cloudwatch put-metric-alarm --alarm-name <unauthorized_api_calls_alarm> --metric-name <unauthorized_api_calls_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 34. IAM Monitoring – Login Without MFA $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = "ConsoleLogin") && ($.additionalEventData.MFAUsed != "Yes") }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<no_mfa_console_signin_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <no_mfa_console_signin_metric> --metric-transformations metricName=<no_mfa_console_signin_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = "ConsoleLogin") && ($.additionalEventData.MFAUsed != "Yes") }’ $ aws sns create-topic --name <sns_topic_name> $ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> -- notification-endpoint <sns_subscription_endpoints> $ aws cloudwatch put-metric-alarm --alarm-name <no_mfa_console_signin_alarm> --metric-name <no_mfa_console_signin_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 35. IAM Monitoring – “root” Account Usage $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ $.userIdentity.type = "Root" && $.userIdentity.invokedBy NOT EXISTS && $.eventType != "AwsServiceEvent" } ” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<root_usage_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <root_usage_metric> --metric-transformations metricName=<root_usage_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ $.userIdentity.type = "Root" && $.userIdentity.invokedBy NOT EXISTS && $.eventType != "AwsServiceEvent" }’ $ aws sns create-topic --name <sns_topic_name> $ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> -- notification-endpoint <sns_subscription_endpoints> $ aws cloudwatch put-metric-alarm --alarm-name <root_usage_alarm> --metric-name <root_usage_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' -- alarm-actions <sns_topic_arn>
  • 36. IAM Monitoring – IAM Policy Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)||($.eventName=Delete UserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)||($.eventName=P utUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy)||($.eventName=Cr eatePolicyVersion)||($.eventName=DeletePolicyVersion)||($.eventName=AttachRolePolicy)| |($.eventName=DetachRolePolicy)||($.eventName=AttachUserPolicy)||($.eventName=DetachUs erPolicy)||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}" $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<iam_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <iam_changes_metric> --metric-transformations metricName=<iam_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy) ||($.eventName=DeleteUserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy) ||($.eventName=PutUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy) ||($.eventName=CreatePolicyVersion)||($.eventName=DeletePolicyVersion) ||($.eventName=AttachRolePolicy)||($.eventName=DetachRolePolicy) ||($.eventName=AttachUserPolicy)||($.eventName=DetachUserPolicy) ||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}'
  • 37. IAM Monitoring – Authentication Failures $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = ConsoleLogin) && ($.errorMessage = "Failed authentication") }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<console_signin_failure_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <console_signin_failure_metric> --metric-transformations metricName=<console_signin_failure_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = ConsoleLogin) && ($.errorMessage = ""Failed authentication"") }’ $ aws sns create-topic --name <sns_topic_name> $ aws sns subscribe --topic-arn <sns_topic_arn> --protocol <protocol_for_sns> -- notification-endpoint <sns_subscription_endpoints> $ aws cloudwatch put-metric-alarm --alarm-name <console_signin_failure_alarm> --metric-name <console_signin_failure_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 38. AWS CLI Security Auditing Config Monitoring (Logging, Metrics, Alerting)
  • 39. CloudTrail, Config, S3, and Key Monitoring ▷CloudTrail configuration changes ▷AWS Config configuration changes ▷S3 bucket policy changes ▷Disabling or scheduled deletion of customer created CMKs ▷Set thresholds accordingly [1] [1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
  • 40. Monitoring – CloudTrail Config Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = CreateTrail) || ($.eventName = UpdateTrail) || ($.eventName = DeleteTrail) || ($.eventName = StartLogging) || ($.eventName = StopLogging) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<cloudtrail_cfg_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <cloudtrail_cfg_changes_metric> --metric-transformations metricName=<cloudtrail_cfg_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = CreateTrail) || ($.eventName = UpdateTrail) || ($.eventName = DeleteTrail) || ($.eventName = StartLogging) || ($.eventName = StopLogging) }' $ aws cloudwatch put-metric-alarm --alarm-name <cloudtrail_cfg_changes_alarm> --metric-name <cloudtrail_cfg_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 41. Monitoring – AWS Config Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{($.eventSource = config.amazonaws.com) && (($.eventName=StopConfigurationRecorder)||($.eventName=DeleteDeliveryChannel) ||($.eventName=PutDeliveryChannel)||($.eventName=PutConfigurationRecorder))}” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<aws_config_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <aws_config_changes_metric> --metric-transformations metricName=<aws_config_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{($.eventSource = config.amazonaws.com) && (($.eventName=StopConfigurationRecorder)||($.eventName=DeleteDeliveryChannel) ||($.even tName=PutDeliveryChannel)||($.eventName=PutConfigurationRecorder))}’ $ aws cloudwatch put-metric-alarm --alarm-name <aws_config_changes_alarm> --metric-name <aws_config_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 42. Monitoring – S3 Bucket Policy Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventSource = s3.amazonaws.com) && (($.eventName = PutBucketAcl) || ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) || ($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) || ($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) || ($.eventName = DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<s3_bucket_policy_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <s3_bucket_policy_changes_metric> --metric-transformations metricName=<s3_bucket_policy_changes_metric>,metricNamespace='Audit',metric Value=1 --filter-pattern '{ ($.eventSource = s3.amazonaws.com) && (($.eventName = PutBucketAcl) || ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) || ($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) || ($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) || ($.eventName = DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }’ $ aws cloudwatch put-metric-alarm --alarm-name <s3_bucket_policy_changes_alarm> --metric-name <s3_bucket_policy_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 43. Monitoring – Customer Created CMKs $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{($.eventSource = kms.amazonaws.com) && (($.eventName=DisableKey)||($.eventName=ScheduleKeyDeletion))} }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<disable_or_delete_cmk_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <disable_or_delete_cmk_metric> --metric-transformations metricName=<disable_or_delete_cmk_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{($.eventSource = kms.amazonaws.com) && (($.eventName=DisableKey)||($.eventName=ScheduleKeyDeletion))}’ $ aws cloudwatch put-metric-alarm --alarm-name <disable_or_delete_cmk_alarm> --metric-name <disable_or_delete_cmk_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 -- namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 44. AWS CLI Security Auditing VPC Monitoring (Logging, Metrics, Alerting)
  • 45. Security Group and VPC Monitoring ▷Security Group changes ▷NACL changes ▷Network Gateway changes ▷Route changes ▷VPC changes ▷SNS subscribers ▷Set thresholds accordingly [1] [1] http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/viewing_metrics_with_cloudwatch.html
  • 46. IAM Monitoring – Security Group Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = AuthorizeSecurityGroupIngress) || ($.eventName = AuthorizeSecurityGroupEgress) || ($.eventName = RevokeSecurityGroupIngress) || ($.eventName = RevokeSecurityGroupEgress) || ($.eventName = CreateSecurityGroup) || ($.eventName = DeleteSecurityGroup)}” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<security_group_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <security_group_changes_metric> --metric-transformations metricName=<security_group_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = AuthorizeSecurityGroupIngress) || ($.eventName = AuthorizeSecurityGroupEgress) || ($.eventName = RevokeSecurityGroupIngress) || ($.eventName = RevokeSecurityGroupEgress) || ($.eventName = CreateSecurityGroup) || ($.eventName = DeleteSecurityGroup)}' $ aws cloudwatch put-metric-alarm --alarm-name <security_group_changes_alarm> --metric-name <security_group_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 47. IAM Monitoring – NACL Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = CreateNetworkAcl) || ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<nacl_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <nacl_changes_metric> --metric-transformations metricName=<nacl_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = CreateNetworkAcl) || ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }’ $ aws cloudwatch put-metric-alarm --alarm-name <nacl_changes_alarm> --metric-name <nacl_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 48. IAM Monitoring – Gateway Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = CreateCustomerGateway) || ($.eventName = DeleteCustomerGateway) || ($.eventName = AttachInternetGateway) || ($.eventName = CreateInternetGateway) || ($.eventName = DeleteInternetGateway) || ($.eventName = DetachInternetGateway) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<network_gw_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <network_gw_changes_metric> --metric-transformations metricName=<network_gw_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = CreateCustomerGateway) || ($.eventName = DeleteCustomerGateway) || ($.eventName = AttachInternetGateway) || ($.eventName = CreateInternetGateway) || ($.eventName = DeleteInternetGateway) || ($.eventName = DetachInternetGateway) }’ $ aws cloudwatch put-metric-alarm --alarm-name <network_gw_changes_alarm> --metric-name <network_gw_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 49. IAM Monitoring – Route Table Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = CreateRoute) || ($.eventName = CreateRouteTable) || ($.eventName = ReplaceRoute) || ($.eventName = ReplaceRouteTableAssociation) || ($.eventName = DeleteRouteTable) || ($.eventName = DeleteRoute) || ($.eventName = DisassociateRouteTable) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<route_table_changes_metric>`]’ $ aws sns list-subscriptions-by-topic --topic-arn <sns_topic_arn> $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <route_table_changes_metric> --metric-transformations metricName=<route_table_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = CreateRoute) || ($.eventName = CreateRouteTable) || ($.eventName = ReplaceRoute) || ($.eventName = ReplaceRouteTableAssociation) || ($.eventName = DeleteRouteTable) || ($.eventName = DeleteRoute) || ($.eventName = DisassociateRouteTable) }’ $ aws cloudwatch put-metric-alarm --alarm-name <route_table_changes_alarm> --metric-name <route_table_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 50. IAM Monitoring – VPC Changes $ aws logs describe-metric-filters --log-group-name <cloudtrail_log_group_name> "filterPattern": "{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }” $ aws cloudwatch describe-alarms --query 'MetricAlarms[?MetricName==`<vpc_changes_metric>`]’ $ aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> --filter-name <vpc_changes_metric> --metric-transformations metricName=<vpc_changes_metric>,metricNamespace='Audit',metricValue=1 --filter-pattern '{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }’ $ aws cloudwatch put-metric-alarm --alarm-name <vpc_changes_alarm> --metric-name <vpc_changes_metric> --statistic Sum --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --evaluation-periods 1 --namespace 'Audit' --alarm-actions <sns_topic_arn>
  • 51. Monitoring – SNS subscribers $ aws sns list-topics $ aws sns list-subscriptions-by-topic --topic-arn <topic_arn>
  • 52. AWS CLI Security Auditing Networking (VPCs and Security Groups)
  • 53. Networking and Security Groups ▷Ensure SSH is not open to the world ▷Ensure RDP is not open to the world ▷Ensure the default security group of every VPC restricts all traffic [1] ▷Ensure routing tables for VPC peering are "least access” [2] [1] http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html [2] http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/peering- configurations-partial-access.html
  • 54. Networking and Security Groups $ aws ec2 describe-security-groups --filters "Name=ip-permission.to-port,Values=22" "Name=ip- permission.cidr,Values=0.0.0.0/0"$ $ aws ec2 describe-security-groups --filters "Name=ip-permission.to-port,Values=3389" "Name=ip- permission.cidr,Values=0.0.0.0/0” $ aws ec2 describe-security-groups --filters Name=group-name,Values='default' --query 'SecurityGroups[].{IpPermissions:IpPermissions,GroupId:GroupId}’ $ aws ec2 describe-security-groups --filters Name=group-name,Values='default' --query 'SecurityGroups[].{IpPermissionsEgress:IpPermissionsEgress ,GroupId:GroupId}’ $ aws ec2 describe-route-tables --query "RouteTables[*].{RouteTableId:RouteTableId, VpcId:VpcId, Routes:Routes, AssociatedSubnets:Associations[*].SubnetId}" |grep GatewayID |grep pcx-
  • 55. Thanks for your patience richard@lateralblast.com.au