Foxcolab

Glossary

SQL injection

Definition

SQL injection: An attack in which input sent to an application becomes part of the SQL query it runs, changing the query's logic so an attacker can read, modify or delete data and sometimes run administrative or system commands (OWASP).

Also known asSQLiSQL injection attackdatabase injection

In short

SQL injection is an attack in which input sent to an application becomes part of the database query it runs, changing what the query does. An attacker can read other people's records, change or delete data, and sometimes run commands on the server. Parameterized queries stop it, with allow-lists for the parts of a query that can't be parameters.

Key takeaways

  • SQL injection happens when input is pasted into query text instead of passed as data.
  • One quote character in a search box can turn "my records" into "everyone's records".
  • Parameterized queries are the primary fix. Manual escaping is error-prone.
  • Column names and sort orders can't be parameters, so map them to an allow-list.
  • Data that's end-to-end encrypted comes out of a breached database as ciphertext.

Last reviewed 4 December 2026 by Foxcolab Team

SQL injection is an attack in which input sent to an application becomes part of the database query it runs, changing what that query does. OWASP defines it as "insertion or 'injection' of a SQL query via the input data from the client to the application." A successful attack can read other people's data, change or delete it, run database administration commands and, in some setups, run commands on the server itself.

A worked example#

An invoicing app at example.com looks up a customer's invoices by pasting the name into the query text:

Python
query = "SELECT * FROM invoices WHERE customer = '" + customer + "'"

An attacker types x' OR '1'='1 into the search box. The database receives:

SQL
SELECT * FROM invoices WHERE customer = 'x' OR '1'='1'

The condition is always true, so the page lists every customer's invoices. Swap in other input and the same hole can update or delete rows.

The fix: send data as data#

OWASP's prevention cheat sheet lists the primary defenses:

  1. Parameterized queries. "Define the SQL structure separately from its data values and bind those values through the database API." The input can't change the query's shape:
Python
   cur.execute("SELECT * FROM invoices WHERE customer = %s", (customer,))
  1. Allow-lists for structure. Column names and sort directions can't be parameters, so "map user choices to a strict allow-list of fixed, application-owned values."
  2. Not manual escaping. OWASP calls it "error-prone" and "strongly discouraged."

Mistakes people make#

  • Concatenating before preparing. OWASP warns that "concatenating untrusted values into the query before preparing it defeats this protection."
  • Trusting the ORM everywhere. Object-relational mappers parameterize their normal calls, but a raw query built with string formatting is as exposed as hand-written SQL.
  • Running the app as a database administrator. A narrowly scoped account limits what an injected query can touch. See principle of least privilege.

In Foxcolab#

An injected query returns whatever the database holds. For Foxcolab's end-to-end encrypted apps, that's ciphertext: Drive files and file names, Docs and their titles, Sheets, Notes, Whiteboard boards and answers to Encrypted forms are encrypted on your device before they're stored, so Foxcolab can't read them, and neither could anyone who pulled them out of a database. That's the difference between encryption at rest and end-to-end encryption when a data breach happens.

Create a free account, or see Foxcolab for enterprise.

Keep exploring

All terms

Foxcolab

Private work tools, without the ads.

Mail, files, documents, spreadsheets and meetings in one account. Files, documents and spreadsheets are end-to-end encrypted.

Jump to