fix: revoke public trigger privilege on net tables#259
Conversation
Make test assertions more explicit and checking for all tables in pg_net.
|
I'm taking over this bug fix from @samrose and have pushed a couple of commits. @hanefi, @za-arthur could you please do a final review before I merge it? |
There was a problem hiding this comment.
Just to make it clear, the vulnerability here doesn't have anything to do with SECURITY definer functions.
Regular INVOKER functions have the same problem because they're using the worker which uses the "initdb-created superuser" by default to execute the functions; but this can be changed with pg_net.username.
I'm not sure if this is the right fix because some users have claimed to use TRIGGER functions on the net tables so we would be causing a breaking change.
|
That's a much better alternative suggested by @steve-chavez. Basically we set
|
Sounds good to me. |
|
sounds good to me to thanks @steve-chavez and @imor |
Summary
This fixes a privilege escalation issue caused by granting
ALLtable privileges on pg_net internal tables toPUBLIC.ALLincludesTRIGGER, which allowed ordinary roles to create triggers onnet._http_response.Changes
grant all on all tables in schema net to PUBLICwith an explicit grant list that excludesTRIGGER.0.20.3to0.20.4that revokesTRIGGERon all tables in thenetschema fromPUBLIC.0.20.4.net._http_response.The previous broad grant was intended to let non-
postgresroles use pg_net after the SQL functions were changed to security invoker. That behavior should be preserved.The minimal safe fix is to remove only the
TRIGGERprivilege while keeping the table privileges needed for normal pg_net operation.Testing