liveBook · Manning

SQL injection

As explained in Fundamentals of Cybersecurity

SQL injection is an attack technique that manipulates an application's database queries through crafted input to execute unintended database operations.

SQL injection occurs when a web application puts crafted user input directly into a database query without proper validation or sanitization. The database may then execute the attacker’s instructions along with the intended query. section 12.3.2

A crafted login input

A normal query might look for a user named Alice: SELECT * FROM users WHERE username = 'Alice'. Replacing the username with ' OR 1=1 -- can make the condition always true, potentially returning every user row in the browser. section 12.3.2

Exposed database rows can put information at risk. SQL injection is one of several scripting attacks that exploit application weaknesses to gain unauthorized access or manipulate data. section 12.11 section 12.3.2

Figure 12.3 Illustration of an SQL Injection (SQLi) attack.

Illustrates how crafted input can affect a database query. section 12.3.2

How Fundamentals of Cybersecurity covers it

How deep it goes
Defines the input-handling flaw and works through a query and crafted payload.
Examples
Uses a username query for Alice and the payload ' OR 1=1 -- to show possible exposure of user rows.
What you can do after
Understand how crafted input can change a database query and expose stored information.
How it connects
Links SQL injection to SQL, web applications, input validation, and scripting attacks.

Also explained in

Compare how 12 books explain SQL injection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fundamentals of Cybersecurity. The section links point to the parts of the book it draws on.