vault-kv-search is a command-line tool for recursively searching for secrets within HashiCorp Vault's Key-Value (KV) stores (versions 1 and 2). It helps you quickly find where a specific value, key, or path is located across many secrets, making it an essential utility for auditing and managing your Vault environment.
- Recursive Search: Traverses nested paths in Vault to find secrets.
- Multi-Target Search: Search within secret values, keys, or paths.
- Regex & Case-Insensitive Support: Use regular expressions (
-r) and case-insensitive matching (-i) for flexible search patterns. - Bounded Concurrency & Rate Limiting: Configurable worker pool (
-c) and crawling delay (-d) for fast, safe searches. - Graceful Permission Handling: Automatically skips paths returning
403 Permission Deniedand reports skipped counts in the summary. - Match Highlighting: Highlights matched substrings in terminal output (respecting
NO_COLORand--no-color). - Interactive Guided Prompt: Run with no arguments in a terminal (or
--interactive) for a guided store and query prompt. - KV v1 and v2 Support: Works seamlessly with both versions of the KV secrets engine.
- Multiple Output Formats: Choose between human-readable text and structured
jsonoutput. - Cross-Platform: Builds for Linux, macOS, and Windows.
- Search All Stores: Can automatically discover and search all mounted KV stores.
brew install xbglowx/tap/vault-kv-searchHomebrew keeps the formula updated when a new release is published.
You can download the latest pre-compiled binaries for your operating system from the GitHub Releases page.
- Download the appropriate binary for your system (e.g.,
vault-kv-search-linux-amd64). - Make the binary executable:
chmod +x vault-kv-search-* - (Optional) Move it to a directory in your
PATHfor easy access:sudo mv vault-kv-search-* /usr/local/bin/vault-kv-search
The tool requires a Vault server address and authentication token, configured via CLI flags (--vault-addr, --vault-token), environment variables (VAULT_ADDR, VAULT_TOKEN), or ~/.vault-token:
export VAULT_ADDR="https://your-vault-server:8200"
export VAULT_TOKEN="s.YourVaultToken"You may also pass --skip-verify or set VAULT_SKIP_VERIFY=true if your Vault instance uses a self-signed certificate, and NO_COLOR=1 (or pass --no-color) to disable ANSI color output.
Usage:
vault-kv-search [flags] [search-path] substring
Flags:
-c, --concurrency int Number of concurrent Vault workers (default 10)
-d, --delay int Crawling delay in milliseconds (default 15)
-e, --exit-code Return exit code 1 when no matches are found
-h, --help help for vault-kv-search
-i, --ignore-case Perform case-insensitive matching
--interactive Launch interactive guided search prompt
-j, --json Output as JSON
-k, --kv-version int KV version (1,2). Autodetect if not defined
--no-color Disable colored output and match highlighting
-r, --regex Enable searching regex substring
--search strings Which Vault objects to search against. Choices are any and all of the following 'key,value,path'. Can be specified multiple times or once using format CSV. Defaults to 'value' (default [value])
-s, --showsecrets Show secrets values
--skip-verify Skip TLS certificate verification (overrides VAULT_SKIP_VERIFY)
-t, --timeout int Vault client timeout in seconds (default 30)
-a, --vault-addr string Vault server address (overrides VAULT_ADDR)
--vault-token string Vault authentication token, @file, or file path (overrides VAULT_TOKEN and ~/.vault-token)
-
Search values for a substring:
vault-kv-search secret/production/ "api.example.com" -
Search keys for a substring:
vault-kv-search --search=key secret/ "username" -
Search both keys and values:
vault-kv-search --search=key --search=value secret/ "database" -
Search using a regular expression:
vault-kv-search --regex secret/ "^db-" -
Search for a secret by its path (name):
vault-kv-search --search=path secret/ "ssh-keys" -
Search all mounted KV stores at once: This requires permissions to list mounts.
vault-kv-search "sensitive-data" -
Show the secret value in the output:
vault-kv-search --showsecrets secret/ "password123" -
Output results in JSON format:
vault-kv-search --json secret/ "user@example.com" -
Case-insensitive search with custom worker concurrency:
vault-kv-search -i -c 20 secret/ "apikey" -
Return non-zero exit code (
1) when no matches are found (for scripts/CI):vault-kv-search --exit-code secret/ "deprecated-host" -
Launch interactive guided search prompt:
vault-kv-search --interactive
-
Specify Vault address and token via CLI flags (literal token,
@file, or file path):vault-kv-search -a https://vault.example.com:8200 --vault-token @~/.vault-token-prod secret/ "db-host"
Prerequisites:
- Go version specified in
go.mod - Make
To build the binary from the source code:
make vault-kv-searchThe compiled binary will be available in the root of the project directory.
Tests use testcontainers-go to automatically start and stop Vault containers, providing complete isolation and eliminating the need for manual container management.
Prerequisites:
- Docker (Docker Desktop, Colima, or similar)
make testIf you're using Colima instead of Docker Desktop, you need to set the following environment variables:
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"
export TESTCONTAINERS_RYUK_DISABLED=true
make testYou can add these exports to your shell profile (~/.zshrc or ~/.bashrc) to make them persistent.
This project is licensed under the MIT License. See the LICENSE file for details.