Security, Governance and PlatformUntrusted input and toolsStaff
How should an agent use a helpful document that also contains a prompt-injection attempt?
By Amit Kumar4 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
An agent investigating a production error retrieves an incident note that explains the failure correctly but instructs it to upload private logs to an external site. That site is approved for another tenant. Explain how to retain useful evidence while preventing unauthorized transmission, including the controls at the tool and network boundaries. What changes if the instruction is quoted in a code example or the note was written by your own SRE team?
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The incident note can be useful evidence without being authorized to direct this agent's actions. It may accurately explain a past failure and still contain an instruction that is malicious, obsolete or intended for someone else. The system needs to preserve that distinction as the note moves from retrieval into model context and possibly into a proposed tool call.
Prompt injection occurs when lower-trust material tries to influence behavior beyond the authority that material should have. Here, a retrieved document attempts to turn “upload logs” into an action performed with the user's or platform's privileges. The failure is not that the sentence uses imperative language. Runbooks legitimately contain commands. The failure would be treating the document as permission to execute one for the current tenant and data.
Keep the note's source, revision and trust context with its text. Tell the model that retrieved content is evidence to analyze and that embedded commands do not expand its instructions or authority. This can help it extract the valid troubleshooting facts without following the hostile request. It remains a probabilistic control. The design must still prevent the upload if the model proposes it anyway.
Suppose the proposed call is upload_logs(destination, bundle). The tool gateway evaluates the actual requesting principal, tenant, target case, purpose, data classification and destination. It must use trusted runtime identity, not a tenant identifier supplied by the model. A site approved for tenant B is not automatically approved for tenant A. Likewise, permission to read a log for diagnosis does not imply permission to transmit it outside the organization.
The gateway should authorize the exact effect. In a hypothetical policy, tenant A permits only a redacted diagnostic artifact for case C-42 to be sent to its own managed support endpoint. A proposal to send the complete raw bundle to a different host fails that policy even if the host appears in some global allowlist. If the proposed data or destination changes after a human approves it, the tool must check whether the approval still applies. A vague “continue investigation” approval cannot cover arbitrary external transfer.
Reduce the tool's expressive power where the product allows it. An interface that accepts a case ID and a managed artifact reference is easier to constrain than an arbitrary URL and unrestricted blob. Keep credentials in the gateway rather than exposing them to the model or a general sandbox. Redaction can reduce sensitive payload, but it does not authorize a destination or prove that every sensitive field was removed.
Enforce network egress as well. A tool might follow redirects, resolve a hostname to an unexpected address or invoke another transfer mechanism. The controlled network path should apply destination restrictions to the actual connection and handle redirects according to policy. Otherwise a validated initial URL can lead to an unapproved final host, or a shell tool can bypass the specialized upload interface. A single tool-level check is insufficient if another tool has broader network authority.
OpenAI's agent safety guidance discusses indirect prompt injection and downstream data exfiltration, while its computer-use guidance treats encountered content as unable to grant new permission. These sources illustrate the threat. The proposed gateway and network policy are application controls whose behavior must be tested in the deployed environment.
Moving the instruction into a quoted code example changes how the model should interpret the text, but does not broaden permission. It may be legitimate to explain what that example does or show a safe excerpt to an authorized reader. Execution still requires present authority for the destination, payload and operation. Deleting every imperative sentence would damage useful runbooks and still miss less obvious attacks, so do not make linguistic classification the final security boundary.
An internal SRE author may make the troubleshooting facts more credible. It does not make the note a live authorization grant. The note could be copied from another tenant, superseded or compromised. If SRE needs a real log-transfer workflow, implement it through controlled destinations, scoped data and approvals. The document can link to that workflow without defining its permissions.
Test two properties separately. First, does the model use the valid evidence while resisting the injected instruction? Second, if it requests the upload anyway, do the gateway and network controls reject it? Exercise cross-tenant destinations, redirects, quoted examples and alternate tools. Record attempted violations without leaking the private bundle into ordinary traces. The agent should then continue permitted diagnostics or report the blocked step accurately. Safe behavior depends on enforced authority even when document interpretation fails.
Related questions
Keep practising security, governance and platform
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux