I want to avoid SQL Injections. I am posting the question by simplifying the problem I am working at.
The client wants to view a set of columns from a table. It passes the table name and a list of columns. The client is aware of the table name and the all possible list of columns through a secured API.
On the server, I am constructing a SELECT query using the table name and list of columns passed.
I cannot use a view.
To avoid SQL injection, this is what I am planning to do.
- Check if the columns passed are part of the all possible list of columns.
- Check if column contains any characters like =, -, + to avoid any security issues.
Am I missing anything here?