Skip to main content

More Info:

Rotate cryptographic keys on a regular schedule. Thus, key rotation should be enabled on all cryptographic keys. Google will handle the rotation of the encryption key itself, so previous data does not need to be re-encrypted before the rotation occurs.

Risk Level

Medium

Address

Operational Maturity, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • GDPR
  • ISO 27001
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Below are step‑by‑step console instructions to properly configure and remediate cryptographic key issues for GCP Compute Engine using Cloud KMS (CMEK). This covers the most common misconfigurations: using default Google‑managed keys only, not rotating keys, and incorrect IAM on keys.

1. Create or Verify a Cloud KMS Key (CMEK)

  1. In the Google Cloud Console, go to:
    Security → Key Management (or search “Key Management”).
  2. Ensure you’re in the correct project (top nav).
  3. Click Create key ring:
    • Name: e.g. compute-keyring
    • Location type: usually Regional
    • Location: choose the same region as your Compute Engine resources.
    • Click Create.
  4. On the new key ring, click Create key:
    • Name: e.g. compute-disk-key
    • Protection level: Software (or HSM if required by policy).
    • Purpose: Symmetric encryption/decryption.
    • Rotation period: set per your policy (e.g. 90 days) and enable automated rotation.
    • Click Create.

2. Grant Compute Engine Permission to Use the Key

You must allow the Compute Engine service account to use the key.
  1. Identify the service account:
    • For project‑wide default, it’s usually:
      PROJECT_NUMBER-compute@developer.gserviceaccount.com
    • To confirm, go to IAM & Admin → Service Accounts and find:
      • “Compute Engine default service account” or
      • The custom service account attached to your VM(s).
  2. In the console, go to Security → Key Management → Key rings.
  3. Click the key ring, then click your key (e.g. compute-disk-key).
  4. Go to the Permissions tab.
  5. Click Grant access:
    • New principals: add the Compute service account from step 1.
    • Role:
      • Prefer fine‑grained: Cloud KMS CryptoKey Encrypter/Decrypter
        (or at minimum what your policy requires).
    • Click Save.

3. Use CMEK for New Disks / New VMs

You cannot change the encryption key of an existing disk in place; you must create a new disk or snapshot+disk using the CMEK.

3.1 New VM with CMEK‑encrypted boot disk

  1. Go to Compute Engine → VM instances.
  2. Click Create instance.
  3. Under Boot disk, click Change.
  4. Select your image as usual.
  5. Expand the Advanced options or Encryption section.
  6. Select Customer‑managed key (CMEK).
  7. Click Browse and select your key:
    • Choose the correct Key ring and Key created earlier.
  8. Click Select (for the disk), then Create (for the VM).

3.2 New additional data disk with CMEK

  1. While creating or editing a VM, under Additional disks, click Add new disk.
  2. Configure disk type/size.
  3. Expand Encryption options.
  4. Choose Customer‑managed key (CMEK) and select your KMS key.
  5. Save and create/update the VM.

4. Migrate Existing Disks to CMEK

To remediate existing disks not using CMEK:

4.1 Using snapshots

  1. Go to Compute Engine → Disks.
  2. Select the disk you want to remediate.
  3. Click Create snapshot:
    • Name the snapshot (e.g. disk1-snap-cmek-migrate).
    • Encryption:
      • Choose Customer‑managed key (CMEK).
      • Select your KMS key.
    • Click Create.
  4. After snapshot is ready, go to Compute Engine → Disks → Create disk:
    • Source type: Snapshot.
    • Source snapshot: select the snapshot you just created.
    • Under Encryption, choose Customer‑managed key (CMEK) and select the same key.
    • Click Create.
  5. Stop the VM that used the original disk.
  6. Detach the old disk and attach the new CMEK‑encrypted disk:
    • VM details → Edit → detach old disk, add existing disk (the new CMEK disk).
  7. Start the VM and verify it functions correctly.
  8. Once confirmed, delete the old, non‑CMEK disk if no longer needed.

5. Fix Key Rotation and Lifecycle

If the misconfiguration is about non‑rotating or long‑lived keys:
  1. Go to Security → Key Management.
  2. Click your key.
  3. Under Rotation schedule:
    • Ensure Automatic rotation is enabled.
    • Set a rotation period that complies with policy (e.g. 30–90 days).
  4. If you need a new primary key version immediately:
    • On the Versions tab, click Add new version.
    • (Optional) After validation, Disable or Destroy older key versions according to your retention policy.
Note: Disks already encrypted with a CMEK will automatically use the primary key version; using rotation does not require re‑creating disks.

6. Tighten IAM on Keys

To remediate over‑permissive KMS IAM:
  1. Go to Security → Key Management → Key rings → [your key] → Permissions.
  2. Remove broad roles from wide groups/principals:
    • Avoid roles/owner, roles/editor, or roles/cloudkms.admin for large groups.
  3. Only keep:
    • Service accounts that need Encrypter/Decrypter to read/write disks.
    • Limited admins for Cloud KMS Admin if required.
  4. Click Save.

7. Validate the Remediation

  1. For each VM:
    • Go to Compute Engine → VM instances → [VM].
    • Under Boot disk / Additional disks, check Encryption shows your CMEK key.
  2. For the KMS key:
    • Confirm Rotation is enabled.
    • Confirm IAM is appropriately restricted.
  3. Optionally, run Security Command Center or Policy Scanner (if in use) to confirm findings about “cryptographic keys” are cleared.
If you tell me your specific “cryptographic keys” finding text (from SCC, Forseti, or another tool), I can tailor these steps exactly to that control.
Below is a practical, step‑by‑step way to remediate common “Cryptographic Keys” misconfigurations for GCP Compute Engine using the gcloud CLI, focused on moving from default Google‑managed encryption to Cloud KMS CMEK and tightening key controls.If your specific finding text is different (e.g., about service account keys or SSH keys), tell me the exact finding and I’ll adapt.

1. Prerequisites

You’ll need an IAM identity with (at least):
  • roles/owner or
  • roles/compute.admin + roles/cloudkms.admin + roles/cloudkms.cryptoKeyEncrypterDecrypter

2. Create a KMS Key Ring and Crypto Key


3. Grant Compute Engine Access to the Key

Identify the Compute Engine service agents (at project level):
Grant it cryptoKeyEncrypterDecrypter:
If you use a custom service account for VMs, also grant that account:

4. Create New Disks/VMs Encrypted with CMEK

4.1 New Disk with CMEK

4.2 New VM with CMEK Root Disk


5. Migrate Existing Disks to CMEK

You can’t flip an existing disk’s key in place; you must recreate it from a snapshot or image using CMEK.

5.1 Snapshot the Existing Disk

5.2 Create a New Disk from Snapshot Using CMEK

5.3 Attach New Disk / Replace Boot Disk

For data disks, detach the old one and attach the new:
For boot disks, safest route is:
  1. Stop VM.
  2. Create an image from the existing boot disk.
  3. Create a new VM from that image with --boot-disk-kms-key=....
  4. Re‑apply network/metadata settings and delete the old VM.
Example:
Then migrate traffic and delete the old instance.

6. Enforce Key Rotation

Set rotation period and next rotation time:
KMS handles key versions; CMEK resources continue to work with new versions automatically.

7. Harden KMS IAM

Review and remove overly broad access:
Remove any allUsers, allAuthenticatedUsers, or unnecessary roles, and keep to:
  • roles/cloudkms.cryptoKeyEncrypterDecrypter for only required service accounts.
  • roles/cloudkms.admin for a small admin group.
Update via:
(where policy.json is your edited IAM policy).
If you can paste the exact “Cryptographic Keys” finding text (e.g., from Security Command Center or CIS benchmark), I’ll tailor these commands exactly to that control (disks, snapshots, images, etc.).
Below is a concise, step‑by‑step approach to remediate cryptographic key misconfigurations for Google Compute Engine (GCE) using Python, focusing on:
  • Moving from Google‑managed to customer‑managed encryption keys (CMEK)
  • Correct IAM permissions on keys
  • Enforcing proper key rotation and usage

1. Identify Where CMEK Should Be Used

Common targets:
  • Boot disks and data disks on VM instances
  • Images and snapshots
Check which disks are unencrypted with CMEK (i.e., currently using Google‑managed keys):
Any disk equal to Google managed in encryptionKey is a remediation target.

2. Set Up KMS for CMEK

2.1. Enable APIs (one time)

2.2. Create a Key Ring and Crypto Key

Using Python (Cloud KMS client):

3. Grant the Compute Service Account Access to the Key

Each instance uses a service account. That SA needs roles/cloudkms.cryptoKeyEncrypterDecrypter on the crypto key.Typical default GCE service account:
PROJECT_NUMBER-compute@developer.gserviceaccount.com

4. Create New Disks/VMs with CMEK (Python)

CMEK cannot be applied in-place to an existing disk. You must create new disks with CMEK and migrate.

4.1. Create a CMEK‑Encrypted Disk

4.2. Create a VM Using CMEK for Boot Disk


5. Migrate Existing Disks to CMEK

For each non‑CMEK disk:
  1. Create a snapshot of the disk.
  2. Create a new disk from that snapshot with CMEK.
  3. Detach the old disk from the instance.
  4. Attach the new CMEK disk.
  5. Delete the old disk when verified.

5.1. Snapshot the Existing Disk

5.2. Create New Disk from Snapshot with CMEK

5.3. Detach Old Disk and Attach New Disk


6. Harden Key Management

  1. Restrict IAM on KMS keys:
    • Only necessary service accounts: roles/cloudkms.cryptoKeyEncrypterDecrypter
    • Admins: roles/cloudkms.admin with least privilege.
  2. Enable key rotation (already set in Step 2.2).
  3. Disable or destroy old keys only after:
    • All disks/images/snapshots no longer depend on them.
  4. Audit:
    • Enable Cloud Logging & Cloud Audit Logs for KMS.
    • Periodically verify disks use CMEK:

If you paste a specific current configuration (disk/instance JSON or output of gcloud compute instances describe), I can give tailored Python snippets to fix exactly that setup.
Changing rotation_period on an existing google_kms_crypto_key is an in‑place update and does not force key replacement.Verification: terraform plan should show an in-place update to google_kms_crypto_key.CRYPTO_KEY with rotation_period changing from null (or a value > 7776000s) to "7776000s" (and next_rotation_time set/updated if you specified it).

Additional Reading: