Reputation: 387
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.
Am I missing anything here?
Upvotes: 1
Views: 179
Reputation: 18408
Query the catalog to check that the entered table name really exists in the database. (And likewise for checking that the entered column names really are columns of the named table.)
Upvotes: 4