Security of systems that call models

Assistants with tools are applications with a new kind of untrusted input. The failures look like confused deputies, data leaks, and over-broad credentials.

Lesson 3 of 69 · 11 min read · practice only with authorization

Diagram

Trust boundaries around a model-backed feature

Follow the path. One example at a time.

Step 1 of 4

Input

User prompts and retrieved documents enter one context.

Illustration: Input
# Input
# User prompts and retrieved documents enter one context.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Prompt is not a boundary

    What fails
    Instructions in data can override the system prompt.
    Who is affected
    Users and connected systems.
    What you would notice
    Security rules that exist only as prompt text.
    What you change
    Enforce permissions in code around tools.
  2. Retrieval permissions

    What fails
    RAG can surface documents users cannot open.
    Who is affected
    Owners of restricted documents.
    What you would notice
    Index without ACLs.
    What you change
    Permission-aware retrieval.
  3. Tool scope

    What fails
    Agents with broad tools are confused deputies.
    Who is affected
    Everything those tools reach.
    What you would notice
    Service-account tools for user requests.
    What you change
    Act as the user; confirm consequential actions.

The model is not a trust boundary you can skip

A model will follow text. Some of that text is your system prompt. Some is a user. Some is a web page, a ticket, or a PDF the user asked it to read. If those sources are blended, the untrusted part can redirect the task. People call that prompt injection. The impact appears when the model can call a tool: send mail, query a database, spend money, open a URL, or reveal a document the current user should not see.

Treat model output as untrusted input to the next system, the way you treat a browser's form fields. Do not let a generated string become a shell command, a raw query, or an authorization decision. Ask the application, not the model, whether this user may perform this action.

Retrieval and tenants

Retrieval-augmented systems copy documents into a context window. If the index is not filtered by the caller's authorization, the model becomes a search engine for data the UI would have hidden. That is training-data or index leakage even when nobody trained a foundation model on your files.

Separate indexes by tenant. Filter before the text reaches the model. Do not put secrets in documents you retrieve. Log prompts with the same care you log passwords, because people paste secrets into chat boxes, and those logs become the next breach.

Tools and human approval

Give the assistant the smallest tool it needs. A reader is not a writer. A tool that emails should not also be a tool that changes payroll. Require a person to confirm actions that move money, delete data, or contact customers. Rate-limit the tools. Assume the confirmation dialog will be attacked by text that says the confirmation already happened. The application, not the sentence, records consent.

Third-party model providers are vendors. Keys belong in a secret store, data-retention settings are a privacy decision, and a prompt that contains customer data is a transfer. Read the vendor's terms the way you would read any processor agreement. A local model does not remove the authorization problem. It moves the weights and the index onto a machine you must patch.

How to study this safely

Build a toy assistant in a lab that can only read a folder of fake documents for two imaginary users. Confirm it cannot fetch the other user's file, that a document cannot convince it to ignore the folder boundary, and that a tool which sends mail is stubbed and logged. That is a complete exercise.

Do not collect jailbreak recipes, and do not aim experiments at a production assistant you do not operate. The useful skill is designing the permissions around the model.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Where should “only email the requester” be enforced?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.