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:
query = "SELECT * FROM invoices WHERE customer = '" + customer + "'"An attacker types x' OR '1'='1 into the search box. The database receives:
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:
- 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:
cur.execute("SELECT * FROM invoices WHERE customer = %s", (customer,))- 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."
- 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.
Keep exploring
Related terms
- Cross-site scripting (XSS)Cross-site scripting lets an attacker run their own script inside a trusted website, in other people's browsers. Here are the three types, an example and the defenses that work.
- Data breachA data breach is any security incident in which information is accessed, disclosed, lost or made unavailable without authorization. Whether stolen data is readable decides how bad it is.
- Principle of least privilegeLeast privilege means every person, program and process gets only the access its current task needs, for only as long as it needs it.
- Encryption at restEncryption at rest protects stored data on disks, databases and backups. Whether it protects you from the provider depends entirely on who holds the keys.
- End-to-end encryption (E2EE)End-to-end encryption keeps data encrypted from the sender's device to the recipient's device, so the servers in between only ever handle ciphertext.
Where Foxcolab uses it

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.