Azure Key Vault secret has no expiration date

Set a rotation deadline and replace credentials before it.

Description

Set attributes.exp on a Key Vault secret to its intended expiry in Unix seconds. An authorized reader can still retrieve an expired secret.

Potential impact

An exposed credential may remain usable while the issuing service still accepts it.

Remediation

Replace the credential before expiry and store the new value in Key Vault. Verify that apps connect with the replacement before revoking the old credential at its issuer.

Examples

Declare or reference the parent vault keyVault1. The second excerpt changes the secret’s name, value and attributes. To update only the expiry, keep the existing name and other attributes, pass the existing value through a secure parameter, and set expirationTimestamp.

Before

bicep
resource keyVault1_secretid1 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = {
  parent: keyVault1
  name: 'secretid1'
  properties: {
    value: 'string'
    contentType: 'string'
  }
}

After

bicep
param expirationTimestamp int

resource keyVault1_keyVaultSecret1 'Microsoft.KeyVault/vaults/secrets@2016-10-01' = {
  parent: keyVault1
  name: 'keyVaultSecret1'
  properties: {
    value: 'secretValue'
    attributes: {
      enabled: true
      nbf: 1585206000
      exp: expirationTimestamp
    }
  }
}

References