-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String values are not escaped in CONTAINS function #667
Comments
MySQL (unlike other databases) allows limited special character escape sequences in string literals. You can avoid this by using NO_BACKSLASH_ESCAPES. |
Thanks, but setting server side modes globally might not be an option for everyone - consider shared database scenarios, for instance. How can this be provided session-wise? Plus, I am still convinced that trusting in EF connectors to generally abstract the database behaviour (aside from advertised limitations) is quite common. So, unless stated otherwise in the connector's documentation, linq queries are expected to be safe without further action:
So in fact I have to correct the expected result mentioned in the issue - it should reference parameters instead of providing escaped input. |
SQL mode can be set at the session level using We also welcome PR's, see Call for Contributors for more details. It would also be of interest to see if the MySql.Data.EntityFrameworkCore escapes that input, could you test against that provider? |
MySql.Data.EntityFrameworkCore behaves exactly the same: No parameters, no escaping. I'll try and come up with a solution proposal in the next few days. |
per exceptions caused by PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#667 ref #357
per exceptions caused by PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#667 ref collinbarrett#357
Steps to reproduce
Executing
(with
Name
being a string field) resolves towhen the expected resulting SQL query would be
The issue
In my case, this only results in zero rows regardless whether those values exist in the database.
Potentially this opens vulnerabilites for SQL injection attacks whenever developers rely on input being escaped by the EF connector (i. e. a lot, I suppose). I have not checked whether other queries are affected as well or if this behaviour is limited to contains function calls.
Further technical details
Pomelo.EntityFrameworkCore.MySql version: 2.1.0
The text was updated successfully, but these errors were encountered: