Control: 1.10 Ensure KMS Encryption Keys Are Rotated Within a Period of 90 Days
Description
Google Cloud Key Management Service stores cryptographic keys in a hierarchical structure designed for useful and elegant access control management.
The format for the rotation schedule depends on the client library that is used. For the gcloud command-line tool, the next rotation time must be in ISO or RFC3339 format, and the rotation period must be in the form INTEGER[UNIT], where units can be one of seconds (s), minutes (m), hours (h) or days (d).
Set a key rotation period and starting time. A key can be created with a specified rotation period, which is the time between when new key versions are generated automatically. A key can also be created with a specified next rotation time. A key is a named object representing a cryptographic key used for a specific purpose. The key material, the actual bits used for encryption, can change over time as new key versions are created.
A key is used to protect some corpus of data. A collection of files could be encrypted with the same key and people with decrypt permissions on that key would be able to decrypt those files. Therefore, it's necessary to make sure the rotation period is set to a specific time.
Remediation
From Google Cloud Console
- Go to
Cryptographic Keysby visiting: https://console.cloud.google.com/security/kms. - Click on the specific key ring.
- From the list of keys, choose the specific key and Click on
Right side pop up the blade (3 dots). - Click on
Edit rotation period. - On the pop-up window,
Select a new rotation periodin days which should be less than 90 and then chooseStarting ondate (date from which the rotation period begins).
From Google Cloud CLI
- Update and schedule rotation by
ROTATION_PERIODandNEXT_ROTATION_TIMEfor each key:
gcloud kms keys update new --keyring=KEY_RING --location=LOCATION --next-rotation-time=NEXT_ROTATION_TIME --rotation-period=ROTATION_PERIOD
Default Value
By default, KMS encryption keys are rotated every 90 days.
Usage
Run the control in your terminal:
powerpipe control run gcp_compliance.control.cis_v400_1_10Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run gcp_compliance.control.cis_v400_1_10 --shareSQL
This control uses a named query:
select self_link as resource, case when "primary" ->> 'state' = 'DESTROYED' then 'skip' when "primary" ->> 'state' = 'DESTROY_SCHEDULED' then 'skip' when "primary" ->> 'state' = 'DISABLED' then 'skip' when split_part(rotation_period, 's', 1) :: int <= 7776000 then 'ok' else 'alarm' end as status, case when "primary" ->> 'state' = 'DESTROYED' then title || ' is destroyed.' when "primary" ->> 'state' = 'DESTROY_SCHEDULED' then title || ' is scheduled for deletion.' when "primary" ->> 'state' = 'DISABLED' then title || ' is disabled.' when rotation_period is null then title || ' in ' || key_ring_name || ' requires manual rotation.' else key_ring_name || ' ' || title || ' rotation period set for ' || (split_part(rotation_period, 's', 1) :: int)/86400 || ' day(s).' end as reason , location as location, project as projectfrom gcp_kms_key;