OSS bucket policy contains wildcards in actions and principals

Restrict wildcard grants in OSS bucket policies to the principals, actions, and resources needed to prevent unintended data access and changes.

Description

In an OSS bucket policy, an empty Principal list is equivalent to ["*"]. Without a condition, the wildcard covers every identity except the bucket owner. A condition can bring the owner into scope.

Potential impact

oss:* can cover reads, writes, deletes and administration. oss:Get* covers only actions starting with Get. Conditions, explicit denies, ACLs and Block Public Access determine which requests succeed.

Remediation

Name the principals, actions and paths that need access. A private ACL can still coexist with a broad policy grant. Verify that intended requests succeed and other requests are denied.

Examples

The excerpts use legacy inline policy. For new configurations, use alicloud_oss_bucket_policy and match the resource paths to your bucket name. Recheck access after migration.

Broad action grant

hcl
resource "alicloud_oss_bucket" "bucket-policy1" {
  bucket = "bucket-1-policy"
  acl    = "private"

  policy = <<POLICY
  {"Statement": [
    {
        "Action": [
            "oss:*"
        ],
        "Effect": "Allow",
        "Principal": [
            "*"
        ],
        "Resource": [
            "acs:oss:*:*:bucket-1-policy",
            "acs:oss:*:*:bucket-1-policy/*"
        ]
    }
  ],
   "Version":"1"}
  POLICY
}

Broad explicit deny

hcl
resource "alicloud_oss_bucket" "bucket-policy1" {
  bucket = "bucket-1-policy"
  acl    = "private"

  policy = <<POLICY
  {"Statement": [
    {
        "Action": [
            "oss:*"
        ],
        "Effect": "Deny",
        "Principal": [
            "*"
        ],
        "Resource": [
            "acs:oss:*:*:bucket-1-policy",
            "acs:oss:*:*:bucket-1-policy/*"
        ]
    }
  ],
   "Version":"1"}
  POLICY
}

The unconditional Deny blocks approved nonowner users too. Remove or narrow the broad grant, or scope the denial so those users can still perform their required operations.

References