# Trust boundaries

> A catalogue of the boundaries Keryn looks for, who controls each side, what evidence supports crossing, and an example of each.

Source: https://keryn.dev/docs/edges/trust-boundaries/

A trust boundary is an [edge](https://keryn.dev/docs/edges/edge-kinds/) where authority changes: input from one party becomes action by another. Keryn finds these edges, names who controls each side, and says what evidence supports crossing them. A boundary is not a defect. Every useful system crosses several. The finding is a crossing with no evidence that anyone checked it.

## The classes

Rule metadata groups boundaries into four classes. The first three describe what crosses. The fourth describes where code comes from.

| Class | What crosses | Controlled on the near side by | Controlled on the far side by | Evidence that supports crossing |
|---|---|---|---|---|
| [`user->prompt`](#user-to-prompt) | Text someone else wrote becomes instructions or context for a model | whoever wrote it: a user, a web page, a document, an email | your prompt | isolation of the text from the instructions, trust labels on sources, an output check |
| [`model->code`](#model-to-code) | A model's output becomes an action | whoever can influence the model's input | your code and the machine it runs on | an allow-list of actions, argument validation, a person approving, a sandbox |
| [`secret->outside`](#secret-to-outside) | A credential or sensitive data reaches a place less trusted than where it lives | your configuration | a provider, a log, a webhook, a subprocess | a scoped credential, redaction, an allow-listed destination, a review |
| [`supply-chain`](#supply-chain) | Code, a model or a tool from outside is trusted enough to run | its publisher | you | a pinned version, a digest, a signature, a review |

A tool call is a model's output becoming an action, so it belongs to `model->code`. A workflow reaching an outside service is a [`sends`](https://keryn.dev/docs/edges/edge-kinds/#sends) edge, and it is a boundary when the destination is less trusted than the source. When what travels is a credential, it is `secret->outside`.

## user to prompt

Diagram: user text sends system prompt, across a user to prompt. Someone else's words become your instructions.

A model cannot tell instructions from data. Anything that reaches its context can try to give it orders: a message, a retrieved page, a file in a repository, an email it is asked to summarise. The boundary is crossed whenever text from a party you do not control enters a prompt. Keeping that text in the user turn, apart from your instructions, is the common control; it narrows the problem and does not remove it, which is why the next boundary matters as much.

**A user's text enters the system prompt** (a live example on the page; the engine runs in the browser, nothing is uploaded)

```python
from flask import request
from anthropic import Anthropic

client = Anthropic()

def answer():
    company = request.args.get("company")
    return client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=300,
        system="You answer billing questions for " + company + ". Never reveal other accounts.",
        messages=[{"role": "user", "content": "What is my balance?"}],
    )
```

Rule:

```yaml
rules:
  - id: acme.request-in-system-prompt
    languages: [python]
    severity: WARNING
    message: A request parameter becomes part of the system prompt. Keep untrusted text out of the instructions.
    metadata:
      edge: sends
    mode: taint
    pattern-sources:
      - pattern: request.args.get(...)
    pattern-sinks:
      - patterns:
          - pattern: $CLIENT.messages.create(..., system=$S, ...)
          - focus-metavariable: $S
```

Result, computed when the site was built by the same engine as `keryn scan`:

```text
1 finding · 1 of 1 rules ran on 1 file

warning acme.request-in-system-prompt line 12 [proof 2 path-in-file]
  A request parameter becomes part of the system prompt. Keep untrusted text out of the instructions.
  Edge: sends
  Flow: source (line 8) -> propagation (line 8)
  | system="You answer billing questions for " + company + ". Never reveal other accounts.",
```

Rules that inspect this boundary: 181 rules in the catalog name user->prompt in their metadata.

- [`keryn.agentcfg.env-api-base-url-override`](https://keryn.dev/rules/claude-code-hooks-v1/#kerynagentcfgenv-api-base-url-override)
- [`keryn.agents2026.agentcore-payload-to-browser-navigation`](https://keryn.dev/rules/agent-frameworks-2026-python-v1/#kerynagents2026agentcore-payload-to-browser-navigation)
- [`keryn.agents2026.openai-agents-function-tool-network-or-file`](https://keryn.dev/rules/agent-frameworks-2026-python-v1/#kerynagents2026openai-agents-function-tool-network-or-file)
- [`keryn.agents2026.strands-agent-dangerous-community-tool`](https://keryn.dev/rules/agent-frameworks-2026-python-v1/#kerynagents2026strands-agent-dangerous-community-tool)
- [`keryn.browseragent.host-function-exposed-to-page-js`](https://keryn.dev/rules/browser-agent-automation-v1/#kerynbrowseragenthost-function-exposed-to-page-js)
- [`keryn.browseragent.host-function-exposed-to-page-py`](https://keryn.dev/rules/browser-agent-automation-v1/#kerynbrowseragenthost-function-exposed-to-page-py)
- [`keryn.browseragent.page-content-in-system-prompt-js`](https://keryn.dev/rules/browser-agent-automation-v1/#kerynbrowseragentpage-content-in-system-prompt-js)
- [`keryn.browseragent.page-content-in-system-prompt-py`](https://keryn.dev/rules/browser-agent-automation-v1/#kerynbrowseragentpage-content-in-system-prompt-py)

173 more in the [rule catalog](https://keryn.dev/rules/).

## model to code

Diagram: model output reaches a shell, across a model to code. Text becomes a command.

The model's output is text that something can steer. When code turns that text into a shell command, a query, a file path, a URL, a function call or a tool call, whoever steers the model steers the machine. This is the boundary behind most agent incidents, and the one where evidence is cheapest to produce: an allow-list of the actions the model may choose, validation of the arguments, and a person approving the ones that change things. [Why the edges](https://keryn.dev/docs/concepts/why-the-edges/#one-edge-in-code) runs a live example, and [edge kinds](https://keryn.dev/docs/edges/edge-kinds/) has the file, SQL and function-call variants.

Rules that inspect this boundary: 353 rules in the catalog name model->code in their metadata.

- [`keryn.agentcfg.hook-command-relative-script-path`](https://keryn.dev/rules/claude-code-hooks-v1/#kerynagentcfghook-command-relative-script-path)
- [`keryn.agentcfg.hook-command-unconditional-allow`](https://keryn.dev/rules/claude-code-hooks-v1/#kerynagentcfghook-command-unconditional-allow)
- [`keryn.agentcfg.hook-command-uses-eval`](https://keryn.dev/rules/claude-code-hooks-v1/#kerynagentcfghook-command-uses-eval)
- [`keryn.agenthooks.copilot-hook-base64-exec`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-base64-exec)
- [`keryn.agenthooks.copilot-hook-relative-script-path`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-relative-script-path)
- [`keryn.agenthooks.copilot-hook-uses-sudo`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-uses-sudo)
- [`keryn.agenthooks.cursor-hook-base64-exec`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-base64-exec)
- [`keryn.agenthooks.gemini-hook-base64-exec`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthooksgemini-hook-base64-exec)

345 more in the [rule catalog](https://keryn.dev/rules/).

## secret to outside

Diagram: api key sends webhook host, across a secret to outside. A credential leaves with the request.

A secret matters because of what it unlocks. The boundary is crossed when a credential, a customer record or any other sensitive value is placed where a less trusted party can read it: in a prompt, a log line, a request to a third party, a child process's environment, a file the agent can read. The evidence that supports crossing is that the destination should have it: a scoped key rather than a master key, redaction before the value is logged, a destination on an allow-list. A [live example](https://keryn.dev/docs/edges/edge-kinds/#sends) shows the shape.

Rules that inspect this boundary: 76 rules in the catalog name secret->outside in their metadata.

- [`keryn.agentcfg.hook-command-dns-lookup-with-variable`](https://keryn.dev/rules/claude-code-hooks-v1/#kerynagentcfghook-command-dns-lookup-with-variable)
- [`keryn.agenthooks.copilot-hook-raw-ip-url`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-raw-ip-url)
- [`keryn.agenthooks.copilot-hook-reverse-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-reverse-shell)
- [`keryn.agenthooks.copilot-hook-sends-host-data`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-sends-host-data)
- [`keryn.agenthooks.copilot-prompt-hook-posts-to-network`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-prompt-hook-posts-to-network)
- [`keryn.agenthooks.cursor-hook-raw-ip-url`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-raw-ip-url)
- [`keryn.agenthooks.cursor-hook-reverse-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-reverse-shell)
- [`keryn.agenthooks.cursor-hook-sends-host-data`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-sends-host-data)

68 more in the [rule catalog](https://keryn.dev/rules/).

## supply chain

Diagram: agent depends on remote model code, across a supply chain. Code from outside runs here.

Some boundaries are crossed before the program starts: a dependency, a container base image, a model file that carries code, an MCP server fetched by name when the agent launches. The far side is controlled by a publisher you may not know, and the near side is your machine with your credentials. What supports the crossing is being able to say exactly what ran: a pinned version, a digest, a signature, a review of what it asks for.

**A model repository's own code runs here** (a live example on the page; the engine runs in the browser, nothing is uploaded)

```python
from transformers import AutoModel

def load(name):
    return AutoModel.from_pretrained(name, trust_remote_code=True)
```

Rule:

```yaml
rules:
  - id: acme.remote-model-code
    languages: [python]
    severity: WARNING
    message: Loading this model runs Python code that ships in the model's repository. Pin the revision and review the code.
    metadata:
      edge: depends_on
    pattern: $X.from_pretrained(..., trust_remote_code=True, ...)
```

Result, computed when the site was built by the same engine as `keryn scan`:

```text
1 finding · 1 of 1 rules ran on 1 file

warning acme.remote-model-code line 5 [proof 1 pattern]
  Loading this model runs Python code that ships in the model's repository. Pin the revision and review the code.
  Edge: depends_on
  | return AutoModel.from_pretrained(name, trust_remote_code=True)
```

Rules that inspect this boundary: 242 rules in the catalog name supply-chain in their metadata.

- [`keryn.agenthooks.copilot-hook-pipes-download-to-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-pipes-download-to-shell)
- [`keryn.agenthooks.copilot-hook-unpinned-package-runner`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscopilot-hook-unpinned-package-runner)
- [`keryn.agenthooks.cursor-hook-pipes-download-to-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-pipes-download-to-shell)
- [`keryn.agenthooks.cursor-hook-unpinned-package-runner`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookscursor-hook-unpinned-package-runner)
- [`keryn.agenthooks.gemini-hook-pipes-download-to-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthooksgemini-hook-pipes-download-to-shell)
- [`keryn.agenthooks.gemini-hook-unpinned-package-runner`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthooksgemini-hook-unpinned-package-runner)
- [`keryn.agenthooks.kiro-broad-file-hook-fetches`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookskiro-broad-file-hook-fetches)
- [`keryn.agenthooks.kiro-hook-pipes-download-to-shell`](https://keryn.dev/rules/agent-hooks-multivendor-v1/#kerynagenthookskiro-hook-pipes-download-to-shell)

234 more in the [rule catalog](https://keryn.dev/rules/).

## Where Keryn finds boundaries

- **In code.** Rules look for the crossing itself: a request parameter in a prompt, a model reply at a sink, a secret in an outgoing call, a remote-code flag. A finding states its [proof level](https://keryn.dev/docs/concepts/proof-ladder/), so a reader can tell a pattern from a traced path.
- **In a model you draw or derive.** The [Trust Canvas](https://keryn.dev/docs/guides/trust-canvas/) puts elements in zones with trust levels. An edge whose ends sit in different zones or at different levels is a boundary, and the analysis records its direction (inbound, outbound or lateral), its controls and its evidence. A boundary with neither control nor evidence is raised as a risk. The [reference](https://keryn.dev/docs/reference/trust-canvas/#trust-boundaries) has the exact rule.

Both say the same thing: where authority changes, the evidence should be written down.

## What this does not claim

The four classes are the ones rule metadata uses today. They are not every boundary a system has, and a rule that finds one is a lead with a stated proof level, not a verdict on your system. [What Keryn does not do](https://keryn.dev/docs/concepts/limits/) lists the measured limits.
