TMA-GCP-BIGQUERY-DATASETS-NOT-PUBLIC
Ensure BigQuery datasets are not anonymously or publicly accessible
Descrição
Granting allUsers or allAuthenticatedUsers on a dataset exposes its tables to anyone. No dataset ACL in the active project may reference those principals. Uses the bq tool from the Cloud SDK. Read-only gcloud calls against the active project (gcloud config set project, or CLOUDSDK_CORE_PROJECT); credentials come from the SDK's normal configuration (gcloud auth login, a service account or ADC). A missing CLI, credential or disabled API fails the check.
Como é verificado
Método de auditoria: Comando shell
ds=$(bq --headless ls -n 10000 --format=json 2>/dev/null) || exit 1
ids=$(printf '%s\n' "$ds" | grep -o '"datasetId": *"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/')
bad=0
for d in $ids; do
acl=$(bq --headless show --format=json "$d" 2>/dev/null) || exit 1
if printf '%s\n' "$acl" | grep -Eq '"(allUsers|allAuthenticatedUsers)"'; then echo "public: $d"; bad=1; fi
done
[ "$bad" -eq 0 ] && echo compliant- Saída esperada
compliant
Como é corrigido
Método de correção: Orientação ou patch de infraestrutura
Remove allUsers / allAuthenticatedUsers entries from the dataset access list (bq show --format=prettyjson <ds> > acl.json, edit, bq update --source acl.json <ds>), and enforce domain-restricted sharing (constraints/iam.allowedPolicyMemberDomains).
Propriedades
- Sistemas operacionais
- Qualquer
- Tags
- gcpbigquery
- Referência
- CIS Google Cloud Platform Foundation Benchmark v5.0.0 - BigQuery - datasets not publicly accessible (verify section number for your release)
Verificar este host
Execute isto em uma máquina que você tenha permissão para auditar. A varredura é somente leitura.
tmaegis scan --target gcp