SecuritySecurity
Part of the Cloud knowledge base — GCP deep dive. Complements DevOps Roadmap.
Tổng quan
Bảo mật Google Cloud được xây trên defense in depth và secure by default. Dữ liệu được mã hóa lúc nghỉ (at rest) và khi truyền (in transit) một cách tự động, IAM chi phối mọi API call, và một tập dịch vụ nhiều lớp cho phép bạn thêm các kiểm soát mạnh hơn ở nơi cần: quản lý khóa (Cloud KMS), secrets (Secret Manager), truy cập app theo ngữ cảnh (Identity-Aware Proxy), dashboard tư thế bảo mật (Security Command Center), bảo vệ edge (Cloud Armor), ranh giới chống rò rỉ dữ liệu (VPC Service Controls), và enforce supply-chain (Binary Authorization).
Trang này tập trung vào lớp bảo vệ dữ liệu và bảo mật workload nằm trên IAM và networking (đã bàn ở các trang trước).
| Mối quan tâm | Dịch vụ GCP | Tương đương AWS |
|---|---|---|
| Quản lý khóa | Cloud KMS / Cloud HSM | AWS KMS / CloudHSM |
| Secrets | Secret Manager | Secrets Manager / SSM Param Store |
| Proxy truy cập app | Identity-Aware Proxy (IAP) | (ALB OIDC / Verified Access) |
| Posture & threat detection | Security Command Center | Security Hub + GuardDuty |
| WAF / DDoS | Cloud Armor | AWS WAF + Shield |
| Data perimeter | VPC Service Controls | (không có tương đương trực tiếp) |
| Cổng image/supply-chain | Binary Authorization | (Signer + admission policies) |
| Quy định/chủ quyền | Assured Workloads | AWS GovCloud / control frameworks |
Kiến thức nền tảng
Mã hóa mặc định at rest và in transit
- At rest: Mọi dữ liệu khách hàng được mã hóa mặc định bằng AES-256, dùng khóa do Google quản lý qua envelope encryption — không cần cấu hình. Dữ liệu được chia chunk; mỗi chunk có data encryption key (DEK) riêng, và DEK được bọc bởi key encryption key (KEK) do KMS trung tâm của Google quản lý.
- In transit: Lưu lượng giữa các data center Google được mã hóa tự động; lưu lượng tới các dịch vụ Google Cloud được bảo vệ bằng TLS. Application Layer Transport Security (ALTS) bảo mật các call service-to-service nội bộ.
Bạn chỉ thêm KMS khi cần kiểm soát khóa (chính sách rotation, cư trú theo vùng, thu hồi, audit).
Cloud KMS — key rings, keys, CMEK, envelope encryption
Cloud KMS là dịch vụ managed để tạo và dùng khóa mật mã.
- Key ring — container theo vùng (hoặc global/multi-region) nhóm các khóa. Location cố định lúc tạo.
- Key (
CryptoKey) — có purpose (symmetric encrypt/decrypt, asymmetric sign, asymmetric decrypt, MAC) và một hay nhiều version. Rotation tạo một primary version mới. - Protection level —
SOFTWARE,HSM(FIPS 140-2 Level 3, qua Cloud HSM), hoặcEXTERNAL(Cloud EKM, khóa do đối tác bên ngoài giữ).
CMEK (Customer-Managed Encryption Keys) thay KEK do Google quản lý bằng một khóa KMS bạn sở hữu cho một dịch vụ (BigQuery, GCS, Compute disk, Pub/Sub, v.v.). Bạn giữ quyền kiểm soát rotation và có thể disable/destroy khóa để làm dữ liệu không đọc được. CSEK (Customer-Supplied) đi xa hơn — bạn cung cấp raw key bytes và Google không bao giờ lưu — nhưng hiếm khi cần.
Envelope encryption là pattern: mã hóa dữ liệu cục bộ bằng DEK, rồi gọi KMS để mã hóa (bọc) DEK đó bằng KEK. Lưu DEK đã bọc cạnh ciphertext; giải mã bằng cách nhờ KMS unwrap DEK. Cách này giữ payload lớn khỏi đường request của KMS trong khi vẫn tập trung kiểm soát khóa.
# Tạo key ring và một symmetric key có rotation
gcloud kms keyrings create app-keyring --location=us-central1
gcloud kms keys create data-key \
--location=us-central1 --keyring=app-keyring \
--purpose=encryption \
--rotation-period=90d --next-rotation-time=$(date -u -d '+90 days' +%Y-%m-%dT%H:%M:%SZ)
# Mã hóa / giải mã một file trực tiếp (payload nhỏ)
gcloud kms encrypt \
--location=us-central1 --keyring=app-keyring --key=data-key \
--plaintext-file=secret.txt --ciphertext-file=secret.enc
gcloud kms decrypt \
--location=us-central1 --keyring=app-keyring --key=data-key \
--ciphertext-file=secret.enc --plaintext-file=-
Secret Manager
Secret Manager lưu API key, mật khẩu, chứng chỉ và các secret khác với versioning, kiểm soát truy cập IAM, audit logging, CMEK tùy chọn, chính sách replication tự động (automatic hoặc user-managed regions), và thông báo rotation qua Pub/Sub.
# Tạo secret và thêm một version
printf 's3cr3t-value' | gcloud secrets create db-password \
--replication-policy=automatic --data-file=-
# Cấp một service account quyền đọc đúng secret này
gcloud secrets add-iam-policy-binding db-password \
--member="serviceAccount:app@PROJECT.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
# Truy cập version mới nhất lúc runtime
gcloud secrets versions access latest --secret=db-password
Cloud Run, GKE và Compute có thể mount secret dưới dạng file hoặc inject vào biến môi trường, nên app không bao giờ nhúng credential.
Identity-Aware Proxy (IAP)
IAP enforce kiểm soát truy cập theo ngữ cảnh trước ứng dụng và VM — mô hình zero-trust nơi truy cập được xác thực và ủy quyền theo từng request thay vì dựa vào vị trí mạng (VPN).
- Đứng trước HTTPS load balancer, App Engine và Cloud Run; cũng đứng trước SSH/RDP tới VM (TCP forwarding) để bạn bỏ public IP và bastion host.
- Kiểm tra Google identity của user + IAM role (
roles/iap.httpsResourceAccessor) và, với Access Context Manager, điều kiện thiết bị/vị trí.
# Tunnel SSH tới một VM private qua IAP (không cần external IP)
gcloud compute ssh my-vm --zone=us-central1-a --tunnel-through-iap
Security Command Center (SCC)
SCC là dashboard bảo mật và rủi ro trung tâm — kiểm kê tài sản, phát hiện misconfiguration và lỗ hổng, cùng threat detection.
| Khía cạnh | Standard | Premium / Enterprise |
|---|---|---|
| Giá | Miễn phí | Trả phí (per-org / theo usage) |
| Security Health Analytics | Quét misconfig cơ bản | Đầy đủ, liên tục |
| Web Security Scanner | Hạn chế | Đầy đủ (managed scans) |
| Event Threat Detection | — | Có (threat từ logs) |
| Container/VM Threat Detection | — | Có |
| Attack path simulation | — | Có (Premium/Enterprise) |
| Báo cáo compliance (CIS, PCI, v.v.) | — | Có |
| SIEM/SOAR (Enterprise) | — | Tích hợp Chronicle |
Dùng Standard cho khả năng hiển thị nền tảng; Premium/Enterprise cho threat detection chủ động, mapping compliance và phân tích attack-path.
Cloud Armor (WAF / DDoS)
Cloud Armor là WAF và bảo vệ DDoS của Google tại edge của global load balancer.
- Security policies = các rule có thứ tự khớp theo IP/CIDR, geo, hoặc preconfigured WAF rules (OWASP ModSecurity CRS cho SQLi, XSS, LFI, RCE).
- Rate limiting (throttle / ban) theo client cho chống lạm dụng và bot.
- Adaptive Protection — phát hiện tấn công L7 DDoS dựa trên ML với rule gợi ý.
- Managed Protection Plus thêm phản ứng DDoS luôn bật và phân tích tấn công.
gcloud compute security-policies create web-waf --description="Edge WAF"
# Chặn một quốc gia và bật preconfigured rule SQLi
gcloud compute security-policies rules create 1000 \
--security-policy=web-waf \
--expression="origin.region_code == 'KP'" --action=deny-403
gcloud compute security-policies rules create 2000 \
--security-policy=web-waf \
--expression="evaluatePreconfiguredExpr('sqli-v33-stable')" --action=deny-403
VPC Service Controls
VPC Service Controls (VPC-SC) tạo một service perimeter quanh các managed Google API (BigQuery, GCS, v.v.) để ngăn rò rỉ dữ liệu (exfiltration). Ngay cả một caller có IAM credential hợp lệ cũng không thể chuyển dữ liệu ra ngoài perimeter — giảm thiểu rò rỉ do đánh cắp credential và insider.
- Perimeter — một tập project mà các dịch vụ được bảo vệ chỉ có thể được truy cập từ bên trong.
- Access levels (qua Access Context Manager) — điều kiện (dải IP, thiết bị, identity) cấp quyền vào.
- Ingress/egress rules — ngoại lệ có kiểm soát cho truy cập cross-perimeter hợp pháp.
- Chạy dry-run mode trước để log vi phạm mà không chặn.
Binary Authorization
Binary Authorization là một cổng lúc deploy cho GKE và Cloud Run, đảm bảo chỉ container image tin cậy, đã attest được chạy. Một policy yêu cầu image được ký bởi các attestor tin cậy (ví dụ được build bởi CI của bạn, đã scan, đã pass test). Image không ký hoặc chưa xác minh bị chặn. Kết hợp với scan lỗ hổng Artifact Analysis, nó enforce một chuỗi cung ứng phần mềm kiểm chứng được.
Assured Workloads (tóm tắt)
Assured Workloads áp dụng kiểm soát compliance (cư trú dữ liệu, truy cập nhân sự, quản lý khóa) lên một folder project để đáp ứng các quy chế như FedRAMP, CJIS, IL4/IL5, HIPAA và yêu cầu chủ quyền theo vùng — mà không phải đấu dây thủ công từng kiểm soát. Hữu ích cho workload thuộc lĩnh vực quy định/khu vực công và sovereign-cloud.
Khái niệm chính
CMEK vs CSEK vs khóa do Google quản lý
| Mô hình | Ai giữ/rotate khóa | Dùng khi |
|---|---|---|
| Google-managed (mặc định) | Cần mã hóa nhưng không cần kiểm soát khóa | |
| CMEK (KMS) | Bạn, trong Cloud KMS | Compliance yêu cầu kiểm soát/rotation/thu hồi |
| CSEK | Bạn cung cấp raw bytes; Google không lưu | Yêu cầu khóa không bao giờ rời khỏi bạn |
| EKM (external) | Đối tác ngoài / HSM on-prem | Khóa phải nằm hoàn toàn ngoài Google |
Secret Manager vs KMS
Chúng giải quyết vấn đề khác nhau: KMS quản lý khóa dùng để mã hóa/giải mã/ký; Secret Manager lưu giá trị secret (và dùng mã hóa bên dưới). Lưu mật khẩu trong Secret Manager; dùng KMS để CMEK-mã hóa một database. Đừng đặt raw application secret trực tiếp vào KMS.
Zero-trust access
IAP + Access Context Manager + VPC-SC cùng nhau hiện thực BeyondCorp zero-trust: truy cập app theo identity và ngữ cảnh, không dựa vào vị trí mạng, và một data perimeter quanh các dịch vụ. Điều này thay thế mô hình cũ “mạng nội bộ tin cậy + VPN”.
Best Practices
-
Dựa vào mã hóa mặc định; chỉ thêm CMEK ở nơi compliance đòi hỏi kiểm soát. Lý do: mọi thứ đã được mã hóa AES-256 at rest — CMEK thêm overhead vận hành và nên dành cho dữ liệu cần đảm bảo rotation/thu hồi.
-
Lưu mọi secret trong Secret Manager, không bao giờ trong code, image hay file env trong git. Lý do: credential hard-code là vector rò rỉ hàng đầu; Secret Manager thêm versioning, IAM, audit và rotation.
-
Cấp
secretAccessortheo từng secret cho service account theo từng workload. Lý do: least privilege giới hạn một workload bị xâm phạm chỉ đúng những secret nó cần, không phải cả project. -
Bật automatic key rotation trong KMS. Lý do: rotation định kỳ giới hạn blast radius của một key version bị xâm phạm và được nhiều khung compliance yêu cầu.
-
Tách nhiệm vụ quanh KMS bằng các IAM role riêng biệt. Lý do: tách
cryptoKeyEncrypterDecrypter(dùng) khỏicloudkms.admin(quản lý) để không identity nào vừa dùng vừa hủy được khóa. -
Dùng envelope encryption cho dữ liệu ứng dụng lớn. Lý do: mã hóa dữ liệu khối lượng lớn cục bộ bằng DEK và chỉ gọi KMS để wrap/unwrap — tránh giới hạn rate của KMS và giữ payload khỏi đường của key-service.
-
Đặt IAP trước app nội bộ và SSH/RDP; bỏ public IP. Lý do: xác thực theo ngữ cảnh, theo request qua IAP loại bỏ bastion và cổng quản trị phơi ra internet.
-
Bật Security Command Center và triage finding liên tục. Lý do: SCC phơi bày misconfiguration và threat khắp org; Premium thêm threat chủ động và attack-path cho môi trường rủi ro cao.
-
Đặt một policy Cloud Armor với OWASP CRS trước các HTTPS load balancer public. Lý do: WAF edge + bảo vệ DDoS chặn các tấn công web phổ biến và flood khối lượng trước khi tới backend.
-
Thêm rate limiting và Adaptive Protection trong Cloud Armor. Lý do: throttling và phát hiện L7 DDoS dựa trên ML phòng chống lạm dụng và flood tầng ứng dụng mà ACL đơn giản bỏ lỡ.
-
Bọc các dịch vụ dữ liệu nhạy cảm trong một VPC Service Controls perimeter (dry-run trước). Lý do: ngăn exfiltration ngay cả với credential đánh cắp hợp lệ; dry-run xác thực rule trước khi bạn liều chặn traffic hợp pháp.
-
Enforce Binary Authorization trên GKE/Cloud Run production. Lý do: chỉ image đã ký, đã attest, đã scan mới deploy — bịt khe supply-chain nơi một image độc hại hay có lỗ hổng lọt vào prod.
-
Bật scan lỗ hổng Artifact Analysis trên mọi registry. Lý do: scan CVE liên tục các image nuôi Binary Authorization và phơi bày dependency có lỗ hổng trước khi deploy.
-
Bật data-access audit logs cho các dịch vụ nhạy cảm. Lý do: admin-activity logs bật mặc định, nhưng data-access logs (ai đọc gì) là opt-in và thiết yếu cho điều tra và compliance.
-
Dùng Assured Workloads cho workload thuộc lĩnh vực quy định/chủ quyền. Lý do: nó enforce kiểm soát cư trú, nhân sự và khóa như guardrail thay vì dựa vào cấu hình thủ công dễ sai.
-
Áp organization policy constraints làm guardrail. Lý do: org policy (ví dụ tắt tạo service account key, giới hạn location tài nguyên, yêu cầu CMEK, tắt external IP) ngăn cấu hình rủi ro khắp org trước khi chúng xảy ra.
Tài liệu tham khảo
- Encryption at rest in Google Cloud
- Encryption in transit in Google Cloud
- Cloud KMS documentation
- Customer-managed encryption keys (CMEK)
- Envelope encryption
- Secret Manager documentation
- Identity-Aware Proxy documentation
- BeyondCorp / zero trust
- Security Command Center documentation
- Cloud Armor documentation
- VPC Service Controls documentation
- Binary Authorization documentation
- Artifact Analysis (vulnerability scanning)
- Assured Workloads documentation
- Organization policy constraints
Part of the Cloud knowledge base — GCP deep dive. Complements DevOps Roadmap.
Overview
Google Cloud security is built on defense in depth and secure by default. Data is encrypted at rest and in transit automatically, IAM governs every API call, and a layered set of services lets you add stronger controls where you need them: managed keys (Cloud KMS), secrets (Secret Manager), context-aware access to apps (Identity-Aware Proxy), a security posture dashboard (Security Command Center), edge protection (Cloud Armor), data-exfiltration boundaries (VPC Service Controls), and supply-chain enforcement (Binary Authorization).
This page focuses on the data-protection and workload-security layer that sits on top of IAM and networking (covered in earlier pages).
| Concern | GCP service | AWS equivalent |
|---|---|---|
| Key management | Cloud KMS / Cloud HSM | AWS KMS / CloudHSM |
| Secrets | Secret Manager | Secrets Manager / SSM Param Store |
| App access proxy | Identity-Aware Proxy (IAP) | (ALB OIDC / Verified Access) |
| Posture & threat detection | Security Command Center | Security Hub + GuardDuty |
| WAF / DDoS | Cloud Armor | AWS WAF + Shield |
| Data perimeter | VPC Service Controls | (no direct equivalent) |
| Image/supply-chain gate | Binary Authorization | (Signer + admission policies) |
| Regulated/sovereign | Assured Workloads | AWS GovCloud / control frameworks |
Fundamentals
Default encryption at rest and in transit
- At rest: All customer data is encrypted by default with AES-256, using Google-managed keys via envelope encryption — no configuration needed. Data is chunked; each chunk gets its own data encryption key (DEK), and DEKs are wrapped by key encryption keys (KEKs) managed by Google’s central KMS.
- In transit: Traffic between Google data centers is encrypted automatically; traffic to Google Cloud services is protected with TLS. Application Layer Transport Security (ALTS) secures internal service-to-service calls.
You only add KMS when you need control over the keys (rotation policy, region residency, revocation, audit).
Cloud KMS — key rings, keys, CMEK, envelope encryption
Cloud KMS is a managed service to create and use cryptographic keys.
- Key ring — a regional (or global/multi-region) container that groups keys. Location is fixed at creation.
- Key (
CryptoKey) — has a purpose (symmetric encrypt/decrypt, asymmetric sign, asymmetric decrypt, MAC) and one or more versions. Rotation creates a new primary version. - Protection level —
SOFTWARE,HSM(FIPS 140-2 Level 3, via Cloud HSM), orEXTERNAL(Cloud EKM, keys held by an external partner).
CMEK (Customer-Managed Encryption Keys) replaces the Google-managed KEK with a KMS key you own for a service (BigQuery, GCS, Compute disks, Pub/Sub, etc.). You keep control over rotation and can disable/destroy the key to render data unreadable. CSEK (Customer-Supplied) goes further — you provide raw key bytes and Google never stores them — but is rarely needed.
Envelope encryption is the pattern: encrypt data locally with a DEK, then call KMS to encrypt (wrap) that DEK with a KEK. Store the wrapped DEK next to the ciphertext; decrypt by asking KMS to unwrap the DEK. This keeps large payloads off the KMS request path while centralizing key control.
# Create a key ring and a rotating symmetric key
gcloud kms keyrings create app-keyring --location=us-central1
gcloud kms keys create data-key \
--location=us-central1 --keyring=app-keyring \
--purpose=encryption \
--rotation-period=90d --next-rotation-time=$(date -u -d '+90 days' +%Y-%m-%dT%H:%M:%SZ)
# Encrypt / decrypt a file directly (small payloads)
gcloud kms encrypt \
--location=us-central1 --keyring=app-keyring --key=data-key \
--plaintext-file=secret.txt --ciphertext-file=secret.enc
gcloud kms decrypt \
--location=us-central1 --keyring=app-keyring --key=data-key \
--ciphertext-file=secret.enc --plaintext-file=-
Secret Manager
Secret Manager stores API keys, passwords, certificates, and other secrets with versioning, IAM access control, audit logging, optional CMEK, automatic replication policy (automatic or user-managed regions), and rotation notifications via Pub/Sub.
# Create a secret and add a version
printf 's3cr3t-value' | gcloud secrets create db-password \
--replication-policy=automatic --data-file=-
# Grant a service account read access to just this secret
gcloud secrets add-iam-policy-binding db-password \
--member="serviceAccount:app@PROJECT.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
# Access the latest version at runtime
gcloud secrets versions access latest --secret=db-password
Cloud Run, GKE, and Compute can mount secrets as files or inject them as environment variables, so apps never embed credentials.
Identity-Aware Proxy (IAP)
IAP enforces context-aware access control in front of applications and VMs — a zero-trust model where access is authenticated and authorized per-request instead of relying on network position (VPN).
- Sits in front of HTTPS load balancers, App Engine, and Cloud Run; also fronts SSH/RDP to VMs (TCP forwarding) so you can drop public IPs and bastion hosts.
- Checks the user’s Google identity + IAM role (
roles/iap.httpsResourceAccessor) and, with Access Context Manager, device/location conditions.
# Tunnel SSH to a private VM through IAP (no external IP needed)
gcloud compute ssh my-vm --zone=us-central1-a --tunnel-through-iap
Security Command Center (SCC)
SCC is the central security and risk dashboard — asset inventory, misconfiguration and vulnerability findings, and threat detection.
| Aspect | Standard | Premium / Enterprise |
|---|---|---|
| Price | Free | Paid (per-org / usage) |
| Security Health Analytics | Basic misconfig scans | Full, continuous |
| Web Security Scanner | Limited | Full (managed scans) |
| Event Threat Detection | — | Yes (log-based threats) |
| Container/VM Threat Detection | — | Yes |
| Attack path simulation | — | Yes (Premium/Enterprise) |
| Compliance reports (CIS, PCI, etc.) | — | Yes |
| SIEM/SOAR (Enterprise) | — | Chronicle integration |
Use Standard for baseline visibility; Premium/Enterprise for active threat detection, compliance mapping, and attack-path analysis.
Cloud Armor (WAF / DDoS)
Cloud Armor is Google’s WAF and DDoS protection at the global load-balancer edge.
- Security policies = ordered rules matching on IP/CIDR, geo, or preconfigured WAF rules (OWASP ModSecurity CRS for SQLi, XSS, LFI, RCE).
- Rate limiting (throttle / ban) per client for abuse and bot control.
- Adaptive Protection — ML-based detection of L7 DDoS attacks with suggested rules.
- Managed Protection Plus adds always-on DDoS response and attack analytics.
gcloud compute security-policies create web-waf --description="Edge WAF"
# Block a country and enable the SQLi preconfigured rule
gcloud compute security-policies rules create 1000 \
--security-policy=web-waf \
--expression="origin.region_code == 'KP'" --action=deny-403
gcloud compute security-policies rules create 2000 \
--security-policy=web-waf \
--expression="evaluatePreconfiguredExpr('sqli-v33-stable')" --action=deny-403
VPC Service Controls
VPC Service Controls (VPC-SC) create a service perimeter around managed Google APIs (BigQuery, GCS, etc.) to prevent data exfiltration. Even a caller with valid IAM credentials cannot move data outside the perimeter — mitigating stolen-credential and insider exfiltration.
- Perimeter — a set of projects whose protected services can only be reached from inside.
- Access levels (via Access Context Manager) — conditions (IP range, device, identity) that grant entry.
- Ingress/egress rules — controlled exceptions for legitimate cross-perimeter access.
- Run in dry-run mode first to log violations without blocking.
Binary Authorization
Binary Authorization is a deploy-time gate for GKE and Cloud Run that ensures only trusted, attested container images run. A policy requires images to be signed by trusted attestors (e.g., built by your CI, scanned, passed tests). Unsigned or unverified images are blocked. Combined with Artifact Analysis vulnerability scanning, it enforces a verifiable software supply chain.
Assured Workloads (brief)
Assured Workloads applies compliance controls (data residency, personnel access, key management) to a folder of projects to meet regimes like FedRAMP, CJIS, IL4/IL5, HIPAA, and regional sovereignty requirements — without you manually wiring each control. Useful for regulated/public-sector and sovereign-cloud workloads.
Key Concepts
CMEK vs CSEK vs Google-managed keys
| Model | Who holds/rotates the key | Use when |
|---|---|---|
| Google-managed (default) | You need encryption but not key control | |
| CMEK (KMS) | You, in Cloud KMS | Compliance requires control/rotation/revocation |
| CSEK | You supply raw bytes; Google doesn’t store | Strict key-never-leaves-you mandates |
| EKM (external) | External partner / on-prem HSM | Keys must live outside Google entirely |
Secret Manager vs KMS
They solve different problems: KMS manages keys used to encrypt/decrypt/sign; Secret Manager stores secret values (and uses encryption under the hood). Store a password in Secret Manager; use KMS to CMEK-encrypt a database. Don’t put raw application secrets directly in KMS.
Zero-trust access
IAP + Access Context Manager + VPC-SC together implement BeyondCorp zero-trust: identity- and context-aware access to apps, no reliance on network location, and a data perimeter around services. This replaces the old “trusted internal network + VPN” model.
Best Practices
-
Rely on default encryption; add CMEK only where compliance demands control. Rationale: everything is already AES-256 encrypted at rest — CMEK adds operational overhead and should be reserved for data needing rotation/revocation guarantees.
-
Store every secret in Secret Manager, never in code, images, or env files in git. Rationale: hard-coded credentials are the top leak vector; Secret Manager adds versioning, IAM, audit, and rotation.
-
Grant
secretAccessorper-secret to per-workload service accounts. Rationale: least privilege limits a compromised workload to the exact secrets it needs, not the whole project. -
Enable automatic key rotation in KMS. Rationale: periodic rotation limits the blast radius of a compromised key version and is required by many compliance frameworks.
-
Separate duties around KMS with distinct IAM roles. Rationale: split
cryptoKeyEncrypterDecrypter(use) fromcloudkms.admin(manage) so no single identity can both use and destroy keys. -
Use envelope encryption for large application data. Rationale: encrypt bulk data locally with DEKs and only call KMS to wrap/unwrap them — avoids KMS rate limits and keeps payloads off the key-service path.
-
Front internal apps and SSH/RDP with IAP; remove public IPs. Rationale: context-aware, per-request auth via IAP eliminates bastions and internet-exposed management ports.
-
Turn on Security Command Center and triage findings continuously. Rationale: SCC surfaces misconfigurations and threats across the org; Premium adds active threat and attack-path detection for high-risk environments.
-
Put a Cloud Armor policy with the OWASP CRS in front of public HTTPS load balancers. Rationale: edge WAF + DDoS protection blocks common web attacks and volumetric floods before they reach your backends.
-
Add rate limiting and Adaptive Protection in Cloud Armor. Rationale: throttling and ML-based L7 DDoS detection defend against abuse and application-layer floods that simple ACLs miss.
-
Wrap sensitive data services in a VPC Service Controls perimeter (dry-run first). Rationale: prevents exfiltration even with valid stolen credentials; dry-run validates rules before you risk blocking legitimate traffic.
-
Enforce Binary Authorization on GKE/Cloud Run production. Rationale: only signed, attested, scanned images deploy — closing the supply-chain gap where a malicious or vulnerable image reaches prod.
-
Enable Artifact Analysis vulnerability scanning on all registries. Rationale: continuous CVE scanning of images feeds Binary Authorization and surfaces vulnerable dependencies before deploy.
-
Enable data-access audit logs for sensitive services. Rationale: admin-activity logs are on by default, but data-access logs (who read what) are opt-in and essential for investigations and compliance.
-
Use Assured Workloads for regulated/sovereign workloads. Rationale: it enforces residency, personnel, and key controls as guardrails rather than relying on manual, error-prone configuration.
-
Apply organization policy constraints as guardrails. Rationale: org policies (e.g., disable service account key creation, restrict resource locations, require CMEK, disable external IPs) prevent risky configurations org-wide before they happen.
References
- Encryption at rest in Google Cloud
- Encryption in transit in Google Cloud
- Cloud KMS documentation
- Customer-managed encryption keys (CMEK)
- Envelope encryption
- Secret Manager documentation
- Identity-Aware Proxy documentation
- BeyondCorp / zero trust
- Security Command Center documentation
- Cloud Armor documentation
- VPC Service Controls documentation
- Binary Authorization documentation
- Artifact Analysis (vulnerability scanning)
- Assured Workloads documentation
- Organization policy constraints