c# - Are SQL operator functions for Entity Framework safe against SQL injection? -


these functions give access specialty functions (sqlclient) in sql. example 'like' or 'between'. , give nicer common abstraction layer them. not confused stored procedure(s) "functions" topic of other question.

my question can't seem find full answer is. safe use, or opening system sql injection attack? use bound variables when writing regular sqlcommands.

but in moving entity framework. there less control on sql statements. don't mind it, can't worrying when concatenate string coming browser , pass function.

here example:

var queryresult = efcontext.table.where(x =>      sqlfunctions.patindex("%" + potentially_unsafe_search_keyword + "%",                            x.column) > 0); 

i did tests , traced actual sql sent server. single quotes escaped out automatically. there protection there. there sanitization taking place. insert statements use bind variables. should content single quote replacement? there else going on behind scenes?

every constant, variable, parameter in linq passed command parameter in idbcommand, in turn escaped underlying driver.

unless there bug, ef queries , sql helper functions safe against sql injection attacks.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -