I've made the ability to sort page content dynamically through two query strings and dynamic LINQ. Today I just realized I can use this in an unintended way.
Intended
Typically I would provide the query string parameters Sort.Field=SomeField
and Sort.Direction=desc
and this would allow the sorting to be set via query.OrderBy(field + " " + direction)
in the code.
Unintended
Today I learned I can provide something like Sort.Field=Modified.On != null ? Modified.On : Created.On
and Sort.Direction=desc
.
Being able to do this isn't dangerous itself, but it has left me feeling a bit uneasy as to what is possible with Dynamic LINQ.
Are there any other security issues that can occur that I never intended, via this injections of sorts?
Note
I did read this question/answer but that seems to be more aimed at escaping characters, where my concern is what dynamic LINQ's OrderBy
function is capable of.