supabase / supautils

PostgreSQL extension that secures a cluster on a cloud environment
https://supabase.github.io/supautils
Apache License 2.0
59 stars 13 forks source link

Fix bug that could cause supautils to lead to segmentation fault. #46

Closed MasaoFujii closed 1 year ago

MasaoFujii commented 1 year ago

With the setting supautils.privileged_role not set, supautils caused a segmentation fault when CREATE ROLE command was executed. ISTM that this happened because supautils_hook() unexpectedly passed "privileged_role" variable to get_role_oid() even though it's NULL. Attached patch fixes this bug.

steve-chavez commented 1 year ago

Reproduced :heavy_check_mark:.

# After removing -c supautils.privileged_role=\"$privileged_role\" from shell.nix

$ supautils-with-pg-15 psql -U rolecreator

$ postgres=> create role foo;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: 2023-02-10 17:37:47.327 -05 [338570] LOG:  server process (PID 338583) was terminated by signal 11: Segmentation fault

cc @soedirgo