Each policy file in config/policies/*.yaml defines one rule that governs
how VaultKit handles a request. A policy has four parts:
Policies match fields by their labels in datasets/registry.yaml: each field’s
sensitivity (high, medium, low or unknown) and its category, which
policies see as a tag. vkit scan suggests labels; review them before deploying.
unknown means the scanner couldn’t place a column that could hold anything,
such as payload (jsonb) or notes (text). Give it a real label once you know
what it holds. Until then, the starter pack masks it for agents. A rescan
replaces an unknown label, but keeps labels you’ve set.
vkit policy bundle rejects a policy that can never match, for example one that
uses a tag no field can have.
id: <string> # REQUIRED: unique policy ID
description: <string> # REQUIRED: clear explanation of the rule
priority: <integer> # OPTIONAL: see "Which policy wins"
match: # OPTIONAL: which data this policy applies to
dataset: <dataset_name> # a dataset in datasets/registry.yaml
fields: # matches if ANY of these conditions holds
sensitivity: high | medium | low | unknown
contains: [<tag>, <tag>] # a requested field has ANY of these tags
any: [field1, field2] # ANY of these fields is requested
all: [field1, field2] # required as well: ALL of these are requested
usage: row | aggregate # OPTIONAL: only fields read value by value (row,
# MIN/MAX included) or only counted, summed,
# averaged or grouped by (aggregate). 0.12.0-alpha
context: # OPTIONAL: like `context` below, plus time
time:
after: "HH:MM"
before: "HH:MM"
context: # OPTIONAL: who is asking, and where
environment: production | staging | development | sandbox # the datasource's
dataset_region: EU | US | CA | APAC # the datasource's
requester_role: <role> # admin, member, approver, an approval group,
# or agent (the default for agent tokens)
requester_clearance: low | medium | high # set by an admin on the user or token
requester_region: EU | US | CA | APAC # set by an admin on the user or token
action: # REQUIRED: exactly one of these is true
deny: true
require_approval: true
mask: true
allow: true
approver_role: <group> # REQUIRED with require_approval: one group, or
approver_roles: [<group>, ...] # several groups (0.12.0-alpha, vkit 1.5.0), with
approval_mode: all | any # all (default): each signs off; any: one does
# Groups can't be admin, member, approver or
# agent: those are built-in roles (vkit 2.0.0)
reason: <string> # REQUIRED with deny and require_approval
ttl: "1h" # OPTIONAL: how long the grant lasts
masking: # OPTIONAL, with mask
default_method: full | partial | hash
The tags the classifier assigns are pii, financial, credential,
internal and unknown. You can use your own by setting category on fields in
datasets/registry.yaml.
Admins set a clearance and a region on each user (Team, Edit member) and agent token. Requests can’t claim their own, so policies can rely on them, for example for data residency:
context:
requester_region: US
dataset_region: EU
A policy that names a clearance or region doesn’t match a requester without one.
There’s no “not equal”, so to restrict everyone below a level, match the levels
you want to restrict (for example one policy each for low and medium).
Requires a control plane with admin-set clearance and region.
When your customers’ rows share tables, keyed by a column like
organization_id, mark those datasets in datasets/registry.yaml:
tickets:
datasource: app
tenant_column: organization_id
fields:
organization_id: { type: uuid, sensitivity: low, category: internal }
Then issue each agent session a token for one tenant:
vkit agents tokens create --name support-assistant --tenant org_42 --expires-in 1h
Every query that reads a tenant-scoped dataset, as its source or through a
join, is confined to the token’s tenant. VaultKit adds
organization_id = 'org_42' to the query, ANDed with the agent’s own filters,
so the agent can’t ask for another tenant, leave the tenant out, or widen past it
with OR. Grants, approvals and grant reuse are bound to the tenant, and every
request records it in the audit log.
vkit policy bundle refuses a dataset
that has another dataset’s tenant column but no tenant_column. Mark it, or set
tenant_column: false for a table every tenant may read (for example a plans
catalogue).When several policies match, the strongest action wins, whatever their priority:
| Strength | Action |
|---|---|
| 3 | deny |
| 2 | require_approval |
| 1 | mask |
| 0 | allow |
When several approval policies match, every policy’s requirement must be met (all
of its groups, or any one with approval_mode: any), each sign-off from a different
person, who counts for one group only. The shortest TTL applies. See
Approvals. Masking from every matching mask
policy is combined. With no matching policy, a request is allowed.
A field must be in the registry for a request to name it. A field the registry doesn’t have is refused before any policy is evaluated, so it can’t slip past policies that match on labels. See Columns the registry doesn’t have.
Masking combines every mask policy that matches, with the requester’s context; when two mask one field, the strictest method wins (full, then hash, then partial). An approval lifts the approval requirement, not the masks: a field a mask policy covers stays masked after approval.
Packs are ready-made policies. vkit init installs starter; add others with
vkit policy pack add <name>, and update with vkit policy pack upgrade.
| Pack | What it does |
|---|---|
starter |
Denies credentials. Masks personal data and high-sensitivity fields, also after approval. High-sensitivity data in production needs approval from data_owner. unknown columns are masked (full) for agents in every environment until someone reviews them; people can read them, and the decision records why, so they show up in the audit log. Other grants last 4 hours. |
ai_safety |
Agents need approval from security for personal or unknown data in production, and for high-sensitivity data in any environment. Agents reading financial data row by row in production need security or finance_manager (2.1.0). With starter, approved unknown columns still come back masked. |
financial_compliance |
Reading financial data row by row in production needs approval from finance_manager. Counts, sums, averages and grouping of financial columns don’t; MIN and MAX do (2.1.0). Grants with financial fields last 30 minutes. |
With both packs (2.1.0), an agent reading financial rows needs one sign-off, from a
finance manager. A request that needs two groups still does so for a reason: personal
and financial data together (security and finance_manager), an unreviewed column
plus financial data (the same two), or a high-sensitivity column (data_owner from
starter and security from ai_safety).
Before relying on a pack:
data_owner, security, finance_manager) and
add people to them. Until a group has an active member, org admins approve for it,
and vkit policy deploy warns about it. See
Groups with no members.low that holds personal data isn’t protected.requester_role: agent, the default role for agent tokens.
Tokens created with another role don’t.An installed pack’s files (config/policies/<pack>__NN__<id>.yaml) are yours
to edit, but keep them, with their ids. .vkit/packs.yaml records each one,
and vkit policy bundle fails if one is missing, has another policy id, or is
from another version of the pack than the one installed. The bundle records
each pack’s policy ids, and vkit policy deploy and the control plane refuse
a bundle that leaves one out. To get deleted files back, run
vkit policy pack upgrade <pack>: it lists them and offers to restore them
(--restore restores without asking). Every bundle prints how many policies
each pack and the repo contribute. Commit .vkit/packs.yaml with your policies:
vkit policy bundle refuses uncommitted changes to it (see
Commit .vkit/packs.yaml).
id: mask_customer_contact_in_business_hours
description: "Customer contact details are masked during business hours."
match:
dataset: customers
fields:
any: [email, phone]
context:
time:
after: "09:00"
before: "17:00"
context:
environment: production
action:
mask: true
reason: "Contact details are masked during business hours."
ttl: "1h"
masking:
default_method: partial