Changes to SQL injection

TechWritereditor · 5 Dec 2026, 05:27 · “New page”

+ added − removed (first version)

Title

Removed:  
Added: SQL injection

Short description

Removed:  
Added: Attack that slips malicious SQL into a database query

Type

Removed:  
Added: technology

Summary

Removed:  
Added: SQL injection is an attack in which someone types database commands into a website or app's input so that the application runs them, letting the attacker read or change data. It is prevented mainly by using parameterised queries.

Fact box

Removed:  
Added: Type: Code injection vulnerability
Added: Target: Applications using SQL databases
Added: First public discussion: 1998
Added: Described by: Jeff Forristal ("Rain Forest Puppy")
Added: Weakness ID: CWE-89
Added: Main defence: Parameterised queries

Article

Added: **SQL injection** is an attack in which an [[SQL]] query is inserted, or "injected", through the input data a client sends to an application.[^1] It happens when a program builds a database command from outside input without properly removing or quoting SQL syntax, so the input can change the meaning of the command.[^2]
 
Added: ## History
Added: The first public discussion of the technique is credited to the security researcher Jeff Forristal, who wrote under the name Rain Forest Puppy, in 1998 while researching a Windows NT server.[^3] The weakness is catalogued by MITRE as CWE-89 and has appeared in every edition of the CWE Top 25 most dangerous software weaknesses list from 2019 to 2025.[^2]
Added:  
Added: ## How it works
Added: Many applications combine user input with a fixed SQL command to look up records in a [[Relational database]]. If the input is pasted straight into the command, an attacker can type text that ends the intended value and adds conditions of their own. In an example given by OWASP, entering `name' OR 'a'='a` as an item name makes the query's condition always true, so it returns every row in the table, including other users' data.[^1]
Added:  
Added: A successful attack can read sensitive data, insert, update or delete records, carry out administrative operations on the database, retrieve files from the database server and, in some cases, issue commands to the operating system.[^1] OWASP notes that it has been especially common in [[PHP]] and ASP applications because of older programming interfaces.[^1]
Added:  
Added: ## Prevention
Added: The main defence is to use prepared statements or parameterised queries, which keep the SQL command separate from the data supplied by users.[^1][^2] Manually escaping special characters can help but does not make an application secure.[^1] Other recommended measures include running database accounts with the fewest privileges needed, validating input, and limiting the detail shown in error messages.[^2]
Added:  
Added: ## See also
Added: - [[SQL]]
Added: - [[Relational database]]
Added: - [[PHP]]
Added: - [[Firewall (computing)]]

Sources

Removed:  
Added: SQL Injection | https://community.owasp.org/attacks/SQL_Injection | OWASP Foundation
Added: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | https://cwe.mitre.org/data/definitions/89.html | MITRE
Added: How Was SQL Injection Discovered? | https://www.esecurityplanet.com/networks/how-was-sql-injection-discovered/ | eSecurity Planet | 2013-11-25

Categories

Removed:  
Added: Online security

Other names

Removed:  
Added: SQLi
Added: SQL injection attack