12.4 Vault Secrets: Versions, Rotation States, Automatic Generation & Rotation
Key Takeaways
A Vault secret is encrypted with a symmetric master encryption key, and its contents are sent to the service base64-encoded.
Secret versions can be marked current, pending, latest, previous, or deprecated, and only deprecated versions can be deleted.
Automatic secret rotation can run on an interval from 1 to 12 months and integrates with Autonomous AI Database and OCI Functions.
A rotation function runs four steps: VERIFY_CONNECTION, CREATE_PENDING_VERSION, UPDATE_TARGET_SYSTEM, and PROMOTE_PENDING_VERSION.
Applications on compute instances can read secrets with instance principals, and functions can read them with resource principals, so no credentials are stored on the host.
Why Secrets Belong in Vault
Hardcoded passwords in source code, container images, or environment files are among the most common causes of breaches. Vault secrets keep credentials in a managed, audited store:
- A secret is encrypted with a master encryption key from a vault, and that key must be symmetric (AES).
- Secret contents are base64-encoded before they are sent to the service. The Console lets you type plain text and encodes it for you.
- Access is controlled with IAM on the
secret-familyresources, such asread secret-bundlesfor applications that only need to retrieve values, and every access is recorded by Audit.
Retrieving Secrets Without Stored Credentials
Applications should authenticate to Vault with an OCI identity rather than a stored API key:
| Workload | Identity used | Example policy |
|---|---|---|
| Compute instance | Instance principal (instance in a dynamic group) | Allow dynamic-group app-servers to read secret-bundles in compartment Secrets |
| OCI Function | Resource principal (resource.type = 'fnfunc') | Allow dynamic-group fn-apps to read secret-bundles in compartment Secrets |
| OKE pod | Workload identity or the Secrets Store CSI driver | A policy conditioned on the cluster, namespace, and service account |
| Container Instance | Registry credentials stored as a Vault secret | Used to pull images from private registries |
The application calls the Secrets API at run time to read the current version, often caching it briefly.
Secret Versions and Rotation States
A secret is a container for one or more secret versions. Each version can carry one or more rotation states:
| State | Meaning |
|---|---|
| Current | The version applications receive by default |
| Pending | A new version uploaded but not yet promoted, for example during rotation |
| Latest | The most recently created version |
| Previous | The version that was current immediately before the most recent rotation |
| Deprecated | A version that is not current, pending, or previous |
When a secret is first created, its single version is both current and latest. During rotation, a new version is added as pending, and applications keep using current until the pending version is promoted. Any version other than a deprecated one can be marked current again to roll back, and only deprecated versions can be deleted.
Automatic Secret Generation
Since February 2024, Vault can generate secrets for you, such as passwords and SSH keys, using templates that define the format, so humans never see or choose the value. The Console shows whether a secret is auto-generated and auto-rotated, and work requests let you track secret operations.
Automatic Secret Rotation
Automatic rotation changes a secret on a schedule with an interval from 1 to 12 months. It integrates with Autonomous AI Database and OCI Functions, so the new value is applied to the target system and not just stored in Vault.
The Rotation Function Contract
For a target that a function updates, Vault calls the function with the secret OCID, the current version number, and a step. The function must implement four steps:
- VERIFY_CONNECTION: confirm the existing credentials in the secret still work against the target system.
- CREATE_PENDING_VERSION: create a new pending secret version (or reuse an existing pending version).
- UPDATE_TARGET_SYSTEM: change the credential on the target system to the pending value.
- PROMOTE_PENDING_VERSION: move the pending version to current.
If a step fails, for example because the database cannot be reached during UPDATE_TARGET_SYSTEM, the pending version is never promoted. Applications keep using the unchanged current version, so a failed rotation does not lock them out.
Pre-Built Rotation Functions
Oracle provides pre-built functions in OCI Functions for database credentials: Database Secret Rotation with Wallet (mutual TLS to the database) and Database Secret Rotation without Wallet (TLS). When you create one from the Pre-Built Functions page, OCI Functions can create the dynamic group and IAM policy the function needs. You must also allow the Vault secret rotation service to invoke the function, and the database must allow network access from the function's application subnet.
Common Mistakes
- Encrypting a secret with an asymmetric key: secrets require a symmetric master encryption key.
- Giving applications
manageinstead ofreadpermissions on secrets, which lets a compromised application change or delete them. - Caching a secret value forever, so a rotated password breaks the application until it restarts.
- Rotating the value in Vault without changing it in the target system. Automatic rotation with a rotation function avoids this, because the target is updated before the new version becomes current.
Designing for Rotation
- Store one credential per secret, and point applications at the secret OCID rather than a version number.
- Make applications re-read the secret when authentication fails, so they pick up a newly promoted version.
- Use separate secrets for each environment and region, and replicate or recreate them in the DR region alongside the keys that encrypt them.
- Restrict
manage secret-familyto the security team, and give applications onlyread secret-bundles.
During an automatic rotation, the rotation function creates a pending version but cannot reach the database to change the password. What is the state of the secret afterward?
The new value becomes current at once, so applications fail until someone fixes the database
The new value stays pending and the current version is unchanged, so logins keep working
Vault deletes the secret and disables its master encryption key to prevent misuse
All versions are marked deprecated until the next scheduled rotation runs
A security engineer wants to delete old versions of a secret that was rotated several times. Which versions can be deleted?
Any version, including the current version, as long as a backup exists
Only the version marked previous
Only versions marked deprecated
Only versions created more than 12 months ago
An application on compute instances must read a database password from Vault without any API key or password stored on the instances. What should the architect configure?
An API signing key stored in the application's config file, with a policy to read secrets
A public bucket holding the password, protected by a pre-authenticated request
A Bastion session that injects the password into the instance at every boot
A dynamic group for the instances, a read secret-bundles policy, and instance principals
Sections you finish are checked off in the contents.