Malicious text is hidden in a tool result
Detect: Provenance trace shows the instruction originated outside trusted configuration.
Recover: Reject unauthorized actions and isolate the affected source.
Constrain untrusted instructions at data boundaries and prevent retrieved content from acquiring tool authority, secrets, or control over the agent workflow.
Prompt injection occurs when untrusted content attempts to redirect a model away from its intended task or policy. The content may arrive in a user message, retrieved page, document, image, or tool result. Because instructions and data share a model context, delimiters and warnings alone cannot establish a complete security boundary.
Design around consequences. Keep secrets out of model context, constrain tool capabilities, validate outputs, and enforce authorization outside the model. A retrieved document may contain useful facts and malicious instructions simultaneously; the architecture must preserve evidence utility without treating the document as a source of authority.
A prototype should include malicious documents and tool responses in its test corpus, even when all tools are read-only.
Production separates trusted configuration from retrieved data, limits outbound destinations, scopes credentials, and requires confirmation for specified consequential actions. Detectors provide signals rather than guarantees.
At scale, maintain adversarial regression suites, provenance-aware traces, and incident containment. Evaluate successful unauthorized effects and data exposure, not merely whether the model repeated suspicious text.
Labels source provenance and prevents external text from replacing trusted configuration.
Enforces narrow tool permissions and rejects unauthorized operations independently of model output.
Flags suspicious instruction patterns and risky payloads for policy handling.
Restricts destinations, data classes, and request shapes that tools can transmit.
Tests indirect injection paths and verifies actual boundary enforcement.
flowchart LR
D["External document"] --> T["Provenance and inspection"]
T --> M["Model context"]
C["Trusted task configuration"] --> M
M --> G["Independent capability gateway"]
P["Authorization and egress policy"] --> G
G --> A["Approved business API"]
G --> X["Denied action and audit event"]
M --> V["Output validation"]sequenceDiagram
participant D as External document
participant M as Model
participant G as Tool gateway
participant P as Egress policy
participant A as Audit record
D->>M: Evidence containing hostile instructions
M->>G: Proposed upload of internal notes
G->>P: Check destination and data authority
P-->>G: Denied outside approved scope
G-->>M: Unauthorized action rejected
G->>A: Record source provenance and denied effectMark user input, retrieved evidence, tool output, and trusted configuration by provenance.
Remove unnecessary secrets and limit the data and capabilities available for the task.
Apply detection and normalization while retaining the distinction between evidence and instructions.
Allow the model to use evidence but require structured action requests.
Validate authorization, arguments, destinations, and approval requirements before any effect.
Check public output and audit traces for leakage or unauthorized actions, then quarantine compromised sources.
Enterprise procurement · Illustrative enterprise scenario, not a reported customer outcome.
A procurement assistant reviews supplier PDFs and can retrieve internal evaluation templates.
A supplier inserts text instructing the assistant to upload evaluation notes to an external endpoint disguised as a verification service.
The assistant must extract proposal facts without allowing the supplier document to control internal tools or data sharing.
Documents enter as untrusted evidence; the agent has no arbitrary network tool, and outbound actions pass through an allowlisted gateway.
If a detector misses the payload, capability and egress controls still prevent the upload; the proposal can be quarantined based on the denied action.
Measure unauthorized-action success, sensitive-data exposure, benign-document false positives, and containment time across realistic attack variants.
| Decision | Benefit | Cost |
|---|---|---|
| Narrow capabilities | Injection has fewer harmful actions available. | Some useful flexible workflows require additional adapters. |
| Content detection | Known attack patterns can be flagged early. | Obfuscation and novel payloads can evade classifiers. |
| Strict egress policy | Exfiltration paths are reduced independently of model behavior. | Integrations need deliberate destination and data approvals. |
Detect: Provenance trace shows the instruction originated outside trusted configuration.
Recover: Reject unauthorized actions and isolate the affected source.
Detect: Adversarial tests still observe an attempted prohibited effect.
Recover: Strengthen the execution boundary instead of trusting classifier confidence.
Enforce authority in tools and data services.
Use scoped credentials outside model-visible context.
Include retrieval, files, images, and tool-response injection.