Skip to content

003 · Domain 2: Vault policies · 13% of the exam

Task 2.2: Describe Vault policy syntax: path

Exact paths, the * glob at the end and the + segment wildcard, priority between matching paths, KV v2 data and metadata paths, and templated paths.

Study it

  • Policy paths: exact paths, the * glob, the + wildcard and priority

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.

Question 1 · choose 1

A token's only policy is: path "secret/data/+/config" { capabilities = ["read"] } Which read does it allow?

  1. Asecret/data/billing/config
  2. Bsecret/data/billing/eu/config
  3. Csecret/data/config
  4. Dsecret/metadata/billing/config
Show the answer and why
  • Asecret/data/billing/config

    Correct

    + stands for any characters within exactly one path segment, here billing.

  • Bsecret/data/billing/eu/config

    Incorrect

    billing/eu spans two segments, and + covers only one.

  • Csecret/data/config

    Incorrect

    The policy needs one segment between data/ and config; this path has none.

  • Dsecret/metadata/billing/config

    Incorrect

    The policy names the data/ prefix; metadata/ is a different path.

+ is a single-segment wildcard that can appear anywhere in a path and matches exactly one segment, never zero or several.

Question 2 · choose 1

A token carries two policies: # policy team-rw path "secret/data/team/*" { capabilities = ["create", "read", "update"] } # policy prod-ro path "secret/data/team/+/prod" { capabilities = ["read"] } What happens when the token writes to secret/data/team/billing/prod?

  1. AIt succeeds, because Vault unions create, read and update from both matching paths
  2. BIt is denied, because the + path is the higher-priority match and allows only read
  3. CIt succeeds, because a path ending in a * glob outranks a path with a + segment
  4. DIt succeeds, because the policy attached to the token first takes precedence
Show the answer and why
  • AIt succeeds, because Vault unions create, read and update from both matching paths

    Incorrect

    Vault unions capabilities only when the same pattern appears in several policies; for different patterns it takes the highest-priority match.

  • BIt is denied, because the + path is the higher-priority match and allows only read

    Correct

    Both wildcards start at the same place, and a pattern ending in * ranks below one that does not, so only prod-ro's rule applies.

  • CIt succeeds, because a path ending in a * glob outranks a path with a + segment

    Incorrect

    The priority rules work the other way: a pattern that ends in * is lower priority than one that does not.

  • DIt succeeds, because the policy attached to the token first takes precedence

    Incorrect

    The order in which policies are attached plays no part in matching.

With several matching patterns, Vault picks one by its priority rules: earlier wildcards, a trailing *, more + segments and shorter paths all rank lower. Capabilities are merged only for identical patterns.

Question 3 · choose 1

Every user's entity carries the metadata key team, for example team=payments. One policy, attached to all users, must let each of them read secrets under secret/data/teams/<their team>/ on a KV v2 mount. Which policy path does it?

  1. Asecret/data/teams/{{identity.entity.name}}/*
  2. Bsecret/data/teams/{{identity.entity.team}}/*
  3. Csecret/data/teams/{{identity.groups.names.team.id}}/*
  4. Dsecret/data/teams/{{identity.entity.metadata.team}}/*
Show the answer and why
  • Asecret/data/teams/{{identity.entity.name}}/*

    Incorrect

    This injects the entity's own name, so each user would get a path of their own rather than their team's.

  • Bsecret/data/teams/{{identity.entity.team}}/*

    Incorrect

    There is no identity.entity.team parameter; entity metadata is reached through identity.entity.metadata.<key>.

  • Csecret/data/teams/{{identity.groups.names.team.id}}/*

    Incorrect

    This injects the ID of a group named team, the same value for every user, not each user's team.

  • Dsecret/data/teams/{{identity.entity.metadata.team}}/*

    Correct

    identity.entity.metadata.<key> injects the value stored under that metadata key of the requesting entity.

Templated policies replace identity parameters with values of the requesting entity, its aliases or its groups, so one policy can serve many users.

Question 4 · choose 1

A policy contains path "secret/foo" with capabilities = ["read"] on a KV version 1 mount. Which read is allowed?

  1. Asecret/foo and secret/foo/bar
  2. Bsecret/foo and secret/food
  3. Csecret/foo only
  4. DEvery path under secret/
Show the answer and why
  • Asecret/foo and secret/foo/bar

    Incorrect

    Matching children needs a glob such as secret/foo/*.

  • Bsecret/foo and secret/food

    Incorrect

    Partial matches need a trailing *.

  • Csecret/foo only

    Correct

    A path with no wildcard is an exact match.

  • DEvery path under secret/

    Incorrect

    Only the named path is covered.

Exact paths are the narrowest grant; add * or + only where a wider match is intended.

Question 5 · choose 1

A policy author writes path "secret/data/*/config" expecting it to cover the config secret of every application. What is wrong?

  1. AA * acts as a glob only as the final character, never mid-way
  2. BPolicy paths must not start with a mount name such as secret/, only with the API path after it
  3. CNothing, but the rule needs the list capability to take effect
  4. DNothing; * matches one segment wherever it appears
Show the answer and why
  • AA * acts as a glob only as the final character, never mid-way

    Correct

    The glob is not a regular expression and is supported only at the end of a path.

  • BPolicy paths must not start with a mount name such as secret/, only with the API path after it

    Incorrect

    Policy paths include the mount path.

  • CNothing, but the rule needs the list capability to take effect

    Incorrect

    list allows listing; it does not change how the path matches.

  • DNothing; * matches one segment wherever it appears

    Incorrect

    That is not how * works; it is not a segment wildcard.

The glob character is not a regular expression and works only as the last character of a policy path, so check every rule that places * anywhere else.

Question 6 · choose 1

A platform team's policy must allow its members to enable a secrets engine at db/ and nothing else in Vault's configuration. Which path does the policy name?

  1. Adb/*
  2. Bsys/mounts/db
  3. Csys/auth/db
  4. Dsys/policy/db
Show the answer and why
  • Adb/*

    Incorrect

    db/* covers requests to the engine once it exists, not the request that enables it.

  • Bsys/mounts/db

    Correct

    Secrets engines are enabled through sys/mounts/<path>, and every action, internal configuration included, has a path a policy can name.

  • Csys/auth/db

    Incorrect

    sys/auth/<path> enables auth methods, not secrets engines.

  • Dsys/policy/db

    Incorrect

    sys/policy stores ACL policies.

Even core configuration lives under sys/, so policies control it the same way they control secrets.

Practice domain 2 →Practice all domains →