Policy Configuration

Status: Available.

Policy rules live at ~/.mezite/local/policy.yaml. The file is hot-reloaded by fsnotify — save it and the new policy takes effect within a second without restarting the daemon. If the YAML is invalid, the daemon logs a warning and keeps the previous working policy.

Schema overview

The top level is keyed by protocol (kubectl, gcloud, fly,generic, …). Each protocol block contains:

KeyPurpose
inspect:Hostnames, globs, IPs, or CIDRs the daemon should MITM for this protocol
default:Fallback action (allow / escalate / deny) when no rule matches
groups:Named selectors — match requests by tiers:, commands:, or operations:
<scope>:First-match-wins scope-sugar list (namespaces, projects, regions, zones, orgs, apps)
rules:Flat allow/escalate/deny fallback, evaluated after scope blocks

Actions: allow (forward immediately), escalate (block until a human approves or denies),deny (return 403 immediately).

The four risk tiers

TierTypical operations
observeRead-only / GET; API discovery
modifyCreates, updates, patches
sensitiveDeletes, secret reads, credential operations
break-glassIAM grants, cluster-admin, destructive platform ops

There are four tiers in V2 (observe, modify, sensitive,break-glass). There is no Tier-1 "operate" or runbook tier.

Annotated example — kubectl

kubectl:
  # Hosts to intercept. Add your own cluster URLs here.
  inspect:
    - "*.eks.amazonaws.com" # EKS
    - "*.gke.goog" # GKE
    - "*.azmk8s.io" # AKS

  # Default: escalate anything that doesn't match a rule.
  default: escalate

  # Named groups — match by tier string or exact command label.
  groups:
    read:
      tiers: [observe]
    mutate:
      tiers: [modify]
    delete:
      tiers: [sensitive]
    admin:
      tiers: [break-glass]
    exec:
      # commands: use the classifier's canonical "verb resource" form
      # (visible in ~/.mezite/local/daemon.log on `classified:` lines).
      commands: [exec, attach, port-forward, cp, debug, proxy]

  # Scope-sugar: first-match-wins across the list.
  namespaces:
    - names: [prod-*, production]
      rules:
        escalate:
          groups: [mutate, delete, admin]
          commands:
            - configmaps get
            - configmaps list
        allow:
          groups: [read]
        deny:
          groups: [exec]

    - names: ["*"]
      rules:
        allow:
          groups: [read]
        escalate:
          groups: [mutate, delete, admin]
        deny:
          groups: [exec]

  # Flat fallback — hits when no namespaces: entry matched
  # (cluster-scoped requests, API discovery, auth handshakes).
  rules:
    allow:
      groups: [read]
    escalate:
      groups: [mutate, delete, admin]
    deny:
      groups: [exec]

Annotated example — gcloud

gcloud:
  inspect:
    - "*.googleapis.com"

  default: escalate

  groups:
    read:
      tiers: [observe]
    mutate:
      tiers: [modify]
    destructive:
      tiers: [sensitive]
    iam:
      tiers: [break-glass]

  projects:
    - names: ["*"]
      rules:
        allow:
          groups: [read]
        escalate:
          groups: [mutate, destructive, iam]

  # Flat fallback for OAuth token refreshes, cross-service IAM,
  # and discovery calls that carry no project label.
  rules:
    allow:
      groups: [read]
    escalate:
      groups: [mutate, destructive, iam]

Annotated example — fly

fly:
  inspect:
    - "api.fly.io"
    - "api.machines.dev"
    - "*.fly.dev"

  default: escalate

  groups:
    read:
      tiers: [observe]
    mutate:
      tiers: [modify]
    destructive:
      tiers: [sensitive]
    admin:
      tiers: [break-glass]

  apps:
    - names: ["*"]
      rules:
        allow:
          groups: [read]
        escalate:
          groups: [mutate, destructive, admin]

  rules:
    allow:
      groups: [read]
    escalate:
      groups: [mutate, destructive, admin]

Annotated example — aws

aws:
  # AWS spans many services across several endpoint suffixes. These
  # globs cover the bulk, China, the dual-stack .api.aws endpoints,
  # and the .aws.amazon.com control plane.
  inspect:
    - "*.amazonaws.com"
    - "*.amazonaws.com.cn"
    - "*.aws.amazon.com"
    - "*.api.aws"

  default: escalate

  groups:
    read:
      tiers: [observe]
    mutate:
      tiers: [modify]
    destructive:
      tiers: [sensitive]
    iam:
      tiers: [break-glass]

  # The classifier emits a `region` label for regional endpoints
  # (ec2.us-east-1.amazonaws.com); regions: is first-match-wins.
  regions:
    - names: ["*"]
      rules:
        # Hard-deny a handful of catastrophic, irreversible ops
        # outright — no approval prompt, just refused. operations:
        # matches the classifier's `operation` label (the real API
        # verb, which the on-the-wire HTTP method does not carry).
        deny:
          operations:
            - DeleteVpc
            - ScheduleKeyDeletion
            - DeleteOrganization
            - LeaveOrganization
            - CloseAccount
            - DeleteBucket
            - DeleteHostedZone
        allow:
          groups: [read]
        escalate:
          groups: [mutate, destructive, iam]

  # Flat fallback for global services (IAM, STS, Route 53, CloudFront),
  # the S3 global endpoint, and credential handshakes — calls with no
  # region label. The same hard-deny list is repeated here.
  rules:
    deny:
      operations:
        - DeleteVpc
        - ScheduleKeyDeletion
        - DeleteOrganization
        - LeaveOrganization
        - CloseAccount
        - DeleteBucket
        - DeleteHostedZone
    allow:
      groups: [read]
    escalate:
      groups: [mutate, destructive, iam]

The shipped default policy wires up kubectl, gcloud, aws, fly, andgeneric. The gcloud and aws blocks hard-deny a short list of catastrophic, irreversible operations (project/VPC/org/bucket/KMS-key deletion) via the operations: selector — those are refused outright rather than escalated.

generic: — arbitrary hosts

The generic: block MITMs any host listed under inspect: and tiers requests from the HTTP method alone (GET/HEAD/OPTIONS → observe, POST/PUT/PATCH → modify, DELETE → sensitive). The wildcard *under inspect: is legal only in the generic: block.

generic:
  inspect: [] # add hosts here; empty ships by default
  default: escalate

  groups:
    read:
      tiers: [observe]
    mutate:
      tiers: [modify]
    destructive:
      tiers: [sensitive]
    admin:
      tiers: [break-glass]

  rules:
    allow:
      groups: [read]
    escalate:
      groups: [mutate, destructive, admin]

Scope-sugar keyword reference

KeywordProtocolMatched label
namespaces:kubectlnamespace
projects:gcloudproject
regions:gcloudregion
zones:gcloudzone
orgs:gcloudorganization
apps:flyapp
orgs:flyorg

Scope blocks are first-match-wins down the list. Each entry needs a names: glob list and a rules: block.

Glob patterns

PatternMatches
"payments"Exact match
"staging-*"Any name starting with staging-
"*"Everything (catch-all)

Policy decisions

DecisionBehaviour
allowRequest forwarded immediately
denyRequest rejected with 403
escalateRequest blocked; operator must approve or deny via desktop app or msh local approval allow <id> / msh local approval deny <id>

default: escalate is the safe default. Without an explicit rule, unknown commands surface an approval prompt rather than being silently allowed or denied.

Changes to policy.yaml are hot-reloaded automatically — no daemon restart needed. If the new YAML is invalid, the daemon logs a warning and keeps the previous working policy.