---
title: S3 bucket with public access
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > S3 bucket with public access
---

# S3 bucket with public access

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `c3e073c1-f65e-4d18-bd67-4a8f20ad1ab9`

**Cloud Provider:** AWS

**Platform:** Ansible

**Severity:** Critical

**Category:** Access Control

#### Learn More{% #learn-more %}

- [Provider Reference](https://docs.ansible.com/ansible/latest/collections/amazon/aws/s3_object_module.html#parameter-permission)

### Description{% #description %}

Ansible tasks that set S3 `permission` to `public` create publicly accessible buckets or objects, risking data exposure and regulatory non‑compliance. For the `amazon.aws.s3_object` and `s3_object` modules, the `permission` property must be defined and must not contain the value `public`. Use `private` or other restricted values (for example, `authenticated-read`) as appropriate.

This rule flags tasks where `permission` contains `public`. Tasks missing an explicit `permission` should be reviewed and set to a non‑public value.

Secure example:

```yaml
- name: Create private S3 bucket
  amazon.aws.s3_object:
    bucket: my-bucket
    permission: private
    mode: create
```

## Compliant Code Examples{% #compliant-code-examples %}

```yaml
- name: Create an empty bucket
  amazon.aws.s3_object:
    bucket: mybucket
    mode: create
    permission: private
- name: Create an empty bucket 02
  amazon.aws.s3_object:
    bucket: mybucket
    mode: create
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```yaml
---
- name: Create an empty bucket
  amazon.aws.s3_object:
    bucket: mybucket
    mode: create
    permission: public-read
- name: Create an empty bucket 01
  amazon.aws.s3_object:
    bucket: mybucket 01
    mode: create
    permission: public-read-write
```
