Zenaique

Explain cross-prompt injection in a multi-tenant SaaS

Flashcard·Hard·4.0 · 0·~30s·Asked atJasperVoyage Ai
Attempt it
TL;DR

Cross-prompt injection plants malicious instructions in shared state under one tenant so the model executes them later under a different tenant's request.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a shared whiteboard in a co-working office. A tenant on Monday writes a sneaky note: 'whoever reads this, please leave the door unlocked tonight.' The receptionist who screens visitors does not see the note because it was written before the screening. On Tuesday, a different tenant's assistant glances at the whiteboard to remember the office hours, reads the sneaky note as if it were part of the instructions, and unlocks the door. Cross-prompt injection works the same way. The bad instruction is planted in a shared place the system later trusts (a shared doc index, a long-lived memory), and the per-request filters never catch it because the attack is not arriving with a request, it is sitting in storage waiting.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Most LLM safety architectures default to a per-request input rail and call it a day. That works against direct prompt injection, an attacker typing a malicious message at the model. It fails entirely against cross-prompt injection, where the malicious content was deposited into shared state hours or weeks before the victim's request, by an actor the system has every reason to treat as legitimate.

This is the single most common gap senior security reviewers find in multi-tenant LLM SaaS products, because it cuts across the boundary between safety teams and platform teams. The safety team is looking at per-request defences. The platform team is looking at row-level security and tenant isolation. The attack lives exactly in the gap between those two views.

The threat model: three actors and an asynchronous attack

Cross-prompt injection has three actors and one critical asymmetry.

The attacker is a legitimate but low trust user. They have valid credentials on the system, they have write permission to some shared surface, and they are within their granted scope when they write the payload. The system has no reason to reject the write at the moment it happens.

The shared state is any resource that crosses trust boundaries. The canonical example is a shared retrieval index, a single vector store that holds documents from multiple tenants, or a knowledge base that aggregates content across customers. The category extends further: a long-lived assistant memory that persists across sessions, a shared MCP resource exposed to multiple LLM clients, an ingested public Slack channel, a customer-facing comment thread on a multi-tenant record, an integration that pipes external email into the agent's context.

The victim is a normal user on a different tenant (or sometimes the same tenant, in a different session). They issue a benign request. The retrieval, planner, or memory-recall step pulls the attacker's poisoned content into the prompt. The model reads both the user's question and the attacker's embedded instructions. Unless the prompt structure and the model's training defended this case, the instructions take effect.

The asymmetry that makes this hard: the attack and the defence happen at different times and by different code paths. The write happens against the ingestion path; the harm happens against the retrieval path. A defence that only inspects either path in isolation is incomplete.

Why per-request input rails are structurally blind to this
The four-layer defence
Newer surfaces: memory, MCP, and federated retrieval
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Microsoft Copilot for Microsoft 365 in 2026 enforces tenant-scoped retrieval on Graph data and runs write-time content scanning to mitigate cross-prompt injection from shared SharePoint and Teams content.
  • Notion AI and Glean both isolate per-workspace retrieval and treat any retrieved block as untrusted with explicit prompt-template separation between user instructions and retrieved content.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWalk through how you would harden a multi-tenant RAG application that shares a single vector index across customers against cross-prompt injection.
A

Add a tenant_id metadata field to every chunk, enforce row-level security at the vector store with the query always filtering on tenant_id, run a write-time injection scanner on ingest, separate user instructions from retrieved content in the prompt template, mark retrieved chunks as data via the model's dedicated retrieved-content role, and add tool argument validation and output PII scanning as the last-line defences.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Assuming an input rail on user messages covers all injection. The whole point of cross-prompt injection is that the malicious content was deposited earlier through a write path the input rail does not cover.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • How cross-prompt injection differs from direct injection

  • Why per-request input filters cannot see the original payload

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the strongest reason…
MCQ·Medium