Chapter 14: Hardening the Perimeter - Security and Compliance
Security in Google Cloud is built on the concept of Defense in Depth. While Google secures the physical infrastructure and the hardware (using the Titan chip), the “Security in the Cloud” is your responsibility. This chapter covers the advanced tools used to protect data, manage identities, and ensure compliance at scale.1. VPC Service Controls (VPC SC): The Virtual Moat
VPC Service Controls is perhaps the most powerful security tool in GCP. It creates a security perimeter around your Google-managed services (like Cloud Storage, BigQuery, and Cloud SQL).The Service Perimeter with Access Context Manager
- Data Exfiltration Protection: Even if an attacker compromises a VM and gets hold of a service account key, VPC SC prevents them from copying data from your BigQuery table to an external bucket if that bucket is outside the perimeter.
- Service-to-Service Protection: It ensures that only authorized resources inside the perimeter can talk to each other.
- Access Context Manager: You can define “Access Levels” based on IP addresses, user identity, or device health (e.g., “Allow access only if the user is on a company-managed laptop with an encrypted disk”).
2. Sensitive Data Protection (Cloud DLP)
Cloud Data Loss Prevention (DLP) allows you to discover, classify, and protect sensitive data (PII, PHI, financial records) across your entire cloud footprint.Discovery and De-identification
- Inspection: Automatically scan buckets, BigQuery tables, and Datastore instances for over 150 built-in infoTypes (Credit card numbers, SSNs, passports).
- De-identification:
- Masking: Replacing
1234-5678withXXXX-XXXX. - Tokenization: Replacing sensitive data with a cryptographically secure token.
- Bucketing: Changing “Age: 27” to “Age: 20-30” to preserve privacy while maintaining analytical value.
- Masking: Replacing
3. Cloud KMS: Managing the Keys to the Kingdom
Cloud Key Management Service (KMS) provides a centralized place to manage cryptographic keys.Key Types and Tiers
- Software Keys: Fast and cost-effective, managed by Google.
- HSM (Hardware Security Module): Keys are stored on physical FIPS 140-2 Level 3 validated hardware. The raw key never leaves the hardware.
- External Key Manager (EKM): You store your keys on-premise or in a 3rd party vault (like Thales or Fortanix), and Google Cloud calls your vault every time it needs to encrypt/decrypt. You have ultimate control—if you pull the plug on your vault, Google can no longer read your data.
4. Security Command Center (SCC)
SCC is the central security dashboard for GCP. The Premium tier offers advanced threat detection.- Event Threat Detection: Scans your Cloud Audit Logs for signs of account hijacking, brute force attacks, or suspicious IAM changes.
- Container Threat Detection: Detects malicious activity inside your GKE containers, such as the execution of unauthorized binaries or reverse shells.
- Compliance Monitoring: Provides real-time reports on how your infrastructure aligns with industry standards like CIS, PCI-DSS, and HIPAA.
5. Identity-Aware Proxy (IAP) and Zero Trust
IAP is Google’s implementation of the BeyondCorp zero-trust model. It allows you to expose web applications and SSH/RDP access to the internet without a VPN.- Context-Aware Access: Access is granted based on the user’s identity and the “context” of their request (location, device security, etc.).
- IAP TCP Forwarding: Allows you to SSH into a VM that has no public IP address. You connect to the IAP tunnel, which then securely forwards your traffic to the internal VM.
6. Secret Manager
Secrets (API keys, DB passwords) should never be stored in code, environment variables, or config files.- Version Control: Rotate secrets easily by adding new versions and letting applications always pull the
latestversion. - IAM-Integrated: Grant access to specific secrets only to the service accounts that need them.
7. Advanced Perimeter Defense: IAP and SCC
7.1 IAP TCP Forwarding
IAP isn’t just for web apps. TCP Forwarding allows you to reach internal VMs via SSH (port 22) or RDP (port 3389) even if they have no public IP.- How it works: You connect to the IAP service endpoint. IAP verifies your IAM identity and the context of your request. If authorized, it creates a tunnel into your VPC and delivers the traffic to the VM’s internal IP.
- Command:
gcloud compute ssh [VM_NAME] --tunnel-through-iap.
7.2 Security Command Center (SCC) Premium
The Premium tier of SCC provides active threat detection:- Event Threat Detection: Scans logs for brute-force attacks and account hijacks.
- Container Threat Detection: Detects unauthorized binary execution inside your GKE pods.
- Virtual Machine Threat Detection: Scans VM memory for signs of malware (cryptominers, rootkits) without needing an agent.
8. Interview Preparation
1. Q: How does VPC Service Controls (VPC SC) prevent data exfiltration? A: VPC SC creates a Service Perimeter around Google-managed services (like GCS or BigQuery). Even if an attacker compromises a valid User or Service Account, they cannot copy data from a protected resource to an external project or bucket that is not part of the same perimeter. It effectively mitigates the “Stolen Credential” risk by enforcing security at the resource level, not just the identity level. 2. Q: Explain the “BeyondCorp” Zero Trust model as implemented by IAP. A: Identity-Aware Proxy (IAP) replaces traditional VPNs. In a Zero Trust model, “being on the corporate network” does not grant access. IAP grants access to web apps and VMs (SSH/RDP) based on Identity (IAM) and Context (Device health, IP location, time of day). If a device is not encrypted or is missing a security patch, IAP blocks the request even if the user provides the correct password. 3. Q: What is the difference between Cloud KMS Software Keys and HSM Keys? A:- Software Keys: Cryptographic keys are stored and managed in a Google-managed software environment. They are cost-effective and fast.
- HSM Keys: Keys are stored on Hardware Security Modules (FIPS 140-2 Level 3 validated). The raw key material never leaves the hardware. This is a requirement for high-compliance industries (Banking, Government) that need physical separation of keys.
- Masking: Replacing part of the data (e.g.,
4532-XXXX). - Tokenization: Replacing sensitive data with a surrogate “token.”
- K-Anonymity (Bucketing): Generalizing data (e.g., changing “Age 27” to “Age 20-30”) so that individuals cannot be re-identified in a dataset.
- Disable External IPs: Preventing any VM in the company from having a public IP.
- Restrict Resource Usage: Only allowing specific machine types or regions.
- Enforce Shielded VMs: Requiring all GCE instances to use boot integrity checks. It prevents “Configuration Drift” and human error across thousands of projects.