Engineering Around a Stochastic Component

Prompt Injection: There Is No Prompt-Level Fix

Instructions and untrusted text reach the model as the same tokens. Privilege has to live in the action layer, because nothing in the architecture can mark one as trusted.

The thing to internalise: a model has one input channel. Your system instructions and the untrusted text you fed it arrive as the same stream of tokens, and nothing in the architecture marks one as privileged. This is not a bug that a firmer system prompt closes. Every defence written inside the prompt is a probabilistic filter that an attacker gets unlimited attempts to pass, at no cost, with no rate limit on creativity.

Indirect injection is the actual threat

A user typing instructions to ignore the system prompt is mostly a nuisance — they are attacking their own session and their own data. The dangerous form is indirect: the instruction is planted in content your system retrieves on behalf of a trusted user. A web page the agent browses. A PDF it summarises. A support ticket, a calendar invite, a code comment, a commit message, white text in a document. Your agent reads it carrying the user's authority and does what it says, and from the logs it looks like the user asked.

The framing worth using as a checklist: real damage needs three things at once — access to private data, exposure to untrusted content, and a channel to send data out. Remove any one and the attack loses its payoff. Almost every published real-world leak of this kind was an agent that had all three, where nobody had noticed the third.

The exfiltration channel you will miss

Your output rendering is an attack surface. If the interface renders model output as markdown or HTML, an image or link whose URL carries the stolen data is a working exfiltration path, and an image needs no click — the browser fetches it on render. This exact class has been found repeatedly in shipped products from serious engineering organisations, which should tell you how easy it is to miss. Strip or allowlist outbound URLs in rendered output, and never let the model choose an arbitrary destination for a request your infrastructure will make.

Controls that actually hold

  • Least privilege on tools. Scope credentials to the acting user, never a service account that can see every tenant. Read and write are separate tools with separate permissions and separate audit trails.
  • Human confirmation on anything irreversible or outbound — sending, paying, deleting, posting, granting access. The confirmation must display the resolved action and its real arguments, not the model's description of what it is about to do.
  • Deterministic validation at the boundary. Output schemas, allowlists of recipients and domains, numeric ceilings, tenant checks on every identifier. Code enforces these. A prompt never enforces anything.
  • No secrets in context. Anything in the window can be emitted. API keys, other users' records and internal credentials belong in the tool layer, which uses them without ever showing them to the model.
  • Split trust where the architecture allows. One call plans with no access to raw untrusted text; another processes the untrusted text with no tool access. The injected instruction then lands in a context that cannot act.

One channel

instructions and untrusted text arrive as the same tokens — privilege can only live in the action layer

Classifiers, honestly

Input and output classifier guardrails do reduce casual abuse and are worth running. Treat them as noise reduction, not as a security boundary. Published jailbreak-resistance numbers move constantly, differ by attack method, and none reach anything a security engineer would call safe. This is genuinely unsolved and under active research — anyone selling you a solved version of it is selling a filter. Design on the assumption that some fraction of the time the model will do the attacker's bidding, and make that outcome boring: scoped credentials, confirmations, validation, and a complete trace of what actually ran.

Run the exercise on your own system in writing. For each tool the agent can call, assume an attacker fully controls the model's next action and ask what the worst single call achieves. If any answer is unacceptable, the fix is a permission or a confirmation, not a prompt. That exercise takes an afternoon and finds more than a penetration test of the chat interface will.

Key takeaways

1No prompt-level defence is reliable; privilege belongs in scoped tools, confirmations and code validation
2Indirect injection through retrieved documents and pages is the real risk, not users jailbreaking their own session
3Rendered markdown and image URLs are a live exfiltration channel — allowlist outbound destinations
4Audit each tool by asking what one attacker-controlled call could do, then fix with permissions rather than wording

This is one lesson of 541.

The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.