Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Auto-unseal and recovery keys: understanding Vault sealing

By updated

Improve this page

HashiCorp Vault logo

Vault protects your secrets with a sealing mechanism: even if an attacker reaches the storage, the data stays encrypted. This page helps you choose and configure the unsealing method that fits your context, and shows what recovery keys are for, and what they are not for.

The lesson on installing Vault already shows vault operator init and vault operator unseal with Shamir, and gives a short comparison of the two methods. This page does not repeat the initialization: it goes further into automatic unsealing, the keys it produces, its risks and the migration from one seal to another.

What you will learn

  • Why Vault uses a sealing mechanism
  • The fundamental difference between Shamir and auto-unseal
  • Recovery keys vs unseal keys: when to use which
  • The risks of each approach and how to mitigate them
  • How to migrate from one seal to another without losing access to the data
  • What belongs to Community Edition vs Enterprise
  • SOCLE anchoring: this guide implements the sealing part of SOCLE-SEC-STO-5 (in French), a hardened vault for sensitive secrets

Which terms does this page use?

A few words come back all along the page, so here they are in one place. Sealed is the state of a Vault that knows where its data is but cannot decrypt it. Unsealing is giving Vault back the means to decrypt: it happens at every start. With Shamir's Secret Sharing, the key is split into key shares (the parts, also called unseal keys), and a key threshold is the number of shares needed to rebuild it, for example 3 shares out of 5.

With auto-unseal, an external service holds the protecting key: a KMS (Key Management Service, a managed service that encrypts and decrypts with a key it never hands out) or an HSM (Hardware Security Module, a dedicated device that does the same in hardware). The recovery keys are shares produced instead of unseal keys when auto-unseal is used; the sections below explain what they allow. Seal wrap is an Enterprise feature that adds a layer of encryption through the seal mechanism. A root token is the all-powerful credential generated at initialization, and a rekey replaces the key shares with a new set.

Why is Vault "sealed" at startup?

The security problem it solves

Vault stores sensitive secrets (tokens, passwords, private keys). Even encrypted, this data would be vulnerable if someone could:

  • Steal the disk or a backup
  • Access the Raft/Consul storage
  • Compromise the Vault server

Sealing guarantees that the data stays unusable without a key that is never stored on the server.

How does Vault encryption work?

The diagram below shows the key hierarchy. Follow it from the top: the root key decrypts the encryption key, which is stored encrypted, and the encryption key in turn decrypts your secrets. Unsealing is the operation that rebuilds the root key; the two sealing methods differ only in how they do it.

Vault key hierarchy: the root key, never stored in clear text, decrypts the encryption key, which is stored encrypted and in turn decrypts your secrets.Root Keydecrypts the encryption key (never stored in clear)Encryption Keydecrypts the data (stored encrypted by the root key)Your secretsuser data
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The root key is at the heart of the system. It is never stored in clear text. Vault has to "rebuild" it at every startup.

What does sealing not protect?

Sealing protects access to the keys needed to decrypt the data at startup. But it does not replace:

ProtectionProvided by
Access control to secretsPolicies / ACLs
Traceability of operationsAudit logging
Security of the host systemOS hardening
Network protectionFirewall, TLS, mTLS
Storage integrityDisk encryption, backups

Once Vault is unsealed and running, the data is accessible to authenticated users according to their policies. Sealing protects the startup, not the runtime.

What are the two sealing methods?

Method 1: Shamir's Secret Sharing

Principle: the root key is split into N shares. K shares are needed to rebuild it (K is the threshold).

Classic example: 5 shares, threshold of 3

Root Key = Part1 + Part2 + Part3 + Part4 + Part5
To unseal:
- Admin A provides Part1 ✓
- Admin B provides Part3 ✓
- Admin C provides Part5 ✓ → Vault unsealed

Advantages:

  • Full control: no external dependency
  • Security: no single person can unseal alone
  • Resilience: the loss of N-K shares is tolerated

Drawbacks:

  • Manual: human intervention at every restart
  • Coordination: gathering K people can take time
  • Cannot be automated: a problem for self-managed clusters

With Shamir in a cluster, does every node have to be unsealed?

Yes. In a Vault cluster (several nodes), the sealing mechanism is independent per node. Vault does not share a "partially unsealed" state between nodes.

In practice:

  • If you have 3 nodes and use Shamir, you must provide the unseal keys on each node after a full restart
  • The leader and the standbys must all be unsealed individually
  • This multiplies the operational load by the number of nodes

This is one of the main reasons why auto-unseal is preferred in production on clusters.

Method 2: Auto-unseal

Principle: delegate the protection of the root key to an external service (KMS, HSM, Transit).

How it works: the diagram below shows the exchange. At every start, Vault sends the encrypted root key to the external service and gets it back decrypted, with no human involved. The service is therefore on the startup path.

Auto-unseal: an external service (AWS KMS, GCP KMS, Azure Key Vault, Transit or HSM) encrypts the root key, which is stored encrypted, and decrypts it when Vault restarts.encryptsdecrypts on restartRoot KeyEncrypted Root Key(stored)External serviceAWS KMS, GCP KMS, Azure Key Vault, Transit, HSM
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Advantages:

  • Automatic: no human intervention at restart
  • Self-managed clusters: compatible with Kubernetes and autoscaling groups
  • Audit: KMS accesses are logged
  • Rotation: possible without downtime

Drawbacks:

  • External dependency: if the KMS is down, Vault cannot start
  • Potential cost: KMS usage is billed
  • Complexity: extra infrastructure to manage

What is the difference between recovery keys and unseal keys?

The common confusion

Many people mix up unseal keys (Shamir) and recovery keys (auto-unseal). They are different concepts with distinct uses. The table below compares them on the same six criteria.

AspectUnseal keys (Shamir)Recovery keys (auto-unseal)
Main functionUnseal VaultEmergency operations
Used at restartYesNo (the KMS does it)
Can generate a root tokenYesYes
Can reseal VaultNo (an authorised token is required)No (an authorised token is required)
Allow a rekeyYes (of themselves)Yes (of the recovery keys)
Critical to operationVitalImportant but secondary

Why do recovery keys exist?

With auto-unseal, Vault starts on its own. But some critical operations still need a human authorisation, and the recovery keys provide it. The table below lists them.

OperationRecovery keys needed
Generate a new root tokenYes
Perform a rekey (change the recovery keys)Yes
Seal migration (KMS to another KMS)Yes
Reading the initial recovery keysNo (only once, at init)

Why can recovery keys not unseal Vault?

This is an intentional security decision. Recovery keys cannot decrypt the root key. If an attacker obtains the recovery keys, they cannot:

  1. Start a stolen Vault (the KMS is needed)
  2. Access the secrets without the KMS
  3. Bypass the KMS

That does not make recovery keys harmless. On a Vault that is already unsealed and reachable, whoever holds the threshold of recovery keys can generate a root token (vault operator generate-root), and therefore gets full access to the secrets, the policies and the configuration. They can also rekey the recovery keys and lock out the legitimate holders. Protect them as an administration key, not as a harmless spare key.

Neither unseal keys nor recovery keys can reseal Vault: vault operator seal requires an authorised token (sudo on sys/seal).

Which auto-unseal methods are available?

Cloud KMS (Community Edition)

The table lists the providers and the seal type to put in the Vault configuration. Each cloud has its own KMS service, and each one is available in Community Edition.

ProviderKMS serviceVault configuration
AWSAWS KMSseal "awskms"
GCPCloud KMSseal "gcpckms"
AzureAzure Key Vaultseal "azurekeyvault"
AlibabaAlibaba Cloud KMSseal "alicloudkms"
OCIOracle Cloud KMSseal "ocikms"

Advantages:

  • Native integration with the cloud
  • Managed high availability
  • Audit trails included
  • Available in Community Edition

Drawbacks:

  • Dependency on the cloud provider
  • Network latency
  • Usage costs

Transit (Vault-to-Vault)

One Vault cluster can unseal another Vault cluster. The one that does the work uses its Transit secrets engine, described in the lesson on Vault Transit.

A secondary Vault unseals itself automatically by calling the Transit engine of the primary Vault, which plays the role of unsealer.TransitVault Primary(unsealer)Vault Secondary(auto-unsealed)
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Advantages:

  • No cloud dependency
  • Full control
  • Free (Community Edition)

Drawbacks:

  • Complexity: you need a Vault cluster that is always available
  • Possible circular dependency
  • The unsealer cluster is usually itself unsealed manually (Shamir)

HSM (Hardware Security Module), Enterprise

Auto-unseal through an HSM (PKCS#11) is a Vault Enterprise feature.

TypeExamplesNotes
Cloud HSMAWS CloudHSM, GCP Cloud HSMHigh cost
On-premises HSMThales Luna, nCipherDedicated hardware

Advantages:

  • Reinforced security (the key never leaves the HSM)
  • FIPS 140-2 Level 3+ compliance

Drawbacks:

  • Enterprise only
  • Very high cost
  • Operational complexity

Seal HA, Enterprise

Vault Enterprise 1.16+ introduces Seal HA: the ability to configure several auto-unseal mechanisms for resilience.

  • At least two auto-unseal seals configured
  • Shamir is not supported in this mode
  • If one KMS is unavailable, the other takes over

Seal HA reduces the risk of depending on a single service, but it is an Enterprise-only feature.

When should I choose Shamir or auto-unseal?

For most production deployments, HashiCorp pushes towards auto-unseal because it greatly reduces operational complexity compared with Shamir. The table puts the two side by side on six criteria.

CriterionShamirAuto-unseal
Automatic restartNoYes
Horizontal scalingDifficultYes
Kubernetes-readyNoYes
Disaster recoverySlow (coordination)Yes, fast
External dependencyNoYes
SecurityHighHigh (different)

When should I keep Shamir?

Shamir remains appropriate in some cases, listed below with the reason for each.

SituationWhy Shamir
Lab / developmentNo need for auto-restart
"Zero cloud" policyNo KMS available
Extreme complianceNo external dependency tolerated
Air-gapped environmentNo KMS connectivity possible
Very tight budgetNo KMS cost
Transit unsealer clusterThe "unsealer" is usually Shamir itself

What are the risks, and how do I mitigate them?

Risk 1: loss of access to the KMS

Scenario: your KMS key is deleted, your cloud account is suspended, or the KMS is down for a long time.

Impact: Vault cannot start. If the key is deleted permanently, your secrets are permanently inaccessible, even from the backups; as long as access to the KMS can be restored, they become available again.

Mitigations:

  1. Regular backups of the Raft storage (the data stays recoverable if you regain access to the KMS)

  2. A documented migration procedure to another seal/KMS

  3. Strong governance on the KMS key: protection against accidental deletion, retention policy, restricted access

  4. Seal HA (Enterprise): several seals configured for resilience

Risk 2: compromise of the KMS

Scenario: an attacker gains access to the KMS.

Impact: they can decrypt the stored root key. If they also have access to the Vault storage, they can potentially decrypt the secrets.

Mitigations:

  • Restricted KMS access: strict IAM, least privilege
  • Audit logging: monitor every access to the KMS key
  • Regular KMS rotation: good hygiene, but it does not shorten the exploitation window of access already obtained. Previous key versions are kept and still decrypt what they encrypted (documented AWS KMS behaviour). In the face of a compromise, remove access to the KMS, then migrate to a new seal
  • Seal Wrap (Enterprise): additional encryption by an HSM at runtime

Risk 3: loss of the recovery keys

Scenario: the recovery keys are lost or inaccessible.

Impact: it becomes impossible to generate a new root token if needed. Vault keeps working but some emergency operations are blocked.

Mitigations:

  • Secure storage: physical safe, enterprise password manager
  • Several copies: spread among N people (threshold K for a rekey)
  • Regular testing: check that the recovery keys are accessible
  • Documentation: a clear procedure on who holds what

How do I configure each seal?

Pick the tab for your provider. Each shows the seal block, then the minimum permissions the Vault identity needs on the key.

seal "awskms" {
region = "eu-west-1"
kms_key_id = "alias/vault-unseal-key"
# Prefer an IAM role attached to the instance
# rather than hard-coded access_key/secret_key
}

Minimum IAM policy:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:eu-west-1:123456789:key/your-key-id"
}
]
}

Recommendation: use an IAM role attached to the EC2 instance or a Kubernetes service account with IRSA rather than static credentials.

How do I check that sealing works?

Once the seal block is in place and Vault restarted, the proof is read in vault status. Three fields matter: Seal Type shows the active mechanism (awskms, gcpckms, azurekeyvault, transit or shamir), Sealed must be false after the restart without anyone supplying a share, and Recovery Seal Type appears with auto-unseal as a reminder that recovery keys exist. A Sealed set to true after a restart means the KMS did not answer: check Vault's logs.

Terminal window
vault status

How do I migrate from one seal to another?

It is possible to migrate from one seal type to another.

From Shamir to auto-unseal

This is the typical migration: you start from manual unsealing with Shamir shares and move to automatic unsealing backed by a KMS. The point to remember before starting is that the migration turns the unseal keys into recovery keys: the documentation says the Shamir keys you supply are "migrated as the recovery keys" of the new seal. They serve one last time to authorise the switch, then no longer unseal anything: the KMS takes over. Vault does not generate new ones on this occasion. Keep them until the migration is fully validated, because they are now your recovery keys.

  1. Add the new seal in vault.hcl (in addition to the implicit Shamir):

    seal "awskms" {
    region = "eu-west-1"
    kms_key_id = "alias/vault-unseal-key"
    }
  2. Restart Vault: the server detects a pending migration

  3. Run the migration with the -migrate flag:

    Terminal window
    vault operator unseal -migrate
  4. Provide the existing Shamir unseal keys (threshold required)

  5. The Shamir shares you supplied become the recovery keys of the new seal

  6. Secure these recovery keys. There is nothing to remove: by default, Shamir has no seal block in vault.hcl. Once every node is migrated, just check that their configuration files carry only the new seal block

From one KMS to another

Changing cloud provider, or going from AWS KMS to GCP Cloud KMS, follows a different sequence on a detail that makes the migration fail if you miss it. You do not just add the new seal: you must mark the old one as disabled with disabled = true, without removing it yet. Vault needs the old seal to decrypt and the new one to re-encrypt. Another difference from the previous case: the recovery keys authorise the operation, since there are no Shamir shares any more.

  1. Mark the old seal disabled and add the new one in vault.hcl. The old block keeps its identification attributes (region, key): Vault needs them to decrypt.

    seal "awskms" {
    region = "eu-west-1"
    kms_key_id = "alias/vault-unseal-key"
    disabled = "true" # old one, kept for decryption
    }
    seal "gcpckms" {
    project = "my-project"
    region = "europe-west1"
    key_ring = "vault-keyring"
    crypto_key = "vault-unseal-key"
    }
  2. Restart Vault: migration detected

  3. Run the migration:

    Terminal window
    vault operator unseal -migrate
  4. Provide the existing recovery keys (threshold required)

  5. Once the migration has succeeded on every node, remove the old seal block from their configuration files

  6. Restart to validate the final configuration

Which checklist should I apply?

For Shamir

With Shamir unsealing, the risk is not technical but human: the root key is spread among several people, and a cluster stays inaccessible if the quorum cannot be gathered. The points below therefore read in two steps, the configuration of the shares first, then the governance of the holders. It is this second half that people forget, until the day a departure makes a share impossible to find.

  • Number of shares suited to the case (5 is the default of vault operator init)
  • Suited threshold (3 is the default for 5 shares)
  • PGP encryption of the unseal keys at initialization
  • Each share stored separately (different people/places)
  • Documented unsealing procedure
  • Periodic drills to check the ability to gather the quorum
  • Holders identified and reachable
  • Lifecycle management of the holders (departure, renewal)

For auto-unseal

With auto-unseal, unsealing becomes automatic, but Vault's availability now rests entirely on that of the KMS. The list below has two distinct goals: locking down access to the KMS key (least privilege, no clear-text secret) and guarding against its loss (anti-deletion protection, tested recovery keys, a plan B). The point most often neglected is the last one: what do you do if the KMS is unavailable for even an hour?

  • Dedicated KMS key (not shared with other services)
  • Minimum KMS access (least privilege)
  • No clear-text credentials in vault.hcl (cloud identity or env://)
  • Audit logging enabled on the KMS
  • Protection against accidental deletion of the KMS key
  • Recovery keys generated with PGP encryption
  • Recovery keys secured and tested
  • Documented migration procedure
  • Plan B if the KMS is unavailable (even temporarily)
  • KMS SLA checked and acceptable

Key points

  1. Shamir = full control, auto-unseal = automation: both have high security, but different trade-offs
  2. Recovery keys are not unseal keys: they do not unseal Vault, do not let you recover a cluster whose seal mechanism is permanently lost, and remain an administration key to protect
  3. For most deployments, auto-unseal offers a better operational experience than Shamir
  4. KMS dependency: a critical risk to assess and mitigate; permanently losing the KMS means permanently losing the cluster, even with backups
  5. Transit: a good alternative with no cloud dependency (but with an unsealer cluster to maintain)
  6. HSM and Seal HA: Enterprise features for advanced needs
  7. Never store seal credentials in clear text: use native cloud identities or indirect references
  8. Proof expected by SOCLE: the seal block configuration and a vault status that shows Sealed set to false after a restart with no human intervention prove the sealing part of SOCLE-SEC-STO-5 (in French); the audit and the separation of roles, the other parts of this requirement, are proven elsewhere (installation, policies)

Knowledge check

Check that the essentials of this lesson are in place. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

4 questions
4 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn