Skip to content

Policies

  • Vault policies permit or deny access to certain paths or actions within vault (RBAC).
  • Provides granular control over who accesses what.
  • Policies are default deny (Implicit deny), which means no policy no access.
  • Policies are attached to tokens and tokens can have multiple policies attached.
  • Policies are cumulative and capabilities are additive.
CommandEffect
vault policy listList all policies
vault policy write POLICY_NAME POLICY_FILE_PATHCreate a policy
vault policy read POLICY_NAMERead a policy
vault policy delete POLICY_NAMEDelete a policy
vault policy fmt POLICY_FILE_PATHFormats policy file according to syntax
  • Structure of policy looks like:
path "PATH" {
capabilities = ["LIST_OF_CAPABILITIES"]
}
path "PATH" {
capabilities = ["LIST_OF_CAPABILITIES"]
}
path "PATH" {
capabilities = ["LIST_OF_CAPABILITIES"]
}
...

Example:

path "kv/data/apps/cicd" {
capabilities = ["read", "update", "delete"]
}
path "sys/policies/*" {
capabilities = ["create", "update", "list", "delete"]
}
path "aws/creds/webapp" {
capabilities = ["read"]
}
  • There are root protected paths which are available to only root user and must not be exposed to other users unless until required, some of them are here:
    • auth/token/create-orphan
    • pki/root/sign-self-issued
    • sys/rotate
    • sys/seal
    • sys/step-down
  • This is how to provide access to users to protected paths:
path "PROTECTED_PATH" {
capabilities = ["sudo"]
}
*
  • * is a wildcard and can only be used at the end of at the end of a path. It can be used to signify anything “after” a path or as a pattern. Ex: /.../.../...* or /.../.../*.
  • It also matches all the sub paths and sections beyond it as well.
  • + supports wildcard matching for single section in the path.
  • Can be used in between the path.
  • Can be used multiple times. Ex: /.../+/... or /.../+/+/.../+/....
  • Use variable replacement in some policy strings with values available to the token.
  • Define policy paths using double curly brackets.
path ".../{{VARIABLE_REFERENCE}}/*" {
capabilities = ["LIST_OF_CAPABILITIES"]
}
  • create,list,read,update,delete are capabilities that work as per their names.
  • sudo capability allows access to protected paths.
  • deny disallows access irrespective of any other granted access and capabilities.