HashiCorp Cloud Platform
Copy leaked secrets into HashiCorp Vault
Vault Radar helps you identify leaked secrets in your code. You can start the remediation process by copying these secrets into a Vault.
Prerequisites
Before you begin, you need the following:
- The HCP Vault Radar agent v0.27.0 or greater is running and configured
- A HashiCorp Vault Enterprise or HCP Vault Dedicated cluster configured for the Vault Radar Agent
- A Datasource onboarded using the HCP Vault Radar agent
Resource Based Access Control (RBAC)
The copy secrets feature does support RBAC. A user can be assigned a Resource Contributor role to a specific Resource(s). When visiting the Vault Radar portal the user will only be allowed to copy secrets for the Resource(s) they have access to.
For more information on RBAC and how to configure it, see the Configure HCP user permissions documentation.
Vault configuration
Copying secrets into Vault requires the create, patch, and update
capabilities on the path where you want to copy secrets to.
This is an example policy that allows the Vault Radar agent to copy secrets to any secrets engine mount point.
# HCP Vault Radar agent correlation policy
path "*" {
capabilities = ["read", "list"]
}
# HCP Vault Radar copy secrets
path "secret/+/*" {
capabilities = ["create", "read", "list", "patch", "update"]
}
Update the policy used by the Vault auth method that authenticates the Vault Radar agent with Vault.
Configure a remediation action
Once you have the Vault Radar agent running and configured with a policy that permits writing to Vault, you can configure Vault Radar to import secrets.
Log into the HCP Portal
Click Vault Radar.
Click Settings.
Click Remediation.
Click the Actions tab
Click Create actions.

Verify your desired Vault cluster is in the list and click Next.

On the Create actions, click Download template to download an example CSV template.

Update the CSV file to match the values for your environment. The template includes the following columns:
- Resource: The URL of one or more data sources HCP Vault Radar scans for leaked secrets.
- Secret manager: The location of the HCP Vault Dedicated or Vault Enterprise cluster, and the namespace where Vault Radar will copy the secrets. More information here.
- Secret manager location: The path of the secrets engine where Vault Radar will copy the secrets. More information here.
Click Choose File and select the completed form.
Click Upload and check content format.

This shows you a report that includes any validation errors that may exist. Fix any reported errors and re-upload the form.
Click Finish.
Copy secrets to secret manager
With the Vault Radar actions configured, you can begin copying secrets into Vault.
Navigate to the Events page and select one or more events you'd like to remediate.

Select the Store in secret manager button to open a flyout menu.

Populate the flyout menu with one or more key names for the selected events.
Verify the Store at location for the target secret manager. You can edit the value if you want to store the secret in a different location.

Click Confirm to start the copy operation.
The copying will happen in the background. A notification banner should appear at the top of the page to indicate the operation was successful.
Select a remediated event to see the managed location fields. You can also view the secret in Vault to confirm it was copied to the defined path.

Resource
The resource column is expecting a URI to a data source.
For git repositories, expects a URL including the protocol, domain, and respository.
git://<domain/path-to-repository>/<repository-name>.git
Example:
git://github.com/hashicorp/vault.git
Secret manager
The secret manager column expects a URI to a secret manager configured, including the port and namespace.
vault://<vault-cluster-url>:8200/<namespace>
Example:
vault://vault-cluster.hashicorp.com:8200/admin
Secret manager location
The secret manager location column is expecting a delimited string that is going to act as the top level directory for any secret that is copied and belongs to the resource defined in the first column.
The string needs to be in the format:
kv/<mount-path>/secret-path/<path-to-secret>
Example:
kv/secret/secret-path/secrets-for-resource