Alicloud OSS bucket configured as a static website

Review the purpose and effective read permissions of an OSS static website to prevent exposure of internal files.

Description

Use OSS static website hosting for content you intend to publish. Keep internal logs, backups and configuration files in a separate bucket.

Potential impact

A website block selects index and error pages. Anonymous access depends on bucket and object ACLs, bucket policies and Block Public Access.

Remediation

Remove website from internal buckets. On a public site, grant anonymous read access only to published objects and reserve writes and deletes for deployment identities. Without signing in, use the website endpoint to check that a public file loads and a private file is denied.

Examples

The examples use different buckets. Keep the bucket name and Terraform resource address when updating an existing bucket.

Website configuration

hcl
resource "alicloud_oss_bucket" "website_bucket" {
  bucket = "bucket-1-website"

  website {
    index_document = "index.html"
    error_document = "error.html"
  }
}

Configuration for private use

hcl
resource "alicloud_oss_bucket" "private_bucket" {
  bucket = "bucket-1-acl"
  acl    = "private"
}

References