Skip to content
SQL injection Write-up Beginner

The Art Of Breaking Your Sql Powered Ai Chatbot After Building It

A chatbot that turns natural language into SQL and runs it against a SQLite database accepted raw SQL typed by the user, so the model passed it straight through to the database. An attacker could list every table and read the users table, including admin and customer details.

Yuvarajan Follow

Published on infosecwriteups.com

Hello Hackers!!! Ever wondered how AI chatbots with API and database access get compromised?

Yuvarajan, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the AI-generated SQL was executed directly with no validation or parameterisation, and the model passed user-supplied SQL through unchanged.

Impact

An attacker could read the contents of the users table, including admin credentials and customer details, though the model's built-in safety blocked some malicious inputs.

What the attacker needed

Access to the chatbot interface; none

The fix

The bot should use parameterised queries, validate input, sanitise AI-generated SQL, give the chatbot a read-only database role and hide database errors; the text does not say it was fixed.

How it was found

  1. Send a simple SQL query to the chatbot and confirm it is accepted.
  2. Try a malicious query; the model's built-in safety blocks it.
  3. Ask the bot to list all tables in the database.
  4. Query the users table to extract admin and customer details.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The chatbot was built to translate plain questions into database commands. But it also accepted database commands typed directly by the user and ran them without checking. That let anyone ask the database to show its own list of tables and then read private user records.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by Yuvarajan

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.