> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# S3 Bucket Should Not Allow Public READ_ACP Access

### More Info:

AWS S3 buckets should not allow public READ\_ACP access. Granting public “READ\_ACP” access to your S3 buckets can allow everyone on the Internet to see who controls your objects. Malicious users can use this information to find S3 objects with misconfigured permissions and implement probing techniques to help them gain access to your S3 data.

### Risk Level

Medium

### Address

Security

### Compliance Standards

* APRA CPS 234 (Australia)
* AWS Startup Security Baseline
* BSI C5 (Germany)
* Brazil LGPD
* CCPA / CPRA (California)
* CIS Critical Security Controls v8
* CMMC 2.0
* CSA Cloud Controls Matrix v4
* DPDPA
* Digital Operational Resilience Act (EU)
* Essential 8
* ISO/IEC 27017
* ISO/IEC 27018
* ISO/IEC 27701
* KSA PDPL
* MAS Technology Risk Management (Singapore)
* MITRE ATT\&CK (Cloud)
* NIS2 Directive
* NIST
* NIST SP 800-171
* NYDFS 23 NYCRR 500
* PCI
* SWIFT Customer Security Controls Framework
* Sarbanes-Oxley IT General Controls
* UK NCSC Cyber Assessment Framework

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        Sure, here are the step by step instructions to remediate the misconfiguration "S3 Bucket Should Not Allow Public READ\_ACP Access" for AWS using AWS console:

        1. Log in to your AWS console.
        2. Navigate to the S3 service.
        3. Select the S3 bucket that you want to remediate.
        4. Click on the "Permissions" tab.
        5. Scroll down to the "Access control list (ACL)" section.
        6. Click on the "Edit" button next to the "Public access" option.
        7. Uncheck the "List objects" checkbox under the "Access for Everyone" section.
        8. Click on the "Save" button to save the changes.

        By following the above steps, you have successfully remediated the misconfiguration "S3 Bucket Should Not Allow Public READ\_ACP Access" for AWS using AWS console.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the misconfiguration "S3 Bucket Should Not Allow Public READ\_ACP Access" in AWS using AWS CLI, follow the below steps:

        Step 1: Open the AWS CLI on your local machine or EC2 instance.

        Step 2: Run the following command to list all the S3 buckets in your AWS account.

        ```
        aws s3api list-buckets
        ```

        Step 3: Identify the bucket that has public READ\_ACP access and note down the bucket name.

        Step 4: Run the following command to remove the public READ\_ACP access from the identified S3 bucket.

        ```
        aws s3api put-bucket-acl --bucket <bucket-name> --acl private
        ```

        Replace `<bucket-name>` with the name of the identified S3 bucket.

        Step 5: Verify that the public READ\_ACP access has been removed from the S3 bucket by running the following command.

        ```
        aws s3api get-bucket-acl --bucket <bucket-name>
        ```

        This command will return the access control list (ACL) of the S3 bucket. Ensure that there are no grants with the permission "READ\_ACP" for "AllUsers" or "AuthenticatedUsers".

        By following the above steps, you can remediate the misconfiguration "S3 Bucket Should Not Allow Public READ\_ACP Access" in AWS using AWS CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the S3 Bucket should not allow public READ\_ACP access issue in AWS, you can follow the below steps using Python:

        1. Import the required AWS SDKs and libraries in your Python script.

        ```python theme={null}
        import boto3
        from botocore.exceptions import ClientError
        ```

        2. Initialize the S3 client using the AWS SDK for Python (Boto3) and provide the necessary AWS credentials.

        ```python theme={null}
        s3 = boto3.client('s3',
            aws_access_key_id='<your_access_key_id>',
            aws_secret_access_key='<your_secret_access_key>'
        )
        ```

        3. Iterate over all the S3 buckets in your AWS account and check if any of them have public READ\_ACP access.

        ```python theme={null}
        buckets = s3.list_buckets()['Buckets']

        for bucket in buckets:
            try:
                acl = s3.get_bucket_acl(Bucket=bucket['Name'])
                grants = acl['Grants']
                
                for grant in grants:
                    if 'URI' in grant['Grantee'] and grant['Permission'] == 'READ_ACP':
                        print(f"Bucket {bucket['Name']} has public READ_ACP access.")
                        # remediation steps go here
                        break
            except ClientError as e:
                print(f"Error getting ACL for bucket {bucket['Name']}: {e}")
        ```

        4. If any S3 bucket has public READ\_ACP access, update its bucket policy to deny public READ\_ACP access.

        ```python theme={null}
        bucket_policy = {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Deny",
                    "Principal": "*",
                    "Action": "s3:GetObjectAcl",
                    "Resource": f"arn:aws:s3:::{bucket['Name']}/*",
                    "Condition": {
                        "StringEquals": {
                            "s3:x-amz-acl": "public-read"
                        }
                    }
                }
            ]
        }

        s3.put_bucket_policy(Bucket=bucket['Name'], Policy=json.dumps(bucket_policy))
        ```

        This will update the bucket policy for the S3 bucket to deny public READ\_ACP access.
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "aws_s3_bucket" "TARGET_BUCKET" {
          bucket = "REPLACE_WITH_BUCKET_NAME"
        }

        # Enable S3 Block Public Access on the bucket (prevents public READ_ACP via ACLs)
        resource "aws_s3_bucket_public_access_block" "TARGET_BUCKET_block" {
          bucket = aws_s3_bucket.TARGET_BUCKET.id

          block_public_acls       = true
          ignore_public_acls      = true
          block_public_policy     = true
          restrict_public_buckets = true
        }
        ```

        Substitute:

        * `REPLACE_WITH_BUCKET_NAME` with the actual bucket name.
        * `TARGET_BUCKET` with your resource name if different.

        This change does not force bucket replacement, but it may break workloads that depend on public access; review before applying.

        Verification: `terraform plan` should show creating or updating `aws_s3_bucket_public_access_block.TARGET_BUCKET_block` with all four attributes set to `true`.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

### Additional Reading:

* [https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-overview.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-overview.html)
