Whoever controls your cloud key management service decides whether your encrypted data can be read, and whether it can be read at all, so a compromised KMS is both a confidentiality breach and a ransomware lever. A KMS sits underneath storage, databases, backups, secrets managers and signing services. Its key policies, grants and administrative roles are often created by infrastructure code, copied between accounts and rarely reviewed, and the workloads that call it are non-human identities with standing permissions. This guide is for cloud security engineers, platform teams and cryptography owners who run a cloud KMS, including keys backed by hardware security modules or by imported key material. It covers the attack surface, administrative roles, the service identities that use keys, key lifecycle and deletion, logging, hardening and decommissioning. It is vendor-neutral, so confirm exact setting names in your provider's documentation. For key management principles in general, see the Cryptographic Key Management Guide.
Key takeaways
- Treat the KMS as tier 0. Anyone who can change a key policy, disable a key or schedule its deletion can read or destroy every dataset that key protects.
- Separate key administration from key use. The people who create, rotate and delete keys should not be able to decrypt data, and the workloads that decrypt should not be able to change policy.
- Scope every service identity to named keys and operations. One workload identity per application, allowed only encrypt, decrypt or sign on the keys it needs, with no wildcard on keys or actions.
- Make destruction slow and visible. Use the longest practical deletion waiting period, alert on every disable and schedule-deletion call, and require a second approver.
- Log every key operation somewhere the KMS admins cannot alter. Key usage records are the only way to know what data a stolen credential decrypted.
What makes up a KMS's attack surface
NIST SP 800-130 sets out what a cryptographic key management system design should document, and NIST SP 800-57 Part 1 Rev. 5 describes the key states (pre-activation, active, suspended, deactivated, compromised, destroyed) that the system must enforce. A cloud KMS implements those functions as a service, but you configure most of the controls. The table reflects a common cloud architecture and is NHI Mgmt Group's view; your provider may name, merge or split these components differently.
| Component | What it holds or does | If an attacker controls it | Primary control |
|---|---|---|---|
| Key policies and resource permissions | Who may administer and who may use each key, including other accounts | Adds an external principal, grants decrypt to their own identity (T1098) | Policies as code, review, alert on policy change, block cross-account grants by default |
| Grants and delegated permissions | Temporary or programmatic rights for services to use a key | Creates a quiet grant that outlives the incident | Inventory grants, retire unused ones, alert on creation |
| Key encryption keys (customer-managed keys) | Wrap the data keys that encrypt storage, databases and backups | Disables or deletes the key, making data unreadable (T1485), or rewraps data under a key they control (T1486) | Deletion waiting period, deletion alerts, two-person approval |
| Imported or external key material | Customer-supplied material or a key held outside the provider | Lets material expire or removes the external key, causing an outage | Tracked expiry, escrowed copy under dual control |
| Signing and MAC keys | Sign tokens, artefacts or documents | Signs malicious artefacts or tokens that verifiers trust | Separate signing keys, narrow sign permission, usage alerting |
| Management plane identities | Cloud administrators, automation roles, pipelines that deploy key policy | Any of the above, at scale, through infrastructure code | Small admin group, just-in-time elevation, protected pipeline |
The two failure modes matter differently. Loss of confidentiality comes from too many principals with decrypt. Loss of availability comes from a key that is disabled, deleted or whose imported material expires; data encrypted under a lost key cannot be recovered, as the OWASP Key Management Cheat Sheet warns. NIST SP 800-53 SC-12(1) asks you to maintain availability of information in the event of the loss of cryptographic keys.
Administrative roles and separation of duties
Most cloud KMSs let you separate permissions to manage a key from permissions to use it. Design that split before keys are created, because default administrator roles in a cloud account often include both.
| Role | Allowed | Not allowed |
|---|---|---|
| Key administrator | Create keys, set policy, enable rotation, tag, schedule deletion with approval | Encrypt, decrypt, sign, create grants for itself |
| Key user (workload) | Encrypt, decrypt, generate data key or sign on named keys | Change policy, disable, delete, import material |
| Security auditor | Read key metadata, policies, rotation status and usage logs | Any change; any cryptographic operation |
| Break-glass | Restore a deleted policy or cancel a pending deletion during an incident | Routine use; it is monitored and sealed |
- Remove inherited rights: check whether the account owner, root or a broad organisation administrator role can still manage every key. Where the provider allows it, write key policies so that only named administrator roles can manage the key, and keep the account root out of daily use.
- Just-in-time administration: grant key administrator rights for a time-boxed change rather than permanently. NIST SP 800-53 AC-5 (separation of duties) and AC-6(5) (privileged accounts) are the controls to cite. See the Tiered Administration and Enterprise Access Model Guide.
- Organisation guardrails: use organisation-level policies to deny key deletion, disabling and policy changes except from named roles, and to deny granting key use to principals outside your organisation.
- Strong authentication: human administrators sign in through your identity provider with phishing-resistant MFA from privileged access workstations, in line with the NCSC secure system administration principles. See the Privileged Access Workstations Guide.
- Break-glass: keep one documented emergency path, sealed and alerting on use. See the Break-Glass Account Guide.
Service identities and key usage
Most calls to a KMS come from non-human identities: storage and database services acting for you, application workloads that unwrap data keys, pipelines that sign artefacts and backup services. The OWASP Key Management Cheat Sheet asks you to enforce least privilege for all key assets and to give each key a single purpose, which limits the damage if one is misused.
| Identity | Needs | Avoid | Pattern |
|---|---|---|---|
| Application workload | Decrypt or generate data key on its own key | Wildcard on all keys; management actions | One workload identity per application, keyed to named key IDs |
| Cloud storage or database service | Use a key on behalf of the account | Allowing any caller through the service | Condition the permission on the calling service and your account |
| CI/CD signing job | Sign with one signing key | Decrypt rights; long-lived access keys in pipeline variables | Federated short-lived credentials bound to the protected branch |
| Backup service | Encrypt and decrypt backup copies | Using the production key for backups | A separate backup key administered by a different team |
| Cross-account consumer | Use one shared key | Granting the whole external account | Named role in the external account, explicit conditions, expiry |
- Prefer federation: workloads should obtain short-lived credentials through workload identity federation, not static access keys. See the Workload Identity Federation Guide.
- Use encryption context: where the KMS supports additional authenticated data or encryption context, require it in policy so a stolen credential can only decrypt data for the matching tenant or table.
- Envelope encryption: keep key encryption keys in the KMS and data keys next to the data, wrapped. That keeps call volumes manageable and lets you rotate the wrapping key without re-encrypting everything. See the Envelope Encryption and KMS Integration Patterns Guide.
- Inventory: record every identity with key permissions, its owner and purpose in your NHI inventory. See the Service Account Security Guide.
Key lifecycle, rotation and deletion
NIST SP 800-57 Part 1 defines a cryptoperiod as the time span during which a key is authorised for use, and the OWASP cheat sheet gives typical ranges, such as up to two years for symmetric data keys in general low-volume use. Set your cryptoperiods in policy and let the KMS enforce them.
- Create: generate keys inside the KMS or its HSM-backed tier rather than importing, unless a regulation or contract needs you to hold the material. FIPS 140-3 defines four increasing security levels for cryptographic modules; record which level your key tier is validated at. See the HSM Deployment and Operations Guide.
- Tag and own: every key gets an owner, data classification, application and cryptoperiod tag at creation, enforced by policy.
- Rotate: turn on automatic rotation for symmetric keys where the KMS offers it. Rotating a key encryption key creates new versions while older versions remain available to decrypt existing data; rotation does not revoke access and is not a response to compromise.
- Respond to compromise: follow a written compromise-recovery plan, as the OWASP cheat sheet recommends: who is notified, which data is affected, how data is re-encrypted under a new key, and when the old key is disabled. See If your cloud key management service (KMS) is compromised.
- Disable, then delete: disable a key and watch for failed calls for a period before scheduling deletion. Use the longest deletion waiting period your provider allows for keys that protect production or backup data.
- Imported material: track expiry dates and keep an escrowed copy under dual control; once material expires or is removed, data cannot be decrypted until it is re-imported. See the BYOK, HYOK and External Key Management Guide.
Logging and detection
Cloud KMSs record management actions and cryptographic operations in the provider's audit log, but data-plane events such as decrypt calls may need to be switched on or may be sampled. Confirm both are captured for every account and region, and send them to storage under a different administrative account with object lock or equivalent immutability. NIST SP 800-53 AU-9(2) covers storing audit records on a separate system, and AU-9(4) limits management of audit logging to a subset of privileged users.
| Event | Why it matters | Alert |
|---|---|---|
| Key disabled, deletion scheduled, imported material deleted | Destroys availability of data (T1485) | Always, page the owner |
| Key policy or permission change, new grant | Persistence or exfiltration path (T1098) | Always, compare with change record |
| Decrypt or generate-data-key by an unexpected identity or from an unexpected network | Stolen workload credential (T1078.004) | New caller for a key; volume spike |
| Cross-account use of a key | Data moved or shared outside the organisation | Any account outside an allow list |
| New key created and used to encrypt existing data in bulk | Possible ransomware using a key the attacker controls (T1486) | Encryption under a key with an external or unknown policy |
| Rotation turned off; logging configuration changed | Weakened lifecycle or a blind spot (T1685) | Always |
Send these to your SIEM and route deletion alerts to a channel that does not depend on the same cloud account. See the Securing the SIEM itself guide for protecting the place where these logs end up.
Hardening an existing KMS: a phased approach
- Inventory (week 1 to 2): export every key, alias, policy, grant and rotation setting across all accounts, subscriptions or projects and regions. Map each key to the data stores and services that use it.
- Turn on logging and alerts: enable data-plane logging, forward to immutable storage, and deploy the deletion and policy-change alerts before changing any permissions.
- Audit mode for least privilege: compare granted permissions with 90 days of actual key usage (our suggested window) and draft narrower policies. Use the provider's policy analysis or access analysis features where available.
- Pilot ring: apply narrowed policies to non-production keys first, then one production application, and watch for access-denied errors.
- Guardrails: add organisation policies that deny deletion and external grants except for named roles.
- Roll back safely: keep the previous policy version in source control. If a workload fails, re-grant only the specific action and key it reports as missing; never restore a wildcard. A key pending deletion can be cancelled during the waiting period, so make cancellation part of the runbook.
For a full rollout of a new KMS, use the Cloud key management service (KMS) rollout playbook; for moving keys between providers or tiers, the Cloud key management service (KMS) migration playbook.
Decision guidance
| Decision | Choose A when | Choose B when |
|---|---|---|
| Provider-managed keys (A) or customer-managed keys (B) | You need encryption at rest with no key administration burden and no separation requirement | You need your own policy, rotation control, usage logs per key or the ability to revoke access |
| Software-protected (A) or HSM-backed key tier (B) | General workloads with no stated module validation level | Regulation, contract or risk needs a higher FIPS 140-3 level or hardware key protection |
| Generated in KMS (A) or imported or external material (B) | Default: fewer moving parts and no material outside the service | You must hold or escrow the material, or keep it outside the provider; accept the outage risk |
| Shared key per environment (A) or key per application (B) | Small estates where blast radius is acceptable | Larger estates, regulated data or multi-tenant platforms |
Small organisations can usually stop at customer-managed keys for regulated data, deletion alerts and a two-role split. Large organisations need policy as code, organisation guardrails and a key per application or tenant. See the Cloud Customer-Managed Keys and BYOK/HYOK Decision Guide.
Lifecycle of the platform itself
- Buy and design: ask the CISA and FBI Secure by Demand questions: standards-based SSO at no extra cost, phishing-resistant MFA by default, security logs in the base product, at least six months of log retention for cloud services, and a published vulnerability disclosure policy.
- Run: review administrators, grants and cross-account permissions every quarter, and track the metrics in the Cloud key management service (KMS) health check.
- Back up and recover: keep a separate key for backups under a different administrative team, and test that a restore can decrypt with that key alone. See the Backup Security and Immutable Backup Guide.
- Retire: before deleting a key, prove that no data store still references it, export the usage history you must retain, then disable, wait and delete. Remove the key's grants and aliases, and close the workload identities that used it.
Detection and measurement
- Percentage of customer-managed keys with an owner, application and cryptoperiod tag (target: 100%).
- Number of principals that can both administer and use the same key (target: zero outside break-glass).
- Policies or grants with wildcard principals, wildcard keys or external accounts outside the allow list (target: zero).
- Percentage of symmetric keys with automatic rotation on.
- Disable and schedule-deletion events with a matching change record (target: 100%), and median time from the event to owner acknowledgement.
- Percentage of accounts and regions with data-plane KMS logging enabled and forwarded to immutable storage.
Framework mapping
| Control area | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | ATT&CK threat addressed |
|---|---|---|---|
| Key lifecycle and availability | SC-12, SC-12(1), SC-28, SC-28(1) | PR.DS-01 | T1485 Data Destruction |
| Admin and use separation | AC-5, AC-6, AC-6(5), AC-2 | PR.AA-05 | T1098 Account Manipulation |
| Service identity credentials | IA-5 | PR.AA-01 | T1078.004 Cloud Accounts, T1098.001 Additional Cloud Credentials |
| Logging of key operations | AU-6, AU-9(2), AU-9(4), AU-12, AC-6(9) | PR.PS-04 | T1685 Disable or Modify Tools |
| Change control of policy | CM-3, CM-5 | PR.PS-01 | T1486 Data Encrypted for Impact |
| Backup keys | CP-9 | PR.DS-11 | T1485 Data Destruction |
In ISO/IEC 27001:2022 Annex A, the platform maps mainly to 8.24 Use of cryptography, 8.2 Privileged access rights and 8.15 Logging. In CIS Controls v8.1, see Control 3 Data Protection and Control 6 Access Control Management.
Common failure patterns
- Admins who can decrypt: a broad cloud administrator role includes key use, so every administrator credential is a decryption credential.
- Wildcard key policies: a policy written during a proof of concept allows any principal in the account to decrypt, and is copied into every new key by a template.
- Forgotten grants: programmatic grants created for a migration or a vendor integration are never retired and stay usable for years.
- Deletion with no alarm: a scheduled deletion passes unnoticed through the waiting period, and the data under the key becomes unreadable.
- Logs only for management events: decrypt calls are not recorded, so after a credential leak nobody can say what data was read.
- Imported material left to expire: nobody owns the expiry date, and a production database stops working on a weekend.
Practitioner checklist
- Classify the KMS, its key policies and the pipeline that deploys them as tier 0.
- Split key administrator, key user and auditor roles, and remove inherited rights from broad admin roles.
- Scope each workload identity to named keys and operations, using federation instead of static keys.
- Require encryption context or equivalent conditions where the KMS supports it.
- Turn on automatic rotation and enforce owner and cryptoperiod tags.
- Deny deletion, disabling and external grants by organisation policy except for named roles.
- Use the longest practical deletion waiting period, and alert on every disable and schedule-deletion call.
- Enable data-plane logging everywhere and forward it to immutable storage.
- Keep a separate backup key under a different team and test restores with it.
- Maintain a written key compromise-recovery plan and test it once a year.
Standards and references
- NIST: SP 800-57 Part 1 Rev. 5 Recommendation for Key Management: Part 1, General
- NIST: SP 800-130 A Framework for Designing Cryptographic Key Management Systems
- NIST: SP 800-152 A Profile for U.S. Federal Cryptographic Key Management Systems
- NIST: FIPS 140-3 Security Requirements for Cryptographic Modules
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
- OWASP: Key Management Cheat Sheet
- NCSC: Secure system administration
- CISA and FBI: Secure by Demand Guide
Related NHI Mgmt Group resources: Cryptographic Key Management Guide · Cloud key management service (KMS) health check · Securing the secrets manager itself · Securing the internal PKI and certificate authority itself · Encryption and Key Management Requirements Map