A hardware security module protects your most valuable keys only if the people, applications and backups around it are controlled as tightly as the hardware itself. Most HSM failures are operational: a single administrator who can do everything, application credentials stored in plain configuration files, backups no one has tried to restore, or a quorum whose key holders have left. This guide covers deploying and running HSMs, both on-premises appliances and cloud HSM services such as AWS CloudHSM, Azure Key Vault Managed HSM and Google Cloud HSM: how identity and roles work inside the HSM, quorum and separation of duties, the application credentials that connect to it, logging, a hardening baseline and the mistakes that cause outages or key loss. It is for PKI, platform and security engineers. Key life cycle policy is covered in the Cryptographic Key Management Guide; this page goes deeper on the HSM itself.
Key takeaways
- HSM users are not cloud IAM users. Cloud IAM controls who can create and manage the HSM resource; separate HSM credentials control who can manage users and keys inside it. Govern both.
- Quorum is your main defence against one bad administrator. AWS CloudHSM supports M of N approval from 2 to 8 approvers for admin operations; Azure Managed HSM security domain recovery needs a quorum of RSA key holders, with up to 10.
- Backups are only as safe as their wrapping keys. An HSM backup or security domain, plus the keys that protect it, is a complete copy of your keys. Store shares offline, apart and with recorded custody.
- Validation status matters for compliance. NIST's CMVP stated that FIPS 140-2 certificates move to the Historical list on 21 September 2026, after which agencies may use those modules only in existing systems; check your HSM's FIPS 140-3 status.
- Application credentials are the soft spot. The crypto user password or client certificate that a service uses to call the HSM is a non-human identity that needs vaulting, rotation and monitoring.
Choosing a deployment model
NIST SP 800-57 Part 1 Rev. 5 (Final, May 2020) sets general key management practice; the HSM is where that practice is enforced in hardware. The first decision is where the HSM sits and who operates the hardware.
| Model | Examples | Who controls keys and users | When it fits | Trade-off |
|---|---|---|---|---|
| On-premises network HSM | Appliances in your data centres, often partitioned | You, including hardware, firmware and physical access | Root CAs, payment processing, sovereignty requirements, offline signing | You run clustering, patching, physical security and spares |
| Dedicated cloud HSM | AWS CloudHSM; Azure Key Vault Managed HSM; Google Cloud Single-tenant Cloud HSM | You control HSM users or the security domain; the provider runs the hardware | Applications in that cloud needing PKCS#11, JCE or single-tenant keys | Provider-specific roles and tooling; you still own quorum and backup keys |
| Multi-tenant HSM-backed KMS | Cloud KMS keys at HSM protection level (for example Google Cloud HSM, protection level HSM) | Provider manages the HSM cluster; you control key access through IAM | Encryption at rest and envelope encryption at scale | Less control over the module; access is IAM-only |
| External key manager | Keys held in your HSM, used by a cloud service through an external key interface | You hold the keys outside the provider | Hold-your-own-key requirements | Availability of your HSM becomes a dependency of the cloud service |
Google documents its multi-tenant Cloud HSM as a cluster of FIPS 140-2 Level 3 certified HSMs, with a separate HSM_SINGLE_TENANT protection level that requires a Single-tenant Cloud HSM instance. Microsoft documents Managed HSM as single-tenant and FIPS 140-3 Level 3 validated. Always confirm the current certificate for the exact module and firmware in the CMVP validated modules search rather than relying on marketing pages. See the BYOK, HYOK and External Key Management Guide and the Cloud KMS and Cloud HSM Guide.
How identity and access work in an HSM
Every HSM has two identity layers. The outer layer is whoever can create, delete, network and back up the HSM resource (cloud IAM or data centre access). The inner layer is the set of HSM-local roles that manage users and keys. AWS states this explicitly: IAM credentials manage HSMs through the AWS API, while HSM user credentials are needed for operations on the HSM itself.
| Function | AWS CloudHSM (CloudHSM CLI) | Azure Managed HSM | PKCS #11 generic |
|---|---|---|---|
| Initial bootstrap | Unactivated admin on the first HSM; becomes admin after cluster activate and password change | Activation by downloading the security domain encrypted to at least three customer RSA public keys | Token initialisation by the Security Officer |
| User management | Admin: creates and deletes users, changes passwords | Managed HSM Administrator and local RBAC role assignments | Security Officer (CKU_SO) initialises the user PIN |
| Key management and crypto | Crypto user (CU): create, delete, share, import, export keys; encrypt, decrypt, sign, verify | Crypto roles assigned through local RBAC | Normal user (CKU_USER) |
| Internal replication | Appliance user (AU) for cloning and synchronisation; AWS states it cannot view or use your keys | Managed by the service | Vendor specific |
- Key attributes enforce policy: in PKCS #11 (version 3.1, OASIS Standard, July 2023), keys marked sensitive and non-extractable cannot leave the HSM in clear form. Generate long-lived private keys with those attributes set, and only allow wrapping to approved keys.
- Partitions are trust boundaries: on multi-partition appliances, give each application or environment its own partition and credentials so a compromised application cannot reach another's keys.
Admin roles and privileged access
HSM administrators can create users, change key policy and, depending on the product, export wrapped keys or download backups. Treat these roles as the highest tier of privileged access.
- Quorum (M of N): AWS CloudHSM quorum authentication requires a minimum of 2 and up to 8 approving admins for quorum-controlled operations, which include creating and deleting HSM users and changing another user's password. Each approver signs a quorum token, tokens expire after 10 minutes by default, and if MFA is enabled the same key serves both.
- Security domain quorum: Microsoft recommends multi-person control with a quorum of at least three, a maximum of 10, holders in separate roles and locations, and a quorum review at least quarterly or when a holder leaves or a share is lost.
- Just-in-time elevation: Microsoft recommends enabling Privileged Identity Management for the Managed HSM Administrator role. Apply the same pattern to cloud IAM roles that can delete or restore HSM resources. See the JIT Access Guide.
- Administration workstations: perform HSM administration and key ceremonies only from hardened, dedicated workstations. Microsoft lists, in order of preference, an air-gapped HSM, an air-gapped computer or a secure privileged access workstation for generating security domain keys.
- Separation of duties: the people who approve HSM user changes should not be the application owners whose keys live there, and key custodians should not also administer the backups that contain those keys.
- Break-glass: document how the HSM is recovered if admins are unavailable, and test it. See the Break-Glass Account Guide.
Integrations, API tokens and service accounts
Applications reach an HSM through PKCS #11 libraries, Java JCE providers, Microsoft CNG or KSP providers, OpenSSL engines or providers, KMIP, or a cloud API. Each connection uses a non-human identity, and that identity is the most likely way an attacker uses your keys without ever extracting them.
| Integration | Credential | Main risk | Control |
|---|---|---|---|
| PKCS #11 or JCE client | Crypto user name and password or PIN | PIN in a configuration file or environment variable on many servers | Pull the PIN from a secrets manager at start-up; one crypto user per application; rotate |
| Client-to-HSM network channel | Client certificate or mutual TLS | Shared client certificate copied across hosts | Per-host client certificates, restricted to known source addresses |
| Cloud API (Managed HSM, Cloud KMS) | Workload identity, managed identity or service account | Over-broad role such as key administrator granted to an application | Use-only roles scoped to individual keys; no long-lived service account keys |
| PKI, code signing, TLS termination | CA service account; signing service identity | Signing anything an attacker submits | Approval workflow in front of the signing call; log every signature |
| Automation (Terraform, CI/CD) | Pipeline identity | Pipeline can delete keys or HSMs | Separate pipeline for infrastructure; deletion protection and quorum for destructive actions |
Possession of a usable key handle is as dangerous as possession of the key. ATT&CK tracks theft of key files as T1552.004 Private Keys; HSMs prevent that, but an attacker who controls an authorised application can still sign or decrypt. See the Code Signing Security Guide and the Secrets Management Guide.
Backup, high availability and disaster recovery
- Clustering: run at least two HSMs in different availability zones or sites for any production key. A single HSM is a single point of failure for every application that depends on it.
- Cloud HSM backups: AWS CloudHSM periodically backs up users, keys and policies; the HSM encrypts all data before it leaves, and AWS states it cannot decrypt the backups. Backups are held in a service-controlled S3 bucket in the cluster's region, so plan copies for regional recovery.
- Security domain: in Azure Managed HSM, the security domain is an encrypted blob containing the HSM backup, user credentials and keys. Without it, keys are permanently lost; Microsoft cannot recover them. A lost security domain is treated as compromised, and the response is a new HSM with a new security domain, because key material cannot move between instances with different security domains.
- Offline shares: Microsoft recommends keeping security domain key shares offline (for example on encrypted USB drives), one share per device, in separate locations and safes, never on an internet-connected computer, with a record of every holder and handoff.
- Restore tests: restore a backup into an isolated cluster at least once a year and prove that applications can use the restored keys. NIST SP 800-53 SC-12(1) addresses key availability, and CP-9 system backup.
- Rotation of wrapping keys: when shares are lost or due for rotation, re-download the security domain with new wrapping keys, and test and store the new ones before destroying the old.
Logging and detection
| Source | What it records | Alert on |
|---|---|---|
| HSM audit log (AWS CloudHSM to CloudWatch Logs) | Client-initiated management commands: HSM creation and deletion, login and logout, user and key management | New HSM users, failed logins, key export or share, quorum token use |
| Cloud control plane log | Create, delete, backup, restore and network changes to the HSM resource | Deletion, restore from backup, changes outside change windows |
| Managed HSM operations | Security domain operations | SecurityDomainBackup and SecurityDomainBackupStatusGet, which Microsoft recommends alerting on |
| Application logs | Which identity used which key for what | Signing or decryption volume spikes; use from unexpected hosts |
| On-premises appliance | Syslog of admin actions, tamper and hardware events | Tamper events, firmware changes, partition creation |
Metrics: (1) percentage of production keys on clustered HSMs with tested restore in the last 12 months; (2) number of HSM admins and crypto users without a named owner (target zero); (3) days since last quorum review; (4) application credentials to the HSM stored outside a secrets manager (target zero); (5) management operations without a matching change record.
Hardening baseline
- Validated modules: select HSMs and firmware with a current FIPS 140-3 certificate where you need FIPS assurance, and record the certificate number. CMVP began FIPS 140-3 validations on 22 September 2020.
- Network isolation: place HSM interfaces in a dedicated management and client network; allow client traffic only from known application hosts.
- Bootstrap ceremony: activate new HSMs in a documented ceremony with witnesses, change default or temporary credentials immediately, and store records.
- Quorum on: enable quorum for user management and, where the product supports it, for key export and policy changes.
- MFA for admins: require MFA for HSM admin logins where supported.
- Key attributes: set non-extractable and sensitive attributes on private and secret keys by default; document every exception.
- Least privilege: one crypto user or role per application, no shared admin accounts, use-only roles for workloads.
- Deletion protection: enable soft delete and purge protection on cloud HSMs and require quorum or approval for destructive actions.
- Firmware and client libraries: patch on a schedule after testing in a non-production cluster; keep client libraries matched to firmware.
- Rollout: pilot new HSM integrations in a test partition with test keys, then migrate one application at a time, keeping the old key path available for rollback until the new one has run through a full cryptoperiod event such as a certificate renewal.
Small versus large: a small organisation with a few cloud workloads is usually better served by HSM-backed KMS keys plus strong IAM than by running its own HSM users and quorum. A dedicated or on-premises HSM makes sense when you operate a CA, payment keys or code signing at scale, or when regulation requires you to control the module.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SC-12 Cryptographic Key Establishment and Management; SC-12(1) Availability; SC-13 Cryptographic Protection | Core HSM purpose and key availability |
| NIST SP 800-53 Rev 5 | AC-5 Separation of Duties; AC-6 Least Privilege; AC-2(7) Privileged User Accounts | Quorum, roles and admin accounts |
| NIST SP 800-53 Rev 5 | AU-2 Event Logging; CP-9 System Backup | Audit logs and backups |
| NIST CSF 2.0 | PR.DS-01, PR.AA-05, DE.CM-03 | Data at rest, least privilege and separation of duties, monitoring personnel activity |
| NIST guidance | SP 800-57 Part 1 Rev. 5; FIPS 140-3 via CMVP | Key management practice and module validation |
| MITRE ATT&CK v20 | T1552.004 Private Keys | The theft HSMs are designed to prevent |
Common misconfigurations
- Single administrator: one person holds the only admin credential with no quorum, so a compromise or departure means total loss of control.
- Security domain shares in one place: all shares stored in the same safe, cloud drive or laptop, defeating the quorum entirely.
- Crypto user PIN in source control: the application's HSM password committed to a repository or baked into an image.
- Single HSM in production: no cluster, so a hardware failure or maintenance window takes down every dependent service.
- Untested backups: backups exist but restore has never been tried, or the wrapping key custodians have left.
- Extractable keys by default: keys generated with export allowed "for flexibility", turning the HSM into an expensive key store.
- Expired validation unnoticed: a compliance requirement assumes FIPS validation that no longer applies to the module or firmware in use.
Practitioner checklist
- Choose the deployment model per use case and record why.
- Confirm the FIPS 140-3 (or other required) validation for the exact module and firmware.
- Enable quorum for user management, and keep at least three named key holders in separate roles and locations.
- Store backup or security domain shares offline, separately, with custody records, and review quarterly.
- Give each application its own crypto user or role, with credentials held in a secrets manager.
- Set keys to non-extractable and sensitive by default.
- Run production HSMs as a cluster across zones or sites.
- Forward HSM audit logs and control plane logs to your SIEM and alert on user, key and backup operations.
- Test a full restore into an isolated cluster at least yearly.
- Protect cloud HSM resources with deletion protection and just-in-time admin roles.
Standards and references
- NIST: SP 800-57 Part 1 Rev. 5 Recommendation for Key Management
- NIST: Cryptographic Module Validation Program
- OASIS: PKCS #11 Specification Version 3.1
- AWS: CloudHSM HSM user types
- AWS: CloudHSM quorum authentication
- Microsoft Learn: Managed HSM security domain
- Google Cloud: Cloud HSM
Related NHI Mgmt Group resources: Cryptographic Key Management Guide · BYOK, HYOK and External Key Management Guide · Enterprise PKI Design and CA Hierarchy Guide · AWS KMS Security Guide