terraform.gcp.security.gcp-storage-bucket-not-public-iam-binding.gcp-storage-bucket-not-public-iam-binding

profile photo of semgrepsemgrep
Author
unknown
Download Count*

Ensure that Container Registry repositories are not anonymously or publicly accessible

Run Locally

Run in CI

Defintion

rules:
  - id: gcp-storage-bucket-not-public-iam-binding
    patterns:
      - pattern: resource
      - pattern-inside: |
          resource "google_storage_bucket_iam_binding" "..." {
          ...
          members = [ ..., "allAuthenticatedUsers", ...]
          ...
          }
    message: Ensure that Container Registry repositories are not anonymously or
      publicly accessible
    metadata:
      owasp:
        - A05:2017 - Broken Access Control
        - A01:2021 - Broken Access Control
      cwe:
        - "CWE-284: Improper Access Control"
      category: security
      technology:
        - terraform
        - gcp
      references:
        - https://owasp.org/Top10/A01_2021-Broken_Access_Control
      subcategory:
        - audit
      likelihood: LOW
      impact: LOW
      confidence: LOW
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Improper Authorization
    languages:
      - hcl
    severity: WARNING

Examples

gcp-storage-bucket-not-public-iam-binding.tf

# fail
# ruleid: gcp-storage-bucket-not-public-iam-binding
resource "google_storage_bucket_iam_binding" "fail" {
    bucket = google_storage_bucket.default.name
    role = "roles/storage.admin"
    members = [
    "user:jane@example.com",
    "allAuthenticatedUsers"
    ]
}

# ok: gcp-storage-bucket-not-public-iam-binding
resource "google_storage_bucket_iam_binding" "success" {
    bucket = google_storage_bucket.default.name
    role = "roles/storage.admin"
    members = [
    "user:jane@example.com"
    ]
}