Does using parameterized SqlCommand make my program immune to SQL injection?

后端 未结 5 1728
故里飘歌
故里飘歌 2020-11-27 19:12

I\'m aware that SQL injection is rather dangerous. Now in my C# code I compose parameterized queries with SqlCommand class:

SqlCommand command = ...;
command         


        
5条回答
  •  [愿得一人]
    2020-11-27 19:25

    SQL Injection is mostly dependent on execution of dynamic SQL. In other words, SQL statements constructed by the concatenation of SQL with user-entered values.

    To avoid SQL Injection completely,

    Protecting yourself against SQL injection attacks is not very difficult. Applications that are immune to SQL injection attacks validate and sanitize all user input, never use dynamic SQL, execute using an account with few privileges, hash or encrypt their secrets, and present error messages that reveal little if no useful information to the hacker. By following a multi-layered approach to prevention you can be assured that if one defense is circumvented, you will still be protected.

    From MSDN

提交回复
热议问题