Preventing Prompt Injection in a Shared Google Doc from Directing an Agent to Exfiltrate Client Files
You cannot reliably stop every injected instruction at the input, so prevent exfiltration by limiting what an influenced agent can do. Treat document content as untrusted, give the agent only the tools the task needs, enforce authorization on each tool call outside the agent's context, restrict egress, and require human approval for sensitive actions. Then retain evidence of what was permitted and what happened.
Five stages, five control points
- 1
1. Ingestion
Treat every shared document as untrusted. Screen it with a trained classifier rather than regex alone, scan for invisible Unicode and hidden instructions, and consider allowlisting trusted document sources. Treat screening as partial, because it does nothing for an injection it fails to detect.
- 2
2. Instruction following
Keep the instruction context separate from the retrieved-content context, and do not treat retrieved text as instructions. Prompt wording and text labels are not an enforcement boundary. Prompt hardening raises the cost of an attack but does not make it impossible.
- 3
3. Tool selection
Define an allowlist of autonomous actions and require explicit approval for anything outside it. Use separate tool sets for different trust levels, so a session that reads untrusted documents does not carry egress-capable tools.
- 4
4. Data access
Grant the minimum scope to client files. Enforce authorization in the execution component, outside the agent's context, evaluating the operation, target, arguments, and caller's authority.
- 5
5. Egress
Restrict outbound network access from agent environments. Remove tools such as email send where the task does not need them, and require approval for the egress actions that remain.
Rollout and verification checklist
- Inventory every tool the agent can call and mark which can send data outside the environment.
- Remove or withhold tools the task does not need, and split untrusted-content sessions from client file access.
- Move authorization into the execution component, evaluating operation, target, arguments, and caller authority.
- Deny outbound network access by default for agent environments and allow only named destinations.
- Require human approval for actions outside the allowlist and for high-impact actions triggered by retrieved content.
- Add adversarial and regression tests for observed injection and tool-abuse failures to CI/CD for agent templates and tool policies.
The attack path from a shared document to client file exfiltration
Agents that read shared Google Docs ingest text written by people the organization may not control or fully trust. NIST's attack taxonomy calls the underlying capability resource control: an attacker modifies documents or web pages that the model ingests at runtime, which enables indirect prompt injection. OWASP guidance on retrieval systems names Google Drive among the shared knowledge bases where multiple users or systems can upload documents. It also notes that the injected content can be staged entirely outside the target organization's control.
Once the document is in the agent's context, the model may treat its text as instructions. The text can be visible or concealed, for example with invisible Unicode characters or zero-width spaces. The attacker does not need to exploit software, because the agent already holds legitimate tool access. It can read client files and then move them out through email, link sharing, an outbound HTTP request, or a change to file-sharing permissions.
NIST's taxonomy cites research in which injection forced a model to exfiltrate user-uploaded data by querying an attacker-controlled URL with the sensitive data, and research in which an email-client agent was prompted to forward emails to an attacker-controlled inbox. The practical consequence is that a compromised agent context has the blast radius of the permissions the agent holds.
Scope permissions before writing policy
OWASP identifies privilege minimization as the most effective control. Its example is direct: an agent that cannot send email cannot be used to send phishing messages, whatever it is instructed to do. Apply the same reasoning to exfiltration. Inventory every egress-capable tool the agent can call, including email, Drive sharing changes, outbound HTTP, and tools exposed by MCP servers. For each one, ask whether the task requires it. An agent that summarizes shared documents rarely needs to send messages or alter sharing permissions.
The riskiest design combines three things in one session: untrusted content, access to client files, and a path to external destinations. Remove at least one. A common approach is to split the work, so the agent that reads shared documents has no client file access and no egress tools, and any agent with client file access never ingests untrusted documents directly. The tradeoff is more orchestration and less convenience, which is the cost of a smaller blast radius.
Network isolation is the last backstop. Restricting egress from the agent environment limits what a hijacked agent can reach, but isolation and permission controls can fail silently. Consider tripwires so a failure shows up as a signal rather than as a gap you discover later.
Enforce policy on tool calls at runtime
Permission scoping decides what the agent can attempt. Runtime enforcement decides what happens to each attempt. The decision should rest on the proposed operation, its target, its arguments, and the caller's authority, not on the content of the prompt. For example, an email send to an external recipient with an attachment from a client folder should never be decided by whether the model seems to have been given a good reason.
A workable policy returns one of four outcomes for each call:
Trussed enforces policy in the execution path across models, agents, tools, and MCP servers, applying allow, redact, block, rate limit, or escalate for human approval. The scope is individual interactions and tool calls, and enforcement happens at runtime, not after the fact. It complements the permission scoping and network egress controls above rather than replacing them.
- Allow: Calls inside the autonomous allowlist, aimed at approved targets with expected arguments.
- Redact: Calls that are acceptable once sensitive fields are removed from arguments or results.
- Block: Calls to unapproved destinations, calls outside the allowlist, or sharing changes the task never requires.
- Escalate: High-impact actions, especially those triggered by externally retrieved content, routed to a human who approves or rejects.
Evidence to retain for each tool call
After a suspected injection event, an auditor or incident responder needs to know what the agent was permitted to do and what it did. Retain the policy configuration in force, including the tool allowlist and egress rules. For each tool call, retain the timestamp, the agent and caller identity, the tool, the operation, the target, and a summary of arguments. Also keep the policy applied, the decision (allow, redact, block, or escalate), and identifiers for the files or data involved. For escalations, record who approved or rejected the action.
Keep security-relevant metadata and decisions, and leave out credentials, secrets, and sensitive prompt or response content that is not needed. Identifiers and classifications are usually enough to show which client files were touched without copying them into the evidence store. Also document residual risk and the layered controls that bound the agent's actions, since no single control removes injection.
Trussed generates audit-ready evidence as a product of enforcement, mapped to HIPAA, NAIC, NYDFS, EU AI Act, and NIST. It can be self-managed in the customer cloud, with configurable retention and data residency.
Exfiltration path and control points
Ingestion
Treat the shared document as untrusted input.
Instruction following
Keep retrieved content separate from instructions.
Tool selection
Allowlist autonomous actions and remove egress-capable tools.
Data access
Authorize each call outside the agent's context.
Egress
Restrict outbound channels and require approval.
Limit what an influenced agent can do
See how policy enforcement on individual interactions and tool calls, with audit-ready evidence, fits into your agent's execution path.
Request a DemoHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.