Limit semicolon to prevent SQL injection?

I saw that SQL injection strings are often constructed as follows:

' ; DROP DATABASE db  --

Therefore, if I prohibit the use of semicolons in the inputs of my applications, does this prevent a 100% SQL injection attack?

+5
source share
6 answers

No, this does not prevent SQL injection attacks. Every time you dynamically create SQL, either on the client side or with EXEC inside the stored proc, you run the risk.

Parameterized queries are the preferred way to enter your query into a query.

+8
source

( ) SQL .

, .

;, (, VARCHAR CHAR, ). SQL, / .

SQL , ( ).

+8

, . SQL-. , , .

, , , ', . SQL-.

+4

SQL- - , . , .

+3

, . , sql - - . , regexp sql .

+2

it will depend on a lot of things (requests, etc.). you should use prepared instructions for this

+1
source

All Articles