psql internals queries breaks in presence of user-defined operators
psql internals queries breaks in presence of user-defined operators
Hi! If a user creates a malformed operator in theirs database, like: ``` create or replace function f (name, name) RETURNS boolean AS $$ begin RETURN $1::text = $2::text; end; $$ LANGUAGE plpgsql; CREATE OPERATOR public.!~ ( LEFTARG = name, RIGHTARG = name, FUNCTION = f); ``` then psql's meta-commands queries like \du stop working. That's because the catalog misses operators for leftarg = name, rightarg = name and oprname = '!~'. I think this can be enhanced a little by schema-qualifying psql's internal query. While this issue is fully the user's fault, I think psql can still be a little more conservative in operator selection, and work anyways. PFA POC patch. This is not a security issue, per: https://www.postgresql.org/docs/current/app-psql.html says: If untrusted users have access to a database that has not adopted a secure schema usage pattern, begin your session by removing publicly-writable schemas from search_path. -- Best regards, Kirill Reshke
Re: psql internals queries breaks in presence of user-defined operators
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Kirill Reshke writes: > If a user creates a malformed operator in theirs database, like: > ... > then psql's meta-commands queries like \du stop working. Yup. > I think this can be enhanced a little by schema-qualifying psql's > internal query. This has been discussed and rejected before. Fully schema-qualifying those queries would make them unreadable and close to unmaintainable. And before you say that readability doesn't matter here: you're wrong. Lots of people look at these queries via "psql -E" to see how to query the catalogs. regards, tom lane