Skip to content

Secret Auto-Rotation

Secret Rotation

VaultLens can automatically rotate KV v2 secret values on a schedule, using Vault's native custom metadata to store rotation configuration alongside the secret itself.

Enabling Rotation

Add these keys to a KV v2 secret's custom metadata:

KeyRequiredExampleDescription
rotate-intervalYes7dHow often to rotate (see formats below)
rotate-formatNoalphanumericGenerated password format

Interval Formats

FormatExampleDescription
Days7dEvery 7 days
Hours24hEvery 24 hours
Minutes30mEvery 30 minutes
Weeks2wEvery 2 weeks

Password Formats

FormatDescription
alphanumeric (default)Letters and digits
hexHexadecimal characters
base64Base64 characters
numericDigits only

Rotation Scheduler

VaultLens checks for eligible secrets every 60 seconds at startup. A secret is eligible for rotation if:

  1. Its custom metadata contains rotate-interval
  2. The elapsed time since last rotation (or creation) exceeds the interval

When a secret rotates, VaultLens generates a new random value using rejection sampling and writes it to the secret using the system token. A new KV v2 version is created, preserving all previous versions.

Rotation Status

View the rotation scheduler status and recent rotation events under Admin → Secret Rotation.

The page shows:

  • Scheduler enabled/disabled state
  • Last check time and next scheduled check
  • List of secrets registered for rotation with their intervals
  • Manual rotation trigger button (for testing)

Manual Rotation

Click Rotate Now on any registered secret to immediately rotate it, regardless of its scheduled interval.

Notes

  • Rotation uses the system token to read and write secrets — it operates independently of any logged-in user
  • Only KV v2 secrets support custom metadata (and therefore auto-rotation)
  • Rotation generates a new password field value; all other fields in the secret are preserved

Released under the GPL-3.0 License.