Ce produit n'est pas pris en charge par le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Metadata

Id: ansible-aws-s3-bucket-with-all-permissions

Provider: AWS

Platform: Ansible

Severity: Critical

Category: Access Control

Learn More

Description

S3 bucket policies must not grant all actions to all principals. A statement that sets Effect=Allow with both Action=* and Principal=* effectively makes the bucket publicly accessible and can enable data exfiltration or unauthorized modification/deletion.

For Ansible resources using the amazon.aws.s3_bucket or s3_bucket modules, inspect the resource policy document’s Statement entries. Any statement where Effect is Allow and both Action and Principal contain the wildcard * (including arrays that include *) is flagged.

Restrict Principal to explicit ARNs, account IDs, or service principals and scope Action to the minimum required permissions following least privilege.

Secure example policy statement:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::123456789012:root" },
      "Action": [ "s3:GetObject" ],
      "Resource": "arn:aws:s3:::example-bucket/*"
    }
  ]
}

Compliant Code Examples

- name: Create s3 bucket
  amazon.aws.s3_bucket:
    name: mys3bucket
    policy:
      Id: id113
      Version: '2012-10-17'
      Statement:
      - Action: s3:put
        Effect: Allow
        Resource: arn:aws:s3:::S3B_181355/*
        Principal: '*'
    requester_pays: yes
    versioning: yes

Non-Compliant Code Examples

---
- name: Create s3 bucket
  amazon.aws.s3_bucket:
    name: mys3bucket
    policy:
      Id: "id113"
      Version: "2012-10-17"
      Statement:
      - Action: "s3:*"
        Effect: "Allow"
        Resource: "arn:aws:s3:::S3B_181355/*"
        Principal: "*"
    requester_pays: yes
    versioning: yes