We're trying to create a asp.net page that gives our users the ability to pull information directly from their own database to our website. The user will have the ability to provide:
- hostname, port, database name, username, password, and query.
I have some serious security concerns regarding this and was wondering how this page could be secured so that we're preventing users from pointing to the localhost database or other type hacks that could enable them to have access to our database. Can anyone please advise?
We're using SqlConnectionStringBuilder to build the connection to the user's database and doing some simple checks to ensure that the host cannot be "localhost" or other addresses that point to our server. I feel like doing this leaves a potential security holes open.
Also, the query that they provide is checked against some keywords that shouldn't be allowed. Again, I think this leaves a lot open if not properly implemented. (We essentially want them to only be able to do a SELECT from their own DB).
Finally, we do an EXEC sp_executesql with the query of the user.
I'd love to hear how others have dealt with this? Klipfolio is an organization that has a similar type functionality so if anyone knows how they've addressed this issue, that would be really awesome!!
Thanks!