A New Weak Point in Apps That Embed AI: Prompt Injection
How do you deal with an attack that has no complete defense? This explains how to build a structure where being fooled does no damage, and the routes other than input fields through which instructions can slip in.

Ren

Wilson

Ren

Procura
The decisive difference from SQL injection
With SQL, there's a mechanism for passing commands and data separately, so if you use it correctly they don't get mixed. Instructions to an AI have no such separation, and the model decides from context where the commands end and the content to be read begins. So this isn't the kind of problem you can prevent by "writing it cleverly".

Procura

Ren

Procura
Protect it through design
- Don't give the AI strong permissions. Don't let it read or delete from the database on the AI's judgment alone
- Don't put the AI's output on screen as is (if it's interpreted as HTML, it leads to XSS, where a malicious script runs on the page)
- Don't execute the AI's output as is as a command or SQL
- Always have a human confirm before important operations
- Be especially wary when you let the AI read text imported from outside (web pages, email, PDFs)

Procura

Ren

Wilson

Procura
- The contents of a fetched web page
- The body of received email or contact messages
- Uploaded document files
- Data imported from an external API
- Text that appears in an image can also be a target

Procura
Make sure you can notice

Procura
- Record what you passed to the AI and what came back
- Keep a history of the operations the AI performed
- Count how many times unexpected operations were attempted, so you can tell when the number rises

Ren
This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.