With every dynamic secret and service
type authentication token, Vaultcreates a lease: metadata containing information such as a time duration,renewability, and more. Vault promises that the data will be valid for thegiven duration, or Time To Live (TTL). Once the lease is expired, Vault canautomatically revoke the data, and the consumer of the secret can no longer becertain that it is valid.
The benefit should be clear: consumers of secrets need to check in withVault routinely to either renew the lease (if allowed) or request areplacement secret. This makes the Vault audit logs more valuable andalso makes key rolling a lot easier.
All dynamic secrets in Vault are required to have a lease. Even if the data ismeant to be valid for eternity, a lease is required to force the consumerto check in routinely.
In addition to renewals, a lease can be revoked. When a lease is revoked, itinvalidates that secret immediately and prevents any further renewals. Forexample, with the AWS secrets engine, theaccess keys will be deleted from AWS the moment a lease is revoked. Thisrenders the access keys invalid from that point forward.
Revocation can happen manually via the API, via the vault lease revoke
cli command,the user interface (UI) under the Access tab, or automatically by Vault. When a leaseis expired, Vault will automatically revoke that lease. When a token is revoked,Vault will revoke all leases that were created using that token.
Note: The Key Value Backend which storesarbitrary secrets does not issue leases although it will sometimes return alease duration; see the documentation for more information.
When reading a dynamic secret, such as via vault read
, Vault always returns alease_id
. This is the ID used with commands such as vault lease renew
and vault lease revoke
to manage the lease of the secret.
Lease durations and renewal
Along with the lease ID, a lease duration can be read. The lease duration isa Time To Live value: the time in seconds for which the lease is valid. Aconsumer of this secret must renew the lease within that time.
When renewing the lease, the user can request a specific amount of time theywant remaining on the lease, termed the increment
. This is not an incrementat the end of the current TTL; it is an increment from the current time. Forexample, vault lease renew -increment=3600 my-lease-id
would request that the TTL of the leasebe adjusted to 1 hour (3600 seconds). Having the increment be rooted at thecurrent time instead of the end of the lease makes it easy for users to reducethe length of leases if they don't actually need credentials for the fullpossible lease period, allowing those credentials to expire sooner andresources to be cleaned up earlier.
The requested increment is completely advisory. The backend in charge of thesecret can choose to completely ignore it. For most secrets, the backend doesits best to respect the increment, but often limits it to ensure renewals everyso often.
As a result, the return value of renewals should be carefully inspected todetermine what the new lease is.
To implement token renewal logic in your application code, refer to the code example in the Authentication doc.
In addition to revoking a single secret, operators with proper access controlcan revoke multiple secrets based on their lease ID prefix.
Lease IDs are structured in a way that their prefix is always the path wherethe secret was requested from. This lets you revoke trees of secrets. Forexample, to revoke all AWS access keys, you can do vault lease revoke -prefix aws/
.For more information about revoke command please checkcli's lease revokecommand docs.
This is very useful if there is an intrusion within a specific system: allsecrets of a specific backend or a certain configured backend can be revokedquickly and easily.