Mitigate prompt injection via user-message wrapping + explicit guard #64
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feature/prompt-injection-mitigation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
None of the prompts that embed the raw user message (classify_intent,
direct_response, synthesize_response, and the RAG grade/rewrite/generate
steps) distinguished user-typed content from instructions to the model.
Wrap the user message in a <user_message> tag
(app/llm.py::wrap_user_input, added in the previous commit) and prepend
PROMPT_INJECTION_GUARD, an explicit instruction telling the model to
treat that block strictly as data, never as commands - even if it
claims system/developer/admin authority. wrap_user_input also strips
any literal occurrence of the tag from the input so a crafted message
can't fake a closing tag and escape the wrapper.
This is a meaningful mitigation, not a hard guarantee - documented as
such in the README's "Known limitations" section.
Refs #15