So this is extremely eye-opening to me, it's essentially an XSS vulnerability for AI. My previous thinking was naive, it's not enough to just treat AI output like it's coming directly from the user. Any source of data it takes in is a potential attack vector if you're not careful. I was greatly underestimating the potential impact of prompt injections.
It's a really interesting, novel approach. And it's the kind of thing where you see it and think, "how did I never think of that, how did that never occur to me?" Great paper. Seriously, thank you for doing this research.
Here’s the kind of approach I’ve been using:
https://github.com/williamcotton/empirical-philosophy/blob/m...
The initial call to the LLM will return a completion that includes JavaScript. There is no third-party data at this point. The JavaScript includes further calls to the LLM that returns JSON, but at this point no further calls are made to the LLM. This means that responses from remote queries are never sent to an LLM. The text presented to the user could be some instructions to talk like a pirate but all the user suffers from is a surprisingly incorrect result.
Even with LangChain the issue is the chatbot UX. LangChain can also be used in ways that make it not vulnerable to this problem.
Orthogonally, I don’t think that chatbots are a very good UX in general and that there are much better ways to interact with an LLM. If anything your work should accelerate this process!