Giving access to execute SQL queries on a static database

52 views Asked by At

I am working on a project where i want to give people the possibility to execute SQL queries on an PostgreSQL database. I then only need to prevent people from hacking/attacking my database.

I thought that maybe a way to do that, is by giving only view access to de database connection. And using EXPLAIN ANALYSE to calculating the cost of the SQL query.

Is EXPLAIN ANALYSE trustworthy enough to make sure there are no cheap ways to get the website down?

Do you have suggestions?

1

There are 1 answers

2
AudioBubble On

EXPLAIN ANALYSE will execute the query, including any side-effects it may have. PostgreSQL also allows running arbitrary Perl and Python code if configured to do so, so be careful. You're likely better off running PostgreSQL instances in per-request VMs or in similar highly isolated environments.