0

I have this controller method below:

[HttpPost]
public ActionResult Login(UserDetails userdetails)

What did I do so far ?

  1. Replaced potential SQL Candidates in my form (via JQuery side , eg. replace '&' by 'amp')
  2. I have added ModelState.IsValid() in ServerSide to check.

Are these two checks enough or How should I make sure that userDetails.UserName is free from Injected SQL ? (Like 1=1 SQL Injection attacks)

1 Answers1

1

Using Entity Framework, Dapper or regular parameterized query should be sufficient enough.

Roman Svitukha
  • 1,302
  • 1
  • 12
  • 22
  • I'm already using Entity framework. Does it mean, EF is free from SQL Injection Attacks altogether ? – now he who must not be named. Sep 07 '18 at 19:56
  • 1
    Yes if you are using parameterized queries or LINQ. Although query composition is possible in LINQ to Entities, it is performed through the object model API. Unlike Entity SQL queries, LINQ to Entities queries are not composed by using string manipulation or concatenation, and they are not susceptible to traditional SQL injection attacks. (ref :https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/ef/security-considerations) – Roman Svitukha Sep 07 '18 at 20:01