top | item 24326215

(no title)

rubber_duck | 5 years ago

>That makes connection pooling difficult and presents its own security issues on limiting the tenant to only their DB user.

Can you use SET LOCAL ROLE <user> on each transaction ?

discuss

order

treis|5 years ago

If you do it that way then you don't gain much security. Any SQL exploit would just need to add the Set Local Role to break out of the tenant row level security. Any code error would (probably) still allow unauthorized access because that error will likely also set the incorrect user.

It adds a layer of security so it might prevent some bugs leading to exploits. But in itself is not enough to rely on to separate tenants.

rubber_duck|5 years ago

Well if you have SQL injection bugs then you have bigger issues to worry about - I've used this to enforce multi-tenancy on database access level (like another poster said - preventing queries accessing wrong data by accident, which is far more common I think).

kevincox|5 years ago

If you are running a copy of the same software for each tenant anyways it doesn't matter much as a SQL injection for one tenant is most likely available on all tenants.

I think for this use case security is focused on accidentally returning the wrong tenant's data (fully or partially)