metadata:
  id: 15c6f217-2ae2-5bb4-8ebe-f40adf02910d
  name: Ensure that Object-level logging for read events is enabled for S3 bucket
  profile_applicability: '* Level 2'
  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.
  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.
  audit: |-
    **From Console:**

    1. Login to the AWS Management Console and navigate to S3 dashboard at `https://console.aws.amazon.com/s3/`
    2. In the left navigation panel, click `buckets` and then click on the S3 Bucket Name that you want to examine.
    3. Click `Properties` tab to see in detail bucket configuration.
    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.
    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.
    6. Repeat steps 2 to 5 to verify `object-level` logging for `read` events of your other S3 buckets.

    **From Command Line:**
    7. Run `describe-trails` command to list the names of all Amazon CloudTrail trails currently available in the selected AWS region:
    ```
    aws cloudtrail describe-trails --region <region-name> --output table --query trailList[*].Name
    ```
    8. The command output will be table of the requested trail names.
    9. 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:
    ```
    aws cloudtrail get-event-selectors --region <region-name> --trail-name <trail-name> --query EventSelectors[*].DataResources[]
    ```
    10. The command output should be an array that contains the configuration of the AWS resource(S3 bucket) defined for the Data events selector.
    11. 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.
    12. Repeat steps 1 to 5 for auditing each s3 bucket to identify other trails that are missing the capability to log Data events.
    13. Change the AWS region by updating the `--region` command parameter and perform the audit process for other regions.
  remediation: |-
    **From Console:**

    1. Login to the AWS Management Console and navigate to S3 dashboard at `https://console.aws.amazon.com/s3/`
    2. In the left navigation panel, click `buckets` and then click on the S3 Bucket Name that you want to examine.
    3. Click `Properties` tab to see in detail bucket configuration.
    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/`
    5. Once the Cloudtrail is selected, check the Read event checkbox, so that `object-level` logging for `Read` events is enabled.
    6. Repeat steps 2 to 5 to enable `object-level` logging of read events for other S3 buckets.

    **From Command Line:**
    7. 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:
    ```
    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>/"
                ]
            }
        ]
    }]'
    ```
    8. The command output will be `object-level` event trail configuration.
    9. If you want to enable it for all buckets at ones then change Values parameter to `["arn:aws:s3"]` in command given above.
    10. Repeat step 1 for each s3 bucket to update `object-level` logging of read events.
    11. Change the AWS region by updating the `--region` command parameter and perform the process for other regions.
  impact: ''
  default_value: ''
  references: 1. 
    https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-cloudtrail-events.html
  section: Logging
  version: '1.0'
  tags:
  - CIS
  - AWS
  - CIS 3.11
  - Logging
  benchmark:
    name: CIS Amazon Web Services Foundations
    version: v1.5.0
    id: cis_aws
    rule_number: '3.11'
    posture_type: cspm
