Introduction
Best practices for securing an AWS environment have been well-documented and generally accepted, such as AWS’s guidance. However, organizations may still find it challenging on how to begin applying this guidance to their specific environments.
- Which controls should be applied out-of-the-box vs. customized?
- What pitfalls exist in implementing the various controls or checks?
- How do you prioritize remediation of the “sea of red” violations?
In this blog series, we’ll analyze anonymized data from Netskope customers that include security settings of 650,000 entities from 1,143 AWS accounts across several hundred organizations. We’ll look at the configuration from the perspective of the best practices, see what’s commonly occurring in the real world and:
- Discuss specific risk areas that should be prioritized
- Identify underlying root causes and potential pitfalls
- Focus on practical guidance for applying the Benchmark to your specific environment
This blog post focuses on IAM security controls related to logging. Based on the Netskope dataset analyzed, we will highlight four opportunities to improve security:
- Enable VPC flow logs: 81% of VPCs do not have VPC flow logging enabled, which will hinder incident response and investigations.
- Encrypt CloudTrail logs at rest: 91% of CloudTrail logs are not encrypted at rest. Encryption at rest supports data compliance controls and is easy to do.
- Ensure S3 bucket access logging is enabled for CloudTrail buckets: 41% of CloudTrail buckets do not have server access logging enabled. Logging should be enabled for all CloudTrail S3 buckets.
- Ensure CloudTrail logs are integrated with CloudWatch or a SIEM: 54% of CloudTrails are not integrated with CloudWatch. These should be reviewed to ensure they are integrated with a production log search service or SIEM.
Logging
These nine technical best practices involve logging configuration, including AWS CloudTrail, bucket access logging, and VPC flow logs. They were analyzed against 1,485 CloudTrails, 11,101 VPCs, and 16,281 keys across 1,143 accounts in the Netskope customer dataset.
# | Best Practice | # Violations | % |
---|---|---|---|
1 | Ensure CloudTrail is enabled in all regions | 39 | 3.4 |
2 | Ensure CloudTrail log file validation is enabled | 271 | 18.2 |
3 | Ensure the S3 bucket used to store CloudTrail logs is not publicly accessible | 2 | 0.13 |
4 | Ensure CloudTrail trails are integrated with CloudWatch Logs | 799 | 53.8 |
5 | Ensure AWS Config is enabled in all regions | 104 | 9.1 |
6 | Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket | 610 | 41.1 |
7 | Ensure CloudTrail logs are encrypted at rest using AWS KMS CMKs | 1,358 | 91.4 |
8 | Ensure rotation for customer created CMKs is enabled | 3,338 | 20.5 |
9 | Ensure VPC flow logging is enabled in all VPCs | 9,015 | 81.2 |
1. CloudTrail enabled in all regions
Background: CloudTrail should be enabled for all regions to ensure complete activity logging is available, including activity in unused regions is detected.
Data: In this dataset, 39 accounts (3.4%) do not have a CloudTrail enabled for all regions.
Analysis: This control is crucial as it is a prerequisite for visibility into having logging enabled in the first place in all regions. Any violations should be immediately remediated.
Controls:
- Detection/Audit
- CloudTrail should be enabled for all regions and regular, automated checks on CloudTrail configurations should be done to enforce this setting.
- The CloudTrail configuration setting, IsMultiReegionTrail, can be checked via CLI:
aws cloudtrail describe-trails
- AWS Config has a rule that will also detect if CloudTrail is not enabled for all regions.
- Prevention/Mitigation
- The CloudTrail setting, IsMultiRegionTrail, can be configured via CLI:
aws cloudtrail update-trail
- The CloudTrail setting, IsMultiRegionTrail, can be configured via CLI:
2. CloudTrail log file validation
Background: A digitally-signed hash of each CloudTrail log can be created on the same S3 bucket where the CloudTrail logs are stored. This is invaluable in ensuring the integrity of the logs and determining if a log was changed or deleted after CloudTrail wrote the log. Enable file validation on all logs to provide additional integrity checking of CloudTrail logs.
Data: 271 out of 1,485 CloudTrail logs (18%) do not have file validation enabled.
Analysis: Log file validation is easy to turn on and should be enabled for all CloudTrail logs.
Controls:
- Detection/Audit
- The CloudTrail log file validation setting,
LogFileValidationEnabled
, can be checked via CLI:aws cloudtrail describe-trails
- AWS Config has a rule that will also detect if log file validation is not enabled.
- The CloudTrail log file validation setting,
- Prevention/Mitigation
- To set the CloudTrail setting, LogFileValidationEnabled, use the CLI:
aws cloudtrail update-trail
- One can also validate log files for a specified period of time, on demand with this CLI command:
aws cloudtrail validate-logs
- To set the CloudTrail setting, LogFileValidationEnabled, use the CLI:
3. CloudTrail private bucket
Background: CloudTrail logs are stored in an S3 bucket, which should not be publicly accessible.
Data: In this dataset, two out of 1,485 CloudTrail buckets are public (0.13%).
Analysis: There is only a very small percentage of CloudTrail buckets that are public. However, remediating the two public buckets is critical as the CloudTrail logs are at risk of being readable or possibly writable publicly, which leaks sensitive information and puts log integrity at risk.
Controls:
- Detection/Audit
- The CloudTrail bucket’s public settings can be checked via CLI:
aws s3api get-public-access-block
aws s3api get-bucket-policy
aws s3api get-bucket-acl - AWS Config also has 3 rules that can detect buckets with public access:
- The CloudTrail bucket’s public settings can be checked via CLI:
- Prevention/Mitigation
- To mitigate a public CloudTrail bucket, apply the Public Access Block, which will ensure that the bucket is not only private but will prevent it from accidentally being changed to public by blocking modification of the bucket policies or ACLs.
- The Console and CLI provide easy ways to set the Public Access Block setting:
aws s3api put-public-access-block
4. CloudTrail integrated with CloudWatch
Background: To provide better searching, metrics, and monitoring alerts, CloudTrail should be integrated with CloudWatch or a product such as a SIEM.
Data: 799 out 1,485 CloudTrails (53.8%) are not integrated with CloudWatch.
Analysis: About half of the CloudTrails are not integrated with CloudWatch. If CloudWatch is the standard service used for metrics and alarms, then these CloudTrails should be remediated immediately. If an alternative product, such a SIEM, is the standard, then there are mitigating controls, and this control can be deprioritized.
Controls:
- Detection/Audit
- CloudWatch configuration for CloudTrails can be checked via CLI:
aws cloudtrail describe-trails
- AWS Config has a rule to check for CloudTrail configuration with CloudWatch.
- CloudWatch configuration for CloudTrails can be checked via CLI:
- Prevention/Mitigation
- To configure CloudTrail to integrate with CloudWatch log groups, use the CLI:
aws cloudtrail update-trail
- To configure CloudTrail to integrate with CloudWatch log groups, use the CLI:
5. AWS Config enabled in all regions
Background: AWS Config can detect common misconfigurations and also is the basis of AWS compliance findings in AWS SecurityHub. It should be enabled in all regions.
Data: 104 out of 1,143 accounts (9.1%) do not have AWS Config enabled for all regions.
Analysis: AWS Config should be enabled for all regions in every account.
Controls:
- Detection/Audit