There is no silver bullet. SQL injections can appear in many hidden forms and try to detect them using regular expressions or another form in your firewall, or the application can protect you from the simplest forms of SQL injection, but an experienced hacker will just go through. As AdaTheDev already noted, automated tools that check your code, such as an MS code analysis tool, can give you a hit, but again there is no silver bullet. You will need to go through your entire application.
When this is a big job, you have to make a plan. First of all, make a guide that outlines how you can reduce these types of attacks. Also try splitting your application in parts, from very critical to less critical. In this way, you can better estimate the cost of repairing errors and let the administration decide what it can cost and therefore what risk they are willing to take. The most important are parts of your application that unauthenticated users can access. If everyone (in the world) can create an account in their application, all the functionality that these users can access is extremely critical. The smaller the population and the more you trust these users, the less risk. You may be able to fix these details later. But never underestimate a good hacker. He / she can jeopardize a user account with high privileges and start testing SQL injection capabilities using this account.
Always try to have a defense strategy in depth, to have several (or many) levels of protection. For example, never contact your database as an SA from your application. Create an account with only the necessary privileges, and perhaps even create multiple SQL accounts, one account for each role (or for a group of roles). Although limiting database privileges helps mitigate the risk, again, don't rely on it as one level of protection. This article , for example, explains how a hacker can abuse an account with lower privileges when it can do SQL injection.
It's great that you ask this question here because in the past I saw a lot of developers who just do not want to know, which is very scary, because the business often trusts its developers (which is also scary).
Wish you luck.
Steven
source share