agentic-rag-policy-assistant/app
Daniel Plank 6ecc5d9df7 Mitigate prompt injection via user-message wrapping + explicit guard
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
2026-11-09 22:01:10 +01:00
..
data/policies Add synthetic internal policy corpus for the RAG knowledge base 2026-11-05 18:01:48 +01:00
rag Mitigate prompt injection via user-message wrapping + explicit guard 2026-11-09 22:01:10 +01:00
tools Deterministic tools: PTO calculator and support ticketing 2026-11-05 22:55:52 +01:00
__init__.py Agent scaffolding: config, state schema, tracing 2026-11-05 22:02:14 +01:00
config.py Switch to qwen2.5:14b on GPU (RTX 5070 Ti), fix routing regression 2026-11-08 22:09:55 +01:00
graph.py Mitigate prompt injection via user-message wrapping + explicit guard 2026-11-09 22:01:10 +01:00
llm.py Streamlit UI polish: native theming, multi-chat sessions, follow-ups 2026-11-09 22:00:45 +01:00
state.py Agent scaffolding: config, state schema, tracing 2026-11-05 22:02:14 +01:00
tracing.py Agent scaffolding: config, state schema, tracing 2026-11-05 22:02:14 +01:00