-
Notifications
You must be signed in to change notification settings - Fork 126
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
Bug: Sort Columns are no longer being verified #1049
Comments
We have made a fix for an almost identical scenario via this request (#963) and that affects this use-case. The main reason of change was because of RepoDB's poor column projection in the older versions. Let us say you have the table schema below.
And you do the query below. var result = connection.Query("Person", fields: Field.From("Id", "Name"), orderBy: new OrderField("Created", Order.Ascending)); In the previous version of the library, it will throw the This is a bug as we limit the available orderable columns based from the target selected columns and not from the actual table columns during the projection. To rectify this, you have to include the var result = connection.Query("Person", fields: Field.From("Id", "Name", "Created"), orderBy: new OrderField("Created", Order.Ascending)); We can (of-course) re-apply the same level of validation in the library by simply checking the orderable columns from the list of columns from the actual table, but we have decided not to proceed with it as we prefer SQL Server to throw this raw exception back to the caller. Is there something we can adjust on the test cases on the cookbook itself? |
The danger in that is it's a SQL injection vulnerability if the end user can choose the order by column. To avoid this risk, either the ORM or the application needs to check the column list.
If that will move the error outside of SQL Server, then it will pass the test. Otherwise we need to check it manually like we do in the ADO.NET implementation. |
We can do revert this behavior again with more strict validation against the actual table columns. Thanks for filing this incident |
Bug Description
RepoDB 1.12.9 with RepoDb.SqlServer 1.1.4 will throw MissingFieldsException if a sort column doesn't exist.
RepoDB 1.12.10 with RepoDb.SqlServer 1.1.5 will pass the invalid sort column to the database.
If the sort column is user-supplied, this may result in a SQL injection vulnerability.
Expected Exception Message:
Actual Exception Message:
Depending on the exact sort column, no exception may be returned.
Schema and Model:
Please share to us the schema of the table (not actual) that could help us replicate the issue if necessary.
And also the model that corresponds the schema.
Library Version:
RepoDB 1.12.10 with RepoDb.SqlServer 1.1.5
The text was updated successfully, but these errors were encountered: