Avoid SQL Injection Attacks

As you just saw, attackers can cause a lot of damage with database injection. We’ll now look at four main defense methods to protect against this kind of attack: controlled error messages, input validation, escaping, and prepared statements.

Database injection attacks are divided into two types: blind and normal SQL injection. In normal SQL injection the attacker will see helpful error messages and/or the result of the attack on the web page. With blind SQL injection, the attacker sees only generic error messages if something is not valid.

In case of blind SQL injection attackers frequently append true-false statements such as and 1=2 or and 1=1 at the end of the query to see the different messages associated ...

Get Secure Your Node.js Web Application now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.