Is LINQ for NHibernate susceptible to SQL injection and other security threats affecting raw sql

I did a search on the Internet, but I could not find reliable answers. Is LINQ for NHibernate susceptible to SQL injection and other raw SQL attacks? If so, what codes illustrate how to avoid such database attacks?

+4
source share
1 answer

Not.

SQL injection usually works using string formatting. The arguments used in LINQ expressions are safe. The provider will handle SQL generation in such a way that fuzzy SQL in the arguments will not be executed, and the arguments will be limited to existing ones, as they are defined.

In addition, under the hood, it uses parameterized SQL queries that are immune to injection attacks.

+7
source

Source: https://habr.com/ru/post/1398951/


All Articles