How can I avoid SQL injection attacks in my ASP.NET application?

前端 未结 16 2038
死守一世寂寞
死守一世寂寞 2020-11-27 20:16

I need to avoid being vulnerable to SQL injection in my ASP.NET application. How might I accomplish this?

16条回答
  •  失恋的感觉
    2020-11-27 21:00

    Never trust user input - Validate all textbox entries using validation controls, regular expressions, code, and so on

    Never use dynamic SQL - Use parameterized SQL or stored procedures

    Never connect to a database using an admin-level account - Use a limited access account to connect to the database

    Don't store secrets in plain text - Encrypt or hash passwords and other sensitive data; you should also encrypt connection strings

    Exceptions should divulge minimal information - Don't reveal too much information in error messages; use customErrors to display minimal information in the event of unhandled error; set debug to false

    Useful link on MSDN Stop SQL Injection

提交回复
热议问题