HSM integration - seal wrap
Enterprise Only
Vault's Hardware Security Module (HSM) auto-unseal and Seal Wrap features require a Vault Enterprise Plus license.
Vault Enterprise integrates with Hardware Security Module (HSM) platforms to opt-in automatic unsealing. HSM integration provides three pieces of special functionality:
- Root Key Wrapping: Vault protects its root key (previously known as master key) by transiting it through the HSM for encryption rather than splitting into key shares
- Automatic Unsealing: Vault stores its encrypted root key in storage, allowing for automatic unsealing
- Seal Wrapping to provide FIPS KeyStorage-conforming functionality for Critical Security Parameters
In some large organizations, there is a fair amount of complexity in designating key officers, who might be available to unseal Vault installations as the most common pattern is to deploy Vault immutably. As such automating unseal using an HSM provides a simplified yet secure way of unsealing Vault nodes as they get deployed.
Vault pulls its encrypted root key from storage and transit it through the HSM for decryption via PKCS #11 API. Once the root key is decrypted, Vault uses the root key to decrypt the encryption key to resume with Vault operations.
Challenge
The Federal Information Processing Standard (FIPS) 140-2 is a U.S. Government computer security standard used to accredit cryptography modules. If your product or service does not follow FIPS' security requirements, it may complicate your ability to operate with U.S. Government data.
Aside from doing business with U.S. government, your organization may care about FIPS which approves various cryptographic ciphers for hashing, signature, key exchange, and encryption for security.
Solution
Integrate Vault with FIPS 140-2 certified HSM and enable the Seal Wrap feature to protect your data.
Vault encrypts secrets using 256-bit AES in GCM mode with a randomly generated nonce prior to writing them to its persistent storage. By enabling seal wrap, Vault wraps your secrets with an extra layer of encryption leveraging the HSM encryption and decryption.
Benefits of the Seal Wrap:
- Conformance with FIPS 140-2 directives on Key Storage and Key Transport as certified by Leidos
- Supports FIPS level of security equal to HSM
- For example, if you use Level 3 hardware encryption on an HSM, Vault will be using FIPS 140-2 Level 3 cryptography
- Allows Vault to be deployed in high security GRC environments (e.g. PCI-DSS, HIPAA) where FIPS guidelines important for external audits
- Pathway for Vault's use in managing Department of Defense's (DOD) or North Atlantic Treaty Organization (NATO) military secrets
Prerequisites
This intermediate operations tutorial assumes that you have:
- A supported HSM cluster to integrate with Vault
- Vault Enterprise version 0.9.0 or later
Step 1: Configure HSM Auto-unseal
When a Vault server is started, it normally starts in a sealed state where a quorum of existing unseal keys is required to unseal it. By integrating Vault with HSM, your Vault server can be automatically unsealed by the trusted HSM key provider.
To integrate your Vault Enterprise server with an HSM cluster, the configuration file must define the
PKCS11 seal
stanza providing necessary connection information.Example:
config-hsm.hcl
For the purpose of this tutorial, the storage backend is set to the local file system (
/tmp/vault
) to make the verification step easy.Warning
Although the listener stanza disables TLS (
tls_disable = "true"
) for this tutorial, Vault should always be used with TLS in production to provide secure communication between clients and the Vault server. It requires a certificate file and key file on each Vault host.The example configuration defines the following in its
seal
stanza:Parameter Description lib
Path to the PKCS #11 library on the virtual machine where Vault Enterprise is installed. slot
The slot number to use. pin
PKCS #11 PIN for login. key_label
Defines the label of the key you want to use. hmac_key_label
Defines the label of the key you want to use for HMACing. generate_key
If no existing key with the label specified by key_label
can be found at Vault initialization time, Vault generates a key.IMPORTANT: Having Vault generate its own key is the easiest way to get up and running, but for security, Vault marks the key as non-exportable. If your HSM key backup strategy requires the key to be exportable, you should generate the key yourself. Refer to the key generation attributes.
For the full list of configuration parameters, refer to the documentation.
If you are using systemd, the
ExecStart
parameter should point to the correct location of your configuration file. For example, if your configuration file is located at/etc/vault.d/config-hsm.hcl
, thevault.service
file may look as follow.Example:
/etc/systemd/system/vault.service
Start the Vault server.
Example:
If starting from the command:
If starting as a service using
systemd
, first enable thevault
service.Start the Vault server as a service.
Check the Vault status.
Initialize Vault.
First, set the
VAULT_ADDR
environment variable.Initialize Vault.
Example output:
When Vault is initialized while using an HSM, rather than unseal keys being returned to the operator, recovery keys are returned. These are generated from an internal recovery key that is split via Shamir's Secret Sharing, similar to Vault's treatment of unseal keys when running without an HSM. Some Vault operations such as generation of a root token require these recovery keys.
Check the Vault status again.
Vault is now unsealed (
Sealed
value is nowfalse
).To verify auto-unseal, stop and restart the Vault server and check its status.
If starting the Vault server as a service using
systemd
:Verify the Vault server status.
Step 2: Enable Seal Wrap
Note
For FIPS 140-2 compliance, seal wrap requires FIPS 140-2 Certified HSM which is supported by Vault Enterprise.
For some values, seal wrapping is always enabled including the recovery key, any stored key shares, the root key, the keyring, and more. When working with the key/value secrets engine, you can enable seal wrap to wrap all data.
To compare seal wrapped data against unwrapped data, enable key/value v1 secrets engine at two different paths:
kv-unwrapped
andkv-seal-wrapped
.Enable k/v v1 without seal wrap at
kv-unwrapped
.Enable k/v v1 with seal wrap. To do so, use the '-seal-wrap' flag when you enable the KV workflow.
To enable seal wrap, pass the
-seal-wrap
flag when you enable a secrets engine.List the enabled secrets engines with details.
Notice that the
Seal Wrap
parameter value istrue
forkv-seal-wrapped
.
Step 3: Test the Seal Wrap Feature
In this step, you are going to:
- Write some test data
- View the encrypted secrets
Write a secret at
kv-unwrapped/unwrapped
for testing.Read the path to verify.
Write the same secret at
kv-seal-wrapped/wrapped
for testing.Read the path to verify.
Using a valid token, you can write and read secrets the same way regardless of the seal wrap.
View the encrypted secrets
Remember that the Vault server was configured to use the local file system
(/tmp/vault
) as its storage backend in this example.
SSH into the machine where the Vault server is running, and check the stored
values in the /tmp/vault
directory.
Under the /tmp/vault/logical
directory, there are two sub-directories. One
maps to kv-unwrapped/
and another maps to kv-seal-wrapped/
although you cannot tell by
the folder names.
View the secret at rest. One of the directory maps to kv-unwrapped/unwrapped
.
Example:
View its content - password value is encrypted.
Another directory maps to kv-seal-wrapped/wrapped
.
View its content. The password value is encrypted.
Secrets are encrypted regardless; however, the seal-wrapped value is
significantly longer despite the fact that both values are the same,
my-long-password
.
When Vault's Seal Wrap feature is used with a FIPS 140-2 certified HSM, Vault will store Critical Security Parameters (CSPs) in a manner that is compliant with KeyStorage and KeyTransit requirements.