SQLi via LLM

UNION-based SQL injection through AI-generated text-to-SQL queries.

What you practise

Text-to-SQL abuse and injection through model output. You run the attack yourself on a live model in a private sandbox set up for you, then capture the flag. Nothing to install and no API key.

Why text-to-SQL is the same bug class as ' OR 1=1 --

Parameterized queries solved 1999-era SQLi by separating code from data at the driver level. Text-to-SQL re-merges them: the entire SQL string is generated by a model that also reads the user's input. There's no parameter boundary left. The fix is the same as it was 25 years ago, never let untrusted text become executable code without an allowlist or a real parser in between.

Where this has happened

  • LangChain SQLDatabaseChain (2023): Multiple researchers demonstrated UNION-based extraction from text-to-SQL chains; LangChain eventually added a 'use_query_checker' wrapper that itself uses an LLM to validate the LLM's output.
  • Vanna.AI prompt injection (Jun 2024): CVE-2024-5565: prompt injection in Vanna's text-to-SQL led to RCE because the generated Python plot code was also executed unsandboxed.
  • ChatGPT Advanced Data Analysis (2023): Users extracted sandbox file contents and source code by manipulating the natural-language-to-Python pipeline, same shape as text-to-SQL, different target language.

Sign in to launch this lab Learn the theory in the Academy

More Foundations labs

Attack labs

20 hands-on scenarios across 4 tracks. Pick a target, launch a private sandbox, capture the flag.

Active sessions

Resume a running lab or stop it before starting the next one.