Back to Checks
huaweicloud

KMS keys have rotation enabled

kms_key_rotation_enabled
Service: kmsSeverity: medium
OfficialBuilt-inVerified
Categories:encryption
Resource Type:NotDefined

Ensure that Huawei Cloud Key Management Service (KMS) keys have automatic key rotation enabled to regularly rotate the cryptographic material.

Risk

Without key rotation, the same cryptographic material is used indefinitely, increasing the risk of key compromise over time. If a key is compromised, all data encrypted with that key version is at risk.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler huaweicloud --checks kms_key_rotation_enabled

Recommendation

Enable automatic key rotation for all KMS keys.

Remediation

CLI

hcloud KMS EnableKeyRotation --key_id=<key_id>

Other

1Log on to the **Huawei Cloud console**.
2Navigate to **Key Management Service**.
3Select the key.
4Click the **Rotation** tab.
5Enable **rotation** and set the rotation period.
6Click **OK**.

Check Code

from prowler.lib.check.models import Check, CheckReportHuaweiCloud
from prowler.providers.huaweicloud.services.kms.kms_client import kms_client


class kms_key_rotation_enabled(Check):
    """Check if KMS keys have rotation enabled."""

    def execute(self) -> list[CheckReportHuaweiCloud]:
        findings = []

        for key in kms_client.keys:
            report = CheckReportHuaweiCloud(metadata=self.metadata(), resource=key)
            report.region = key.region
            report.resource_id = key.id
            report.resource_arn = f"huaweicloud:kms:{key.region}:{kms_client.audited_account}:key/{key.id}"

            if key.is_rotation_enabled:
                report.status = "PASS"
                report.status_extended = (
                    f"KMS key {key.alias} ({key.id}) has rotation enabled "
                    f"with period {key.rotation_period}."
                )
            else:
                report.status = "FAIL"
                report.status_extended = (
                    f"KMS key {key.alias} ({key.id}) does not have rotation enabled."
                )

            findings.append(report)

        return findings