AI consultant How to prevent AI prompt injection when connecting internal documents to user chat
Connecting a customer-facing AI assistant directly to internal notes or emails creates a hidden security risk if untrusted text enters the prompt. Last month, a test document containing hidden formatting instructions caused our prototype assistant to ignore its normal output rules.
We fixed this by separating system instructions from retrieved context using strict XML delimiters and stripping hidden metadata before indexing any files. We also added a lightweight output filter that blocks responses containing system tags or sensitive internal field names.
Prompt boundary failures dropped to zero across two hundred adversarial test cases, allowing us to launch safely to enterprise teams. Treating retrieved text as untrusted user data keeps your assistant reliable under real-world inputs.
Wrap all retrieved document chunks inside strict structural tags separate from system rules.
Sanitize incoming text files to remove hidden formatting or embedded instructions before indexing.
p/producthunt
p/google-cloud-platform
p/meridian-16
p/runevr
p/reso
p/beamfy
p/lancetta
p/make0-brain
p/stackscope-dev
p/netfox
p/comcent
p/many-displays
p/vitals-3
p/expert-chase-deleted-1107920
p/magic-lasso-adblock
p/kodlo
p/monocloud-for-startups-free-for-1-year
p/dino-kids
Replies
What I'd add next to delimiters is limiting what the model can see and do, so a successful injection has nowhere to go. Our support replies are drafted by a model that gets the user's message and a fixed file of product facts, not the app log attached to the ticket, and it can't send anything: a person reads, edits and sends every reply. The alert we get about a new ticket carries ids and codes only, no user text.
And where a model's answer drives code, like the judge that decides whether a refused song prompt may be retried, it answers with one of three fixed verdicts. Injected text can at worst push it to the wrong verdict, it can't invent a new action.