Entity Framework, LinqToSQL and sql injection

人盡茶涼 提交于 2019-12-04 07:07:49

When you use those frameworks as intended, i.e. the entities/tables directly, then no. All string comparisons (i.e. where name = 'smith' ) are parameterized.

The only vulnerable spots are:

  • any string can be executed directly against the context. dbContext.ExecuteQuery(); with any kind of destructive string.

  • a stored procedure executing dynamic SQL using any parameters given

"It depends".

Plain LINQ queries against L2S or EF entities are injection safe, but you could always call a stored procedure or function that is not injection safe.

That would clearly be an edge case, but yes it happens that people write SPs/functions that are open to injection (composing SQL-in-strings with parameter values inside the proc).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!