Join our Newsletter — 33% off our NHI Course
Home› Guides› Cryptographic Key Management Guide: KMS, HSM and Signing…
Guide Secrets Management

Cryptographic Key Management Guide: KMS, HSM and Signing Keys

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 24 October 2026 15 min read
On this page

Cryptographic keys are the identities behind identities. A token signing key decides whose tokens an application trusts, a code signing key decides which software is genuine, and an encryption key decides who can read data and backups. Steal one and you can forge access, ship malicious updates or decrypt everything, and patching the hole you came in through does not take the key back. This guide covers the key types that matter most, lessons from recent incidents, the key lifecycle under NIST SP 800-57, storage in HSMs and cloud KMS, access to keys, rotation and compromise response, detection, and preparation for post-quantum cryptography. It is written for security architects, platform and PKI teams, and the application owners who hold signing and encryption keys.

Key takeaways

  • Treat keys as non-human identities: inventory them, give each an owner and a purpose, and govern who and what can use them.
  • Protect high-value keys in hardware, in an HSM or managed KMS, so they can be used but not copied. NIST IR 8587 says token signing keys for moderate and high impact systems must not sit on the servers that use them.
  • Separate key administration from key use, and remove standing human access to production keys.
  • Define cryptoperiods and rotate on schedule, with overlapping validity for verifiers, and rehearse emergency rotation before you need it.
  • After a compromise, patching is not enough. Rotate every key the attacker could have read, invalidate what it signed or protected, and destroy all old copies.

The keys that matter most

Key typeWhat it protectsIf stolen
Token and assertion signing keysJWTs, SAML assertions, session tokensAttacker forges valid tokens for any user
Application machine keysView state and cookie integrity in web frameworksTampered payloads accepted; code execution in some frameworks
Code and firmware signing keysSoftware updates, drivers, packages and firmwareMalicious updates trusted by every customer or device
CA private keysCertificates for TLS, mTLS, SSH and devicesAttacker issues trusted certificates
Application private keys (for example GitHub App keys)The app's ability to mint access tokensFresh tokens for every installation until the key is revoked
Data and backup encryption keysDatabases, files, backupsData readable wherever copies exist
Key encryption keys and root keysOther keysEvery key they wrap is exposed

NIST SP 800-57 Part 1 Rev. 5 recommends that a key is used for only one purpose, and NIST IR 8587 says token and assertion signing keys must not be used for anything else. Mixing purposes widens the blast radius of any single theft.

Lessons from incidents

  • Microsoft Storm-0558 Key Breach 2023: attackers forged tokens with a 2016 consumer signing key that should have been retired in 2021, and enterprise mail accepted them because key scope was not validated. NIST IR 8587 cites the incident: forged tokens from a single stolen signing key gave access to agency email.
  • Coupang Breach 2025: a former developer used a token signing key that was never revoked to forge access. Investigators found keys stored on developer laptops, and a lawmaker said the keys had validity periods of 5 to 10 years.
  • ToolShell SharePoint Exploitation 2025: attackers read SharePoint's ASP.NET machine keys, which kept code execution working after patching. Microsoft and CISA told defenders to rotate the keys and restart IIS.
  • Gladinet Hard-Coded Keys 2025: every installation used the same AES key and IV, so attackers forged access tickets on any server. The ASP.NET Machine Key Attacks 2025 showed the same failure at scale: Microsoft identified more than 3,000 publicly disclosed keys copied into applications.
  • SolarWinds Supply Chain Compromise: a stolen token-signing certificate let attackers forge SAML tokens.
  • MSI Signing Keys Leak 2023 and NVIDIA Code-Signing Certificates Stolen 2022: firmware and driver signing keys leaked with stolen data. Malware signed with NVIDIA's expired but still trusted certificates appeared soon after.
  • LastPass Breach 2022 and GoTo Breach 2023: decryption keys stored where attackers could reach them turned encrypted backups into readable ones.
  • Leaked GitHub App Private Keys 2026: GitGuardian found 474 of 4,802 leaked GitHub App keys still authenticated, some years after exposure.

The key lifecycle

NIST SP 800-57 Part 1 describes the states a key passes through: pre-activation, active, suspended, deactivated, compromised and destroyed. In practice:

  1. Generate with an approved algorithm and a good random source, inside a validated cryptographic module where possible. NIST IR 8587 requires token signing keys to be generated in validated modules.
  2. Register in an inventory with owner, purpose, algorithm, location, cryptoperiod and dependent systems. The OWASP Key Management Cheat Sheet notes that a compromise-recovery plan needs an inventory of all keys and their use.
  3. Distribute and store without exposing plaintext key material, wrapped by a key encryption key or held in hardware.
  4. Use only for its intended purpose, by authorised identities, with every use logged.
  5. Rotate at the end of the cryptoperiod or on suspicion of compromise, with overlapping validity where verifiers need time to update.
  6. Revoke and destroy when retired: remove the key from published metadata, then erase operational, backup and archived copies, and record it.

Cryptoperiods set the rotation schedule. These are suggested maximums; shorter is better where rotation is automated.

Key typeSuggested cryptoperiodSource
Private signature key1 to 3 yearsSP 800-57 Pt 1, Table 1
Token and assertion signing key, high impactNo more than 90 days of active signingNIST IR 8587
Token and assertion signing key, moderate or low impactLess than one yearNIST IR 8587
Symmetric data encryption keyUnder 2 years to apply protection; up to 3 more years to processSP 800-57 Pt 1, Table 1
Symmetric key-wrapping keyUnder 2 years to apply protectionSP 800-57 Pt 1, Table 1
Symmetric master or key derivation keyAbout 1 yearSP 800-57 Pt 1, Table 1
Private authentication key1 to 2 yearsSP 800-57 Pt 1, Table 1

Storage: HSM, KMS and software

OptionKey exportable?Best forWatch for
Hardware security moduleNo, operations run inside the moduleCA keys, code signing, root and token signing keysFIPS 140-3 validation level and scope; operational cost
Cloud KMSUsually no for service-generated keysData encryption, envelope encryption, many signing usesKey policy scope; rotation limits for asymmetric keys
TPM, secure enclave, embedded processorNoDevice and workload keysSecurity properties vary by implementation
Secrets managerYes, the secret is returned to the callerLower-value symmetric keys and application secretsKey sits in application memory and possibly in logs
Files, code, images, firmwareYes, to anyone who reads themNever for production keysShared, hard-coded and copied keys
  • Isolation by impact level: NIST IR 8587 says systems at moderate impact or above must store signing keys in hardware-based, hardware-backed or otherwise isolated storage, must not persist them on the servers, VMs or containers that use them, and at high impact must also isolate the signing operation itself.
  • Validation: the NIST Cryptographic Module Validation Program validates modules against FIPS 140-3. It states that FIPS 140-2 certificates move to the Historical List after 21 September 2026, so check the status of older HSMs and libraries.
  • Know what rotation does: AWS documents that rotating a KMS key changes only the current key material and keeps older material to decrypt existing data, and Google Cloud KMS does not rotate asymmetric keys automatically.
  • Never hard-code keys in source code, images or firmware, or share one key across customers or installations. See the Secrets Management Guide.

Controlling access to keys

  • Split the roles: separate who can administer a key (create, rotate, delete, change policy) from who can use it (sign, decrypt, wrap).
  • Scope use to workloads: grant use only to the specific workload identities that need it, not to broad roles. See the Cloud Workload Identity Guide.
  • Multi-person control for exporting, deleting or changing policy on critical keys.
  • No standing human access: OWASP says it is preferred that no humans can view keys, and that the key management system should at least account for everyone who can. Use just-in-time elevation for maintenance. See the JIT Access Guide.
  • Offboarding: leaver processes must cover keys people could read, not just accounts. Coupang's key outlived its holder's employment.
  • Keep keys apart from what they protect: the GoTo backups and the key for part of them were both reachable by the attacker.
  • Review who can get copies: NIST IR 8587 says identity providers must document and regularly review the systems and personnel authorised to receive backup or archived keys.

Rotation and compromise response

NIST IR 8587 describes rotation at scale as: create new keys and metadata, expose them to all relevant systems, start signing with them, keep accepting the old keys until tokens they signed expire, then remove and delete the old keys. Publish verification keys through a mechanism that supports rollover, such as a JWK Set (RFC 7517), where the kid parameter lets verifiers choose among keys during rollover.

  • Automate scheduled rotation: AWS KMS, Azure Key Vault and Google Cloud KMS all support rotation policies; Google advises against relying on irregular or manual rotation.
  • Rehearse emergency rotation for each critical key, including how long verifiers take to pick up a new key.
  • Rotate after host compromise: if any system that held or could read a key was compromised, rotate the key even when the vulnerability is patched, as ToolShell and Gladinet required.
  • Re-encrypt, not just rotate: rotating a KMS key does not re-encrypt data protected by the old material. If an encryption key leaked, re-encrypt the data under a new key and destroy the old one.
  • Code signing compromise: revoke the certificate, re-sign legitimate releases and tell customers what to trust. AnyDesk revoked its code signing certificate and replaced it after its 2024 breach. See the Code Signing Security Guide.
  • Token signing compromise: remove the key from metadata, and invalidate tokens and sessions it signed. See the Token and Session Security Guide.
  • Identify the damage: OWASP's compromise-recovery plan includes identifying all information that may be compromised and all signatures that may be invalid.

The Leaked Credential Response Playbook covers the wider incident steps.

Detection and monitoring

SignalData sourceReference
Signing or decrypt calls from a new identity, network or at unusual volumeKMS and HSM audit logsNIST IR 8587 logging
Key policy changes, exports, scheduled deletions or disabled rotationCloud audit logsChange monitoring
Processes reading private key files or certificate stores, followed by network or compression activityEDR telemetryATT&CK T1552.004
SAML or token sign-ins with valid signatures but no matching authentication eventsIdentity provider and SaaS logsATT&CK T1606.002
Use of retired key identifiersToken validation logsNIST IR 8587, section 5.1.1.5
Private keys found in repositories, images or leak dataSecret scanningOWASP NHI2
Binaries signed with your certificates that you did not releaseThreat intelligence, malware repositoriesNVIDIA lesson

Preparing for post-quantum cryptography

A key inventory is also the foundation for moving to post-quantum algorithms, because you cannot migrate keys you cannot find. NIST published its first three post-quantum standards in August 2024: FIPS 203 (ML-KEM) for key encapsulation, and FIPS 204 (ML-DSA) and FIPS 205 (SLH-DSA) for signatures. Its transition report, NIST IR 8547, was still an initial public draft when this guide was written; it proposes that quantum-vulnerable algorithms such as RSA and ECDSA at 112-bit security be deprecated after 2030, and that these families be disallowed after 2035.

  • Record algorithm and key size for every key in the inventory, so quantum-vulnerable keys can be counted.
  • Prioritise long-lived signing roots and data that must stay confidential for years.
  • Prefer HSMs and KMS services with a published roadmap for the new algorithms, and design for algorithm agility.

See the Post-Quantum Cryptography Migration Guide and the Post-Quantum Readiness Guide.

Framework mapping

IDs were checked against NIST CSF 2.0, the NIST SP 800-53 Rev. 5 (release 5.2.0) catalogue, the ISO/IEC 27001:2022 Annex A control list, the CIS Controls v8.1 list and the OWASP NHI Top 10 2025. This is an NHI Mgmt Group alignment, not an official crosswalk.

Control areaNIST CSF 2.0NIST SP 800-53 Rev. 5ISO/IEC 27001:2022 Annex ACIS Controls v8.1OWASP NHI Top 10
Key inventory and lifecycleID.AM-08SC-12, CM-8A.5.9, A.8.243NHI1
Generation and protected storagePR.DS-01SC-12, SC-12(2), SC-12(3), SC-13A.8.243NHI2
Token and assertion signing keysPR.AA-04IA-13(1)A.8.24, A.8.53, 6NHI4
Access to keys and separation of dutiesPR.AA-05AC-5, AC-6A.5.3, A.8.25, 6NHI5, NHI10
Cryptoperiods and rotationPR.DS-01SC-12A.8.243NHI7
No hard-coded or shared keysPR.PS-06IA-5(7)A.8.2816NHI2, NHI9
Code and firmware signingID.RA-09SI-7, SI-7(15)A.8.252, 16No direct item
Certificates and PKIPR.AA-03SC-17A.8.243NHI7
Keys held by cloud providersGV.SC-07SA-9(6)A.5.2315NHI3
Monitoring key useDE.CM-09AU-2, AU-6, SI-4A.8.15, A.8.168No direct item
Key compromise responseRS.MI-01, RS.MI-02IR-4A.5.2617NHI2

Common failure patterns

  • Patch and walk away: the vulnerability is fixed but stolen machine keys still work, as ToolShell and Gladinet showed.
  • Keys that outlive their owners: no leaver step covers key access, so a former employee still holds a valid signing key, as at Coupang.
  • Retirement that never happens: manual rotation stops after an outage and old keys stay trusted. The CSRB found this behind Storm-0558, as reported by BleepingComputer.
  • Vendor or sample keys in production: the same key ships in every installation or is copied from documentation, so one disclosure opens every customer.
  • Keys stored beside the data: decryption keys reachable from the same account or storage as the encrypted backups.
  • Expired is not retired: platforms that still trust expired signing certificates keep stolen ones useful.
  • Rotation that does not re-encrypt: teams rotate a KMS key after a leak and assume old ciphertext is now safe.

Metrics that show progress

MetricWhat it showsTarget direction
Keys in inventory with owner, purpose, algorithm and cryptoperiodVisibilityUp, to 100% of known keys
High-value keys (signing, CA, root) held in HSM or KMSProtection against copyingUp, to 100%
Keys past their cryptoperiodRotation disciplineDown, to zero
Keys with automated rotationOperational maturityUp
Humans with standing use or export rights on production keysInsider and credential theft exposureDown
Time to rotate a critical key in a rehearsalReadiness for compromiseDown
Hard-coded or shared keys found in code, images and productsHygieneDown, to zero
Keys with algorithm recorded and post-quantum status assessedMigration readinessUp

Implementation roadmap

PhaseActionsOutcome
First 30 daysInventory token signing, code signing, CA, machine and backup encryption keys with owners; scan code, images and firmware for private keys; add key access to leaver checklists; turn on KMS and HSM audit loggingYou know which keys matter and where they are
Days 31 to 90Move signing and root keys into HSM or KMS; split administration from use; remove standing human access; set cryptoperiods and enable automated rotation; publish verification keys through rollover-capable metadataHigh-value keys cannot be copied and rotate on schedule
Days 91 to 180Rehearse emergency rotation for each critical key; build detections for unusual key use and retired key IDs; check FIPS 140-3 status of modules; record algorithms and plan post-quantum migration for long-lived keysCompromise response is proven and migration is planned

Practitioner checklist

  • Inventory signing, encryption, machine, application and CA keys, with owners, purpose and dependent systems.
  • Move high-value keys into an HSM or managed KMS, and keep signing keys off the servers that use them.
  • Remove hard-coded, sample and shared keys from code, images, firmware and products.
  • Separate key administration from key use, and scope use to specific workload identities.
  • Set cryptoperiods and automate rotation with overlapping validity for verifiers.
  • Rehearse emergency rotation, and rotate keys after any compromise of systems that held them.
  • Re-encrypt data and destroy all copies of a leaked encryption key, including backups.
  • Revoke key access as part of leaver processes.
  • Log and alert on unusual key use, policy changes and use of retired key IDs.
  • Record algorithms and key sizes to plan the post-quantum transition.

Standards and references

Related NHI Mgmt Group resources: Machine Identity, PKI and Certificate Lifecycle Guide · Secrets Management Guide · Leaked Credential Response Playbook · Encryption Guide · Post-Quantum Readiness Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 24 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.