Vault Policies · Topic 1 of 3
The Value of Vault Policies
Vault Associate (003): why Vault policies matter, deny by default, the built-in root and default policies, and how policies attach to tokens.
- 4 min
- Policies are written in HCL or JSON and are path based.
- Vault is deny by default; no policy means no access.
rootanddefaultare built in, and neither can be removed.
What it is
A Vault policy is a set of rules that says which paths a client may use and what it may do there. Policies control access to the secrets Vault manages.
Every Vault client, whether a person, an application or a container, needs a valid token to send authenticated requests. The policies on that token decide what the request is allowed to do.
How it works
Why policies are valuable
Everything in Vault is addressed by a path, including internal sys/ endpoints. A policy grants or forbids operations on those paths, so one mechanism protects secrets, auth methods and Vault's own administration.
Policies give you:
- Least privilege: each client gets only the paths it needs.
- Separation of duties: an application can read its secrets while only an administrator can change auth methods or policies.
- Central control: rules live in Vault, not in each application.
- Immediate effect: policy contents are evaluated on each use, so an edit applies to tokens that already exist.
Deny by default
Policies are deny by default, so an empty policy grants no permission. A client with no policy that covers a path has no access to it.
path "secret/data/app/*" {
capabilities = ["read"]
}
With only this policy, a token can read paths under secret/data/app/. Writing there is denied, and so is every other path, because nothing grants it.
Built-in policies
| Policy | Behavior |
|---|---|
root | Cannot be modified or removed. A token with it can do anything in Vault. |
default | Cannot be removed. Attached to tokens by default and grants basics such as looking up the token itself and using its cubbyhole. |
Operators can modify default, and Vault will not overwrite those changes. A token can be created without it by using the -no-default-policy option.
The root policy is attached to the root token. HashiCorp strongly recommends revoking root tokens before production use. To see what default allows on your own installation, read it with vault read sys/policy/default.
How policies reach a token
Policies attach to a token after authentication. With userpass, they are set on the user. With other auth methods, they are usually associated with a role or a mapping.
The list of policies on a token is set when the token is created and cannot be changed afterward. What each policy allows is checked in real time on every request, so editing a policy changes what existing tokens can do.
If a policy is deleted, a token that held it is treated as having an empty policy for that name.
Identity policies add to the token
Policies on an entity or group add to the token's own. This lets you grant extra access to many clients without reissuing their tokens.
Policies and Enterprise features
Namespaces, Sentinel policies and control groups are Vault Enterprise features. This exam objective concerns the ACL policies described on these pages.
How the exam asks about this
- "A new token has no policies that cover
secret/data/hr. What can it do there?" Nothing, because Vault is deny by default. - "Which built-in policy is attached to tokens by default?"
default. - "An administrator edits a policy. Do existing tokens change?" Yes, the new rules apply at the next request, because policies are evaluated in real time.
What to remember for the exam
- Policies are written in HCL or JSON and are path based.
- Vault is deny by default; no policy means no access.
rootanddefaultare built in, and neither can be removed.rootcannot be modified;defaultcan be edited but not deleted.- Token policies are fixed at creation, while policy contents are evaluated live.
- Revoke root tokens once they are no longer needed.
An empty or missing policy is not a problem to fix by granting broad access. The safe state is deny; add only the capabilities and paths a client needs.
Common mistakes
Thinking the default policy can be removed. It can be edited but not deleted, and it is attached to new tokens unless you opt out.
Believing a policy edit requires new tokens. Contents are checked on each request, so edits apply to existing tokens. Only the set of policy names on a token is fixed.
Treating policies as an allow list plus a deny list. Policies are deny by default, so you only list what is allowed. The deny capability is for blocking something a broader rule would otherwise allow.
Check yourself
What does it mean that Vault policies are deny by default?
Unless a policy explicitly grants a capability on a path, the request is refused, so an empty policy grants no access.
Which two policies are built in?
root, which can do anything and cannot be changed or removed, anddefault, which gives basic self-service capabilities and cannot be removed.If you add a new path to a policy, do existing tokens with that policy gain access?
Yes, because policy contents are evaluated on each request, even though the list of policies on a token cannot be changed after creation.
Topic 1 of 3 in Vault Policies
Test yourself on Vault Policies
The full HashiCorp Vault Associate 003 question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.