mirror of
https://github.com/open-webui/open-webui
synced 2025-03-15 18:12:19 +00:00
log: added a debug log if detecting a potential prompt injection attack
This commit is contained in:
parent
b4ad64586a
commit
e872f5dc78
@ -198,6 +198,12 @@ def rag_template(template: str, context: str, query: str):
|
|||||||
f"RAG template contains an unexpected number of '[context]' : {count}"
|
f"RAG template contains an unexpected number of '[context]' : {count}"
|
||||||
)
|
)
|
||||||
assert "[context]" in template, "RAG template does not contain '[context]'"
|
assert "[context]" in template, "RAG template does not contain '[context]'"
|
||||||
|
if "<context>" in context and "</context>" in context:
|
||||||
|
log.debug(
|
||||||
|
"WARNING: Potential prompt injection attack: the RAG "
|
||||||
|
"context contains '<context>' and '</context>'. This might be "
|
||||||
|
"nothing, or the user might be trying to hack something."
|
||||||
|
)
|
||||||
|
|
||||||
if "[query]" in context:
|
if "[query]" in context:
|
||||||
query_placeholder = str(uuid.uuid4())
|
query_placeholder = str(uuid.uuid4())
|
||||||
|
Loading…
Reference in New Issue
Block a user