Home › Cybersecurity wiki › What is SQL injection?

Wiki

What is SQL injection?

SQL injection is a fault in which an application places parts of an input into a database query so that the database understands them as part of the instruction.
The application means data, the database sees an altered command.
The fault sits in the way of assembling the query, not in the database as such.

Understanding SQL Injection

Understanding SQL injection means seeing the boundary between the fixed command and the value that comes from the user.
If the value is merely appended, its content can shift the meaning of the query.
If it is passed as a separate parameter, it remains a value even when it looks strange.

Types of SQL Injection

Types differ according to whether the result of the altered query appears directly in the response, whether it becomes visible through side effects such as time or error messages, or whether the query acts in the background.
All types share the same cause, the mixed handover of command and input.
The fitting correction is therefore the same, regardless of visibility.

How SQL Injection Works

How SQL injection works is that the application builds a text of the query and inserts the input into it.
Characters in the input end the intended value and append further instructions that the database executes.
A correctly separated handover treats the same characters as the content of the one value.

Preventing SQL Injection

Prevention relies on queries with separate parameters, on the smallest possible rights of the database account, and on a check that lets through only the expected form of inputs.
Error messages to the user do not name internal details of the query.
This construction applies to every place where a query is formed from inputs, including internal interfaces.

Use of Web Application Firewalls

Web application firewalls can recognize oddities in requests and block them before they reach the application.
They are an additional layer for known patterns and for urgency while the application is not yet corrected.
They do not replace the separated handover of parameters, because a new formulation can pass a pattern.

Impact of SQL Injection on Cybersecurity

The impact on cybersecurity is reading or changing data, bypassing sign-ins, and acting with the rights of the database account.
A single public input can thereby reach the body of data that the application otherwise sees only internally.
The priority of the correction follows that reachability.

Conclusion

SQL injection stays avoidable by keeping commands and values separate and by giving the database only the rights the application really needs.
A firewall can bridge the time until the correction.
After a suspicion, affected data are scoped and credentials that point beyond the application are reviewed.