list, sudo, deny—and explore wildcards, ACL templates, and policy testing. By the end, you’ll know how to craft precise, secure policies using glob patterns and variable interpolation.
Core Capabilities Overview
Vault policy capabilities are declared as lists of strings within eachpath block. Here’s a quick reference:
| Capability | Description |
|---|---|
| create | Add a new secret or configuration (fails if it exists) |
| read | Retrieve secrets, configurations, or policies |
| update | Overwrite an existing entry (fails if missing) |
| delete | Remove a secret or configuration |
| list | Enumerate keys under a path (without revealing values) |
| sudo | Required for root-protected endpoints (e.g., seal, rekey) |
| deny | Explicitly blocks access to a path (highest precedence) |
There is no generic
write capability in Vault. Use create or update depending on whether the path should already exist.The
deny capability always takes precedence over any granted rights. Use it carefully to lock down sensitive paths.Example 1: Simple CRUD Policy
Grant:- Read access to
database/creds/dev-db01. - Full CRUD on
kv/apps/dev-app01.
- For KV v2, prefix paths with
data/(e.g.,path "data/kv/apps/dev-app01"). - A single policy can include multiple
pathblocks; tokens inherit all rules.
Example 2: Glob Patterns with Explicit Deny
Grant read acrosskv/apps/webapp/ but block super_secret:
- The glob
webapp/*matches all child paths—not the directory itself. denyonsuper_secretoverrides any read rights.
Pop Quiz
-
Does
kv/apps/webapp/*allow access tokv/apps/webapp(no trailing slash)?
No. The glob only matches subpaths after the slash. -
Can a user browse the UI down to
webapp?
Not withoutliston the parent paths (kv/,kv/apps/,kv/apps/webapp).
Example policy to enable UI navigation:
Wildcards in Policy Paths
Vault supports two wildcard patterns:- Asterisk (
*) at the end of a path segment (glob). - Plus (
+) replacing exactly one path segment.
Asterisk (*) Globs
Plus (+) Wildcards
Wildcards can inadvertently grant broader access. Always test your patterns to ensure they match only the intended paths.
ACL Templates (Variable Interpolation)
Use Vault templates to inject dynamic values:{{identity.entity.id}} at runtime, generating per-user policies automatically. Other templates include identity.entity.name, group IDs, and more.
Assigning and Testing Policies
-
Create a policy (e.g.,
web-app) via the Vault CLI or API. -
Issue a token bound to that policy:
Example output: Key Value
token hvs.7uBlZwXSxOg31uGXIUetEdXD token_accessor 18r88muoe3x1xEqVqXdlTMwJ token_duration 8h token_renewable true token_policies [“default” “web-app”] identity_policies [] -
Test with the new token:
Example: Administrative Policy
Operators require access to system (sys/) endpoints. Sample admin policy:
Mastering Vault policies—capabilities, wildcards, and templates—is essential for robust RBAC. Practice in a dev environment to solidify your understanding.