Safeguard
Research•

What does a hardware security module do and do you need one?

An HSM is tamper-resistant hardware that creates and uses keys without exposing them. Check FIPS 140 validation, backup and key policy before you buy.

Safeguard Security Team
5 min read

A hardware security module (HSM) is a tamper-resistant device that generates, stores and uses cryptographic keys so the key material never leaves it in readable form. Applications send data in, the module signs or decrypts it, and only the result comes out. You need one when key theft would be severe or a standard requires it.

What problem does an HSM solve?

Software keys live in files, memory or environment variables. Anyone who gains root on that machine, or reads a backup, can copy the key and use it forever and from anywhere. With an HSM the key is created inside the module and marked non-exportable. An attacker who compromises the application server can still ask the HSM to sign things while they hold access, but cannot walk away with the key.

That difference matters most for long-lived, high-value keys: a certificate authority root, a code signing key, a payment processing key, or the master key that wraps all your database keys.

How is an HSM validated?

Do not accept "military grade" wording. Look for a formal validation. NIST runs the Cryptographic Module Validation Program together with the Canadian Centre for Cyber Security. Vendors submit modules to accredited labs, and validated modules appear on a public list with a certificate number, the exact version tested, and the security level.

Two practical points. A validation covers a specific hardware and firmware version, so check that the one you will run is listed, and check whether the certificate is still active. And a validated module does not make your system secure. It means the module meets a standard for how it protects keys.

What forms do HSMs take?

  • A PCIe card inside a server, fast but tied to that host.
  • A network appliance shared by many applications, usually behind an authenticated API.
  • A USB token or small device, often used for signing keys held offline.
  • A cloud service where the provider operates validated hardware and you control keys through an API, with the shared responsibility questions that implies.

Common interfaces include PKCS#11, a standard API for cryptographic tokens, and vendor SDKs. Check that your software stack supports the one on offer.

A constructed example

A software company signs its release artifacts with a key stored as a file on a build server. Any pipeline job with disk access could copy it, and the key has no use limits.

The company moves signing to an HSM-backed service. The key is generated inside, never exported, and only the release pipeline's identity may call the sign operation, and only for a protected branch. If an attacker gets into a build job, they might trigger a bad signature during the window of access, but audit logs record each use and the key can be revoked without having been stolen. The remaining task is making sure the pipeline itself cannot be driven to sign arbitrary content, which no HSM solves on its own.

What should you decide before buying?

Key lifecycle first: generation, backup, rotation, retirement and destruction. Backups of HSM keys must be wrapped and held in a way that matches the original's protection, or the HSM protects nothing.

Next, authorization. Many modules support splitting administrative control among several cards or people, so no single person can export or reset. Decide who holds what.

Then availability. A single module is a single point of failure. Plan clustering or a second site, and test a recovery from backup.

Last, throughput. Signing and key wrap operations per second vary widely, so size against your real peak, not a brochure.

How to check or apply this

  1. List your keys and rank them by impact if stolen. Only the top few usually justify an HSM.
  2. Find which standards or contracts require validated modules, and at what level.
  3. Check the validated-modules list for the exact product and firmware you would run.
  4. Confirm your applications support the interface, such as PKCS#11, before you commit.
  5. Design backup, quorum control and a second site, then rehearse a restore.
  6. Limit which identities can call the key, and log every operation.
  7. Do not forget the software around the key: signing policy, build integrity and access to the pipeline.

Quick check

Can an HSM stop an attacker who owns my server?

It stops key theft, not key use. While the attacker has access they may still request operations, so access control, rate limits and audit logs matter.

Is a cloud HSM less secure than one in my rack?

Not automatically. It changes who operates the hardware and which controls you rely on. Read the validation status, the key control model and the provider's documentation, then decide against your own requirements.

Sources

Last reviewed: 18 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.