How do I write a secure python script for connecting GPTs to SQL databases to prevent prompt injection attacks on user data
Download run
Fan-out diagram
The searches the AI actually ran for this prompt.
SEED QUERY
How do I write a secure python script for connecting GPTs to SQL databases to prevent prompt injection attacks on user data
3 real searches · 1 real-search pass
OWASP LLM Prompt Injection Prevention Cheat Sheet least privilege tool permissions SQL parameterized queries Python database securityGoogle ↗
OBSERVEDInstruction
Python DB-API parameterized queries SQL injection prevention official documentation sqlite3 placeholdersGoogle ↗
OBSERVEDInstruction
OpenAI API function calling tools security validate arguments application authorization documentationGoogle ↗
OBSERVEDInstruction
Badge and edge weight = share of passes that produced the query. Hover a query for its intent and routing format.
Query classes
Google's semantic query class for every sub-query: what kind of answer each search is after, simulated vs real.
ChatGPT real searches (3)
Classes come from the query-classifier (a local Laya model). 3 of 3 calls are low-confidence (under 50%) — hover a query in the table to see its confidence.
Searches and sources
ChatGPT3 real searches · gpt-6
OWASP LLM Prompt Injection Prevention Cheat Sheet least privilege tool permissions SQL parameterized queries Python database security Google ↗
Python DB-API parameterized queries SQL injection prevention official documentation sqlite3 placeholders Google ↗
OpenAI API function calling tools security validate arguments application authorization documentation Google ↗
- CheatSheetSeries/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.md at master · OWASP/CheatSheetSeries · github.com
- SQL Injection Prevention · cheatsheetseries.owasp.org
- sqlite3 — DB-API 2.0 interface for SQLite databases · docs.python.org
- Function calling · developers.openai.com
- Function Calling in the OpenAI API · help.openai.com
- LLM Prompt Injection Prevention · cheatsheetseries.owasp.org
- Database Security · cheatsheetseries.owasp.org
Queries
3 queries · click a column to sort
| Query / type | Search | Intent | Query class | Routing format | Cluster | Freq ↓ | Weight |
|---|---|---|---|---|---|---|---|
OWASP LLM Prompt Injection Prevention Cheat Sheet least privilege tool permissions SQL parameterized queries Python database security OBSERVED | Google ↗ AI Mode ↗ | — | Instruction | — | — | 1x of 1 | |
Python DB-API parameterized queries SQL injection prevention official documentation sqlite3 placeholders OBSERVED | Google ↗ AI Mode ↗ | — | Instruction | — | — | 1x of 1 | |
OpenAI API function calling tools security validate arguments application authorization documentation OBSERVED | Google ↗ AI Mode ↗ | — | Instruction | — | — | 1x of 1 |