Security

Using the Praxis Policy Engine in Core

Praxis Core's policy filter embeds the Praxis Policy Engine (PPE).

Praxis Development (b102332f8bdc) 7 min read

Switching projects opens that project’s default documentation release.

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

On this page

Praxis Core’s policy filter embeds the Praxis Policy Engine (PPE). Use it to authorize API and tool calls, obtain upstream credentials, redact sensitive fields, require approval, or restrict actions after a session reads sensitive data. Request rules run before forwarding to the backend. Response rules can inspect buffered content, while streaming metadata rules run at EOF after chunks have been released.

Core, PPE, and Praxis AI

  • Praxis Core runs the filter on HTTP requests and responses and applies its decisions when forwarding traffic.
  • PPE reads the policy document and runs its identity checks, authorization rules, delegation steps, transformations, and approvals. It can also be embedded directly in other Rust hosts.
  • Praxis AI adds model-provider and agent-protocol filters. MCP policy needs its protocol classifier before policy. Core can authorize inference requests by reading their top-level model without that classifier. See the Praxis AI quickstart for AI pipelines.

Core’s standard build includes PPE and its builtin plugins. Add policy to a listener’s filter chain and give it a policy document to enable enforcement. Depending on the plugins you configure, you may also need an identity provider, secret store, approval service, or session store. The build features guide explains how to select plugins for a smaller build.

Policy use cases

API and tool authorization

An HR employee can read compensation records; an engineer’s request is denied before it reaches the backend. Route rules make this decision using attributes from verified JWT or API-key identities. PPE can resolve the user, client, and workload identities independently. Rules can also call embedded Cedar, CEL, or OPA/Rego decision points.

The tool-access example shows the HR rule in action. HTTP routing covers API routes, and PDP integration explains how to call Cedar, CEL, and OPA.

Model access and inference inputs

An application can be limited to approved models. By default, a body-bearing inference request with a missing or unlisted model is denied. Rules can also inspect the parsed request’s tool definitions and message content. The filter reads these requests directly, without an MCP classifier.

Authenticated bodyless requests, such as GET /v1/models, use HTTP or global authorization rules instead of the model requirement. With neither configured, they can reach the upstream on identity alone. Protect other endpoints on the listener with HTTP/global rules or restricted routing.

LLM routes describes the available request fields. Core’s inference input example includes rules for checking them.

Upstream credentials and delegation

A delegation rule can exchange a user’s token for an upstream credential with the requested audience and permissions. It can also retrieve a personal access token or API key from Vault. The rule selects whose identity the credential represents and who is acting on their behalf.

See credential custody and token exchange and identity and delegation recipes.

Redaction by caller permission

Two HR employees can request the same compensation record. Only the employee with permission to view SSNs receives that field. PPE field pipelines redact or mask MCP tool arguments and tool results in the proxy. Enable body_access: read_write to apply the changes to the forwarded messages.

See on-the-wire redaction and effects and sequencing.

Data flow across tool calls

A policy can block external email after a session reads compensation data. The read adds a session taint label; the email route checks that label and denies the call, even if the email contains no recognizable sensitive pattern. A persistent session store keeps the label across requests and proxy restarts.

The data-flow example demonstrates the read-then-send block. Session taint explains label storage and policy syntax.

Sensitive data in tool arguments

A validator plugin can reject tool arguments containing an SSN or credit card number before the tool runs. The host supplies the scanner, and the policy determines when to call it. Core’s guardrails filter can handle simple request matching; use a PPE validator when scanning belongs in a tool’s policy alongside authorization or session checks.

See PII guardrails on arguments for a scanner and audit example.

Human approval and auditing

A salary adjustment above a threshold can require a manager’s approval. OIDC CIBA sends the approval request through a separate channel and suspends the tool call. Once approved, the caller retries with the approval identifier. Audit sinks record policy decisions and effects; the host can supply a custom destination.

The approval example walks through a salary adjustment. Auditing covers decision records and audit sinks.

Rate limits by address or identity

Limit unauthenticated requests by client address, then apply limits to resolved identities and claims before authorization and forwarding. Policy routes can select different limits. The bundled limiter is experimental. Its counters belong to each limiter instance, are not shared between replicas, and reset on configuration reload. Distributed counting is planned.

See policy rate limiting for configuration and denial behavior.

When to use other Core filters

For simpler rules, Core provides dedicated filters:

  • IP ACL allows or denies source IPs and CIDR ranges.
  • Guardrails matches strings, regexes, or PII patterns in request headers and bodies. It does not inspect response bodies. Use PPE’s supported response controls for policy-based output inspection or MCP redaction, subject to the requirements below.
  • Credential injection attaches a fixed per-cluster credential.

Use policy when rules depend on verified identity, caller permissions, approval, or session history. You can combine these filters: an IP ACL can restrict source networks while policy decides which tools a caller may use.

Proxy and policy configuration

The proxy and the engine have separate configuration documents:

  1. praxis.yaml declares listeners, upstreams, and the filter chain. The policy entry sets config_path and the filter’s options.
  2. policy.yaml declares PPE plugins, identity sources, routes, and rules. The filter loads this file from config_path.

This fragment belongs inside a proxy filter chain:

- filter: policy
  config_path: /etc/praxis/policy.yaml

The default body_access: read_only preserves response streaming. read_write enables rewriting and response inspection using the configured buffer limit. For streaming inference with response rules, chunks are released before EOF; the full response is not buffered.

Filter fields sit directly under filter, without a nested config key. For a complete configuration, use the Core policy example or the gateway demo. The demo provides both files, an identity provider, a session store, and scripted allow, deny, redaction, delegation, and approval scenarios.

Requirements and limitations

ControlRequired integration
HTTP authorization and delegationA policy document with HTTP or global controls.
MCP tool, prompt, and resource policyPraxis AI classifier before policy; keep require_protocol_metadata: true.
MCP body rewriting and response rulesbody_access: read_write; tool results support field pipelines, prompt and resource results do not.
Inference request authorizationA top-level model and matching llm: route; no MCP classifier required.
Inference response content inspectionbody_access: read_write and a non-streaming JSON response; inference bodies are not rewritten by field mutators.
Streaming inference response metadataA host filter supplies trusted metadata, evaluated at EOF after chunks are released. Denials are reported through PolicyResponseOutput; this path neither inspects nor blocks streamed content.
Cross-call session labelsA configured session store; use persistent storage when labels must survive restarts.
Plugins and decision pointsThe corresponding build features and any services those plugins need.

Keep body-processing policy filters in the main pipeline: branch chains do not execute body hooks. For MCP, order the classifier before policy and upstream dispatch after it. For inference, order any body rewriting before policy so it evaluates the request that will reach the backend. Consult the policy-filter reference for header/path ordering, timeouts, body limits, trusted endpoints, and response behavior.

Getting started

  1. Choose a scenario in PPE use cases.
  2. Configure Core using the policy-filter reference.
  3. Write rules with the PPE quick start and APL guide.
  4. Run the gateway demo and check both allowed and denied outcomes.