Skip to content

Commit ec51380

Browse files
authored
Merge pull request #103 from cloudgraphdev/feature/CG-1281-aws-support-logging-rules
Feature/cg 1281 aws support logging rules
2 parents 2c97cc2 + 3fc531b commit ec51380

14 files changed

Lines changed: 1739 additions & 0 deletions

src/aws/cis-1.5.0/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ Policy Pack based on the [AWS Foundations 1.5.0](https://drive.google.com/file/d
7878
| AWS CIS 1.19 | Ensure that all the expired SSL/TLS certificates stored in AWS IAM are removed |
7979
| AWS CIS 1.20 | Ensure that IAM Access analyzer is enabled for all regions |
8080
| AWS CIS 1.21 | Ensure IAM users are managed centrally via identity federation or AWS Organizations for multi-account environments |
81+
| AWS CIS 3.1 | Ensure CloudTrail is enabled in all regions |
82+
| AWS CIS 3.2 | Ensure CloudTrail log file validation is enabled |
83+
| AWS CIS 3.3 | Ensure the S3 bucket used to store CloudTrail logs is not publicly accessible |
84+
| AWS CIS 3.4 | Ensure CloudTrail trails are integrated with CloudWatch Logs |
85+
| AWS CIS 3.5 | Ensure AWS Config is enabled in all regions |
86+
| AWS CIS 3.6 | Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket |
87+
| AWS CIS 3.7 | Ensure CloudTrail logs are encrypted at rest using KMS CMKs |
88+
| AWS CIS 3.8 | Ensure rotation for customer created CMKs is enabled |
89+
| AWS CIS 3.9 | Ensure VPC flow logging is enabled in all VPCs |
90+
| AWS CIS 3.10 | Ensure that Object-level logging for write events is enabled for S3 bucket |
91+
| AWS CIS 3.11 | Ensure that Object-level logging for read events is enabled for S3 bucket |
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// AWS CIS 1.4.0 Rule equivalent 3.1
2+
export default {
3+
id: 'aws-cis-1.5.0-3.1',
4+
title: 'AWS CIS 3.1 Ensure CloudTrail is enabled in all regions',
5+
description: `AWS CloudTrail is a web service that records AWS API calls for your account and delivers
6+
log files to you. The recorded information includes the identity of the API caller, the time of
7+
the API call, the source IP address of the API caller, the request parameters, and the
8+
response elements returned by the AWS service. CloudTrail provides a history of AWS API
9+
calls for an account, including API calls made via the Management Console, SDKs, command
10+
line tools, and higher-level AWS services (such as CloudFormation).`,
11+
audit: `Perform the following to determine if CloudTrail is enabled for all regions:
12+
Via the management Console
13+
14+
1. Sign in to the AWS Management Console and open the CloudTrail console at https://console.aws.amazon.com/cloudtrail
15+
2. Click on *Trails* on the left navigation pane
16+
17+
- You will be presented with a list of trails across all regions
18+
19+
3. Ensure at least one Trail has *All* specified in the *Region* column
20+
4. Click on a trail via the link in the *Name* column
21+
5. Ensure *Logging* is set to *ON*
22+
6. Ensure *Apply trail to all regions* is set to *Yes*
23+
7. In section *Management Events* ensure *Read/Write Events* set to *ALL*
24+
25+
Via CLI
26+
27+
aws cloudtrail describe-trails
28+
29+
Ensure *IsMultiRegionTrail* is set to *true*
30+
31+
aws cloudtrail get-trail-status --name <trailname shown in describe-trails>
32+
33+
Ensure *IsLogging* is set to *true*
34+
35+
aws cloudtrail get-event-selectors --trail-name <trailname shown in describe-trails>
36+
37+
Ensure there is at least one Event Selector for a Trail with *IncludeManagementEvents* set to *true* and *ReadWriteType* set to *All*`,
38+
rationale: `The AWS API call history produced by CloudTrail enables security analysis, resource change tracking, and compliance auditing. Additionally,
39+
40+
- ensuring that a multi-regions trail exists will ensure that unexpected activity occurring in otherwise unused regions is detected
41+
- ensuring that a multi-regions trail exists will ensure that Global Service Logging is enabled for a trail by default to capture recording of events generated on AWS global services
42+
- for a multi-regions trail, ensuring that management events configured for all type of Read/Writes ensures recording of management operations that are performed on all resources in an AWS account`,
43+
remediation: `Perform the following to enable global (Multi-region) CloudTrail logging:
44+
Via the management Console
45+
46+
1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/cloudtrail
47+
2. Click on *Trails* on the left navigation pane
48+
3. Click *Get Started Now*, if presented
49+
50+
51+
- Click *Add new trail*
52+
- Enter a trail name in the *Trail* name box
53+
- Set the *Apply trail to all regions* option to Yes
54+
- Specify an S3 bucket name in the *S3 bucket* box
55+
- Click *Create*
56+
57+
4. If 1 or more trails already exist, select the target trail to enable for global logging
58+
5. Click the edit icon (pencil) next to *Apply trail to all regions* , Click *Yes* and Click *Save*.
59+
6. Click the edit icon (pencil) next to *Management Events* click All for setting Read/Write Events and Click *Save*.
60+
61+
Via CLI
62+
63+
aws cloudtrail create-trail --name <trail_name> --bucket-name <s3_bucket_for_cloudtrail> --is-multi-region-trail
64+
aws cloudtrail update-trail --name <trail_name> --is-multi-region-trail
65+
66+
Note: Creating CloudTrail via CLI without providing any overriding options configures *Management Events* to set *All* type of *Read/Writes* by default.`,
67+
references: [
68+
'CCE-78913-1',
69+
'https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-concepts.html#cloudtrail-concepts-management-events',
70+
'https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-and-data-events-with-cloudtrail.html?icmpid=docs_cloudtrail_console#logging-management-events',
71+
'https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-supported-services.html#cloud-trail-supported-services-data-events',
72+
],
73+
gql: `{
74+
queryawsAccount {
75+
id
76+
__typename
77+
cloudtrail {
78+
isMultiRegionTrail
79+
status {
80+
isLogging
81+
}
82+
eventSelectors {
83+
readWriteType
84+
includeManagementEvents
85+
}
86+
}
87+
}
88+
}`,
89+
resource: 'queryawsAccount[*]',
90+
severity: 'medium',
91+
conditions: {
92+
path: '@.cloudtrail',
93+
array_any: {
94+
and: [
95+
{
96+
path: '[*].isMultiRegionTrail',
97+
equal: 'Yes',
98+
},
99+
{
100+
path: '[*].status.isLogging',
101+
equal: true,
102+
},
103+
{
104+
path: '[*].eventSelectors',
105+
array_any: {
106+
and: [
107+
{ path: '[*].readWriteType', equal: 'All' },
108+
{
109+
path: '[*].includeManagementEvents',
110+
equal: true,
111+
},
112+
],
113+
},
114+
},
115+
],
116+
},
117+
},
118+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// AWS CIS 1.4.0 Rule equivalent 3.10
2+
export default {
3+
id: 'aws-cis-1.5.0-3.10',
4+
title: 'AWS CIS 3.10 Ensure that Object-level logging for write events is enabled for S3 bucket',
5+
6+
description: 'S3 object-level API operations such as GetObject, DeleteObject, and PutObject are called data events. By default, CloudTrail trails don\'t log data events and so it is recommended to enable Object-level logging for S3 buckets.',
7+
8+
audit: `**From Console:**
9+
10+
1. Login to the AWS Management Console and navigate to S3 dashboard at https://console.aws.amazon.com/s3/
11+
2. In the left navigation panel, click *buckets* and then click on the S3 Bucket Name that you want to examine.
12+
3. Click *Properties* tab to see in detail bucket configuration.
13+
4. If the current status for *Object-level* logging is set to Disabled, then object-level logging of write events for the selected s3 bucket is not set.
14+
5. Repeat steps 2 to 4 to verify object level logging status of other S3 buckets.
15+
16+
**From Command Line:**
17+
18+
1. Run *list-trails* command to list the names of all Amazon CloudTrail trails currently available in the selected AWS region:
19+
20+
aws cloudtrail list-trails --region <region-name> --query Trails[*].Name
21+
22+
2. The command output will be a list of the requested trail names.
23+
3. Run *get-event-selectors* command using the name of the trail returned at the previous step and custom query filters to determine if Data events logging feature is enabled within the selected CloudTrail trail configuration for s3bucket resources:
24+
25+
aws cloudtrail get-event-selectors --region <region-name> --trail-name <trail-name> --query EventSelectors[*].DataResources[]
26+
27+
4. The command output should be an array that contains the configuration of the AWS resource(S3 bucket) defined for the Data events selector.
28+
5. If the *get-event-selectors* command returns an empty array '[]', the Data events are not included into the selected AWS Cloudtrail trail logging configuration, therefore the S3 object-level API operations performed within your AWS account are not recorded.
29+
6. Repeat steps 1 to 5 for auditing each s3 bucket to identify other trails that are missing the capability to log Data events.
30+
7. Change the AWS region by updating the *--region* command parameter and perform the audit process for other regions.`,
31+
32+
rationale: 'Enabling object-level logging will help you meet data compliance requirements within your organization, perform comprehensive security analysis, monitor specific patterns of user behavior in your AWS account or take immediate actions on any object-level API activity within your S3 Buckets using Amazon CloudWatch Events.',
33+
34+
remediation: `**From Console:**
35+
36+
1. Login to the AWS Management Console and navigate to S3 dashboard at https://console.aws.amazon.com/s3/
37+
2. In the left navigation panel, click *buckets* and then click on the S3 Bucket Name that you want to examine.
38+
3. Click *Properties* tab to see in detail bucket configuration.
39+
4. Click on the *Object-level* logging setting, enter the CloudTrail name for the recording activity. You can choose an existing Cloudtrail or create a new one by navigating to the Cloudtrail console link https://console.aws.amazon.com/cloudtrail/
40+
5. Once the Cloudtrail is selected, check the *Write* event checkbox, so that *object-level* logging for Write events is enabled.
41+
6. Repeat steps 2 to 5 to enable object-level logging of write events for other S3 buckets.
42+
43+
**From Command Line:**
44+
45+
1. To enable *object-level* data events logging for S3 buckets within your AWS account, run *put-event-selectors* command using the name of the trail that you want to reconfigure as identifier:
46+
47+
aws cloudtrail put-event-selectors --region <region-name> --trail-name <trail-name> --event-selectors '[{ "ReadWriteType": "WriteOnly", "IncludeManagementEvents":true, "DataResources": [{ "Type": "AWS::S3::Object", "Values": ["arn:aws:s3:::<s3-bucket-name>/"] }] }]'
48+
49+
2. The command output will be *object-level* event trail configuration.
50+
3. If you want to enable it for all buckets at once then change Values parameter to *["arn:aws:s3"]* in command given above.
51+
4. Repeat step 1 for each s3 bucket to update *object-level* logging of write events.
52+
5. Change the AWS region by updating the *--region* command parameter and perform the process for other regions.`,
53+
54+
references: ['https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-cloudtrail-events.html'],
55+
gql: `{
56+
queryawsAccount {
57+
id
58+
__typename
59+
cloudtrail {
60+
eventSelectors {
61+
includeManagementEvents
62+
readWriteType
63+
dataResources {
64+
type
65+
}
66+
}
67+
}
68+
}
69+
}`,
70+
resource: 'queryawsAccount[*]',
71+
severity: 'high',
72+
conditions: {
73+
path: '@.cloudtrail',
74+
array_any: {
75+
path: '[*].eventSelectors',
76+
array_any: {
77+
and: [
78+
{
79+
path: '[*].includeManagementEvents',
80+
equal: true,
81+
},
82+
{
83+
path: '[*].readWriteType',
84+
in: ['WriteOnly', 'All'],
85+
},
86+
{
87+
path: '[*].dataResources',
88+
array_any: {
89+
path: '[*].type',
90+
equal: 'AWS::S3::Object',
91+
},
92+
},
93+
],
94+
},
95+
}
96+
},
97+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// AWS CIS 1.4.0 Rule equivalent 3.11
2+
export default {
3+
id: 'aws-cis-1.5.0-3.11',
4+
title: 'AWS CIS 3.11 Ensure that Object-level logging for read events is enabled for S3 bucket',
5+
6+
description: 'S3 object-level API operations such as GetObject, DeleteObject, and PutObject are called data events. By default, CloudTrail trails don\'t log data events and so it is recommended to enable Object-level logging for S3 buckets.',
7+
8+
audit: `**From Console:**
9+
10+
1. Login to the AWS Management Console and navigate to S3 dashboard at https://console.aws.amazon.com/s3/
11+
2. In the left navigation panel, click buckets and then click on the S3 Bucket Name that you want to examine.
12+
3. Click *Properties* tab to see in detail bucket configuration.
13+
4. If the current status for *Object-level* logging is set to *Disabled*, then object-level logging of read events for the selected s3 bucket is not set.
14+
5. If the current status for *Object-level* logging is set to *Enabled*, but the Read event check-box is unchecked, then object-level logging of read events for the selected s3 bucket is not set.
15+
6. Repeat steps 2 to 5 to verify *object-level* logging for *read* events of your other S3 buckets.
16+
17+
**From Command Line:**
18+
19+
1. Run *describe-trails* command to list the names of all Amazon CloudTrail trails currently available in the selected AWS region:
20+
21+
aws cloudtrail describe-trails --region <region-name> --output table --query trailList[*].Name
22+
23+
2. The command output will be table of the requested trail names.
24+
3. Run *get-event-selectors* command using the name of the trail returned at the previous step and custom query filters to determine if Data events logging feature is enabled within the selected CloudTrail trail configuration for s3 bucket resources:
25+
26+
aws cloudtrail get-event-selectors --region <region-name> --trail-name <trail-name> --query EventSelectors[*].DataResources[]
27+
28+
4. The command output should be an array that contains the configuration of the AWS resource(S3 bucket) defined for the Data events selector.
29+
5. If the *get-event-selectors* command returns an empty array, the Data events are not included into the selected AWS Cloudtrail trail logging configuration, therefore the S3 object-level API operations performed within your AWS account are not recorded.
30+
6. Repeat steps 1 to 5 for auditing each s3 bucket to identify other trails that are missing the capability to log Data events.
31+
7. Change the AWS region by updating the *--region* command parameter and perform the audit process for other regions.`,
32+
33+
rationale: 'Enabling object-level logging will help you meet data compliance requirements within your organization, perform comprehensive security analysis, monitor specific patterns of user behavior in your AWS account or take immediate actions on any object-level API activity using Amazon CloudWatch Events.',
34+
35+
remediation: `**From Console:**
36+
37+
1. Login to the AWS Management Console and navigate to S3 dashboard at https://console.aws.amazon.com/s3/
38+
2. In the left navigation panel, click buckets and then click on the S3 Bucket Name that you want to examine.
39+
3. Click *Properties* tab to see in detail bucket configuration.
40+
4. Click on the *Object-level* logging setting, enter the CloudTrail name for the recording activity. You can choose an existing Cloudtrail or create a new one by navigating to the Cloudtrail console link https://console.aws.amazon.com/cloudtrail/
41+
5. Once the Cloudtrail is selected, check the Read event checkbox, so that *object-level* logging for *Read* events is enabled.
42+
6. Repeat steps 2 to 5 to enable *object-level* logging of read events for other S3 buckets.
43+
44+
**From Command Line:**
45+
46+
1. To enable object-level data events logging for S3 buckets within your AWS account, run put-event-selectors command using the name of the trail that you want to reconfigure as identifier:
47+
48+
aws cloudtrail put-event-selectors --region <region-name> --trail-name <trail-name> --event-selectors '[{ "ReadWriteType": "ReadOnly", "IncludeManagementEvents":true, "DataResources": [{ "Type": "AWS::S3::Object", "Values": ["arn:aws:s3:::<s3-bucket-name>/"] }] }]'
49+
50+
2. The command output will be *object-level* event trail configuration.
51+
3. If you want to enable it for all buckets at ones then change Values parameter to *["arn:aws:s3"]* in command given above.
52+
4. Repeat step 1 for each s3 bucket to update *object-level* logging of read events.
53+
5. Change the AWS region by updating the *--region* command parameter and perform the process for other regions.`,
54+
55+
references: ['https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-cloudtrail-events.html'],
56+
gql: `{
57+
queryawsAccount {
58+
id
59+
__typename
60+
cloudtrail {
61+
eventSelectors {
62+
includeManagementEvents
63+
readWriteType
64+
dataResources {
65+
type
66+
}
67+
}
68+
}
69+
}
70+
}`,
71+
resource: 'queryawsAccount[*]',
72+
severity: 'high',
73+
conditions: {
74+
path: '@.cloudtrail',
75+
array_any: {
76+
path: '[*].eventSelectors',
77+
array_any: {
78+
and: [
79+
{
80+
path: '[*].includeManagementEvents',
81+
equal: true,
82+
},
83+
{
84+
path: '[*].readWriteType',
85+
in: ['ReadOnly', 'All'],
86+
},
87+
{
88+
path: '[*].dataResources',
89+
array_any: {
90+
path: '[*].type',
91+
equal: 'AWS::S3::Object',
92+
},
93+
},
94+
],
95+
},
96+
}
97+
},
98+
}

0 commit comments

Comments
 (0)