You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
roji
changed the title
Why am I not getting warnings even for trivial SQL injection holes?
Analyzer warnings for string concatenation in raw SQL APIs
Mar 6, 2025
EF1002 is (currently) only about usage of string interpolation within the raw SQL APIs (e.g. ctx.ExecuteSqlRawAsync($"SELECT ... {foo}"), and does not cover concatenation. This is definitely something we should do.
/cc @DoctorKrolic who contributed the interoplated analyzer inplementation.
Question
I see there are at least two of warnings that should be given if there's a possibility for an SQL injection attack: CA3001 and EF1002.
No matter how egregious of a hole I'm trying to make, I get zero warnings from ExecuteSqlRaw.
In my editorconfig I have:
And I have set this for all projects via Directory.Build.Props
The projects are .NET 9 and the Microsoft.EntityFrameworkCore.Analyzers are enabled.
I get a bunch of other warnings but it seems like these injection vulnerabilities are not detected in the first place.
Can anyone actually get these warnings some way?
Your code
where the request.NameSearch comes directly from the API. Does not get any more obvious than this
EF Core version
9.0.0
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 9.0
Operating system
Windows 11
IDE
No response
The text was updated successfully, but these errors were encountered: