Earlier quoted context omitted.
You could (and should) run with minimal permissions which would exclude DDL.
How many applications actually do, though? At most places I've worked it's common to integrate a schema migration tool (flyway, liquibase) that requires DDL, and I've never seen anyone go to the effort of splitting out an ephemeral instance to run the migration with a separate database connection configuration.
Why We Don't Trust the Database with Authentication
21–24 of 24 posts
Re: Why We Don't Trust the Database with Authentication
#22Earlier quoted context omitted.
You could (and should) run with minimal permissions which would exclude DDL.
How many applications actually do, though? At most places I've worked it's common to integrate a schema migration tool (flyway, liquibase) that requires DDL, and I've never seen anyone go to the effort of splitting out an ephemeral instance to run the migration with a separate database connection configuration.
Re: Why We Don't Trust the Database with Authentication
#23Earlier quoted context omitted.
As explained in the article this wouldn't work, because changing your org means your stored hash is no longer valid (as the org is incorporated in the hmac), and you can't generated your own hashes because you're missing the pepper. So after changing your org all subsequent requests would fail.
But logging in gets you a new hash with your new org id, right?
I think the same HMAC(pepper, user, org) as a validation column would work. Better yet, encryption with AAD on any tenancy data if you have a TPM available.
Re: Why We Don't Trust the Database with Authentication
#24RBAC and proper prepared statements completely defeat all these scenarios.
Building an application that is immune to attack defeats all possible attack scenarios, yes. But no application is perfect or immune to all possible attacks, the concept of defense-in-depth is an acknowledgement of this.
The problem at hand is that the PostgreSQL session user has too many access rights and thus the SQL injection is able to wreck havoc.
The presented solution doesn't help because the SQL injection could probably bypass it easily through some other SQL way (custom triggers or rules to intercept the backend pepper or final tokens for example).
The right way to go about this is to create a schema or table per entity combined with authenticating a custom SQL user per customer and setting the RBAC rights for that user correctly.