Postgresql – How safe are PostgreSQL triggers against attacks

postgresqlSecurity

in my PostgreSQL database I setup some triggers to prevent DELETE and EDIT operations (the triggers make sure that these operations lead to nothing). However, I'm wondering how safe these triggers are? Is it possible to circumvent these triggers and delete data by trying to illegally hack the data?

Best Answer

Security in ANSI relational databases is normally based on layers and one of those is role based access. A business case that no one will ever need to delete or edit data in some tables will probably need to be revised when someone makes an oopsie and bad data is entered.

Any code that is written whether it's in a trigger or stored procedure has a chance of being misused but this requires access. A better solution than writing triggers that prevent basic operations on data is to control access and permissions by creating roles for each type of user and granting permissions appropriate to those roles.