Re: BUG #18281: Superuser can rename the schema with the prefix "pg_" (Applies to all versions of postgresql)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "szyjek9302(at)gmail(dot)com" <szyjek9302(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18281: Superuser can rename the schema with the prefix "pg_" (Applies to all versions of postgresql)
Date: 2024-01-10 16:45:29
Message-ID: 2434705.1704905129@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Wednesday, January 10, 2024, PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>> I renamed the schema pg_toast
>> moja=# alter schema pg_toast rename to x_pg_toast
>> moja-# ;
>> ALTER SCHEMA
>> and can't undo it because :
>> moja=# alter schema x_pg_toast rename to pg_toast;
>> ERROR: unacceptable schema name "pg_toast"
>> DETAIL: The prefix "pg_" is reserved for system schemas.
>>
>> I think this is a serious problem that should be fixed by developers. The
>> superuser should not be able to rename system schemas.

> This isn’t a bug - there is very little effort spent on trying to prevent
> the superuser from doing stuff, even stuff that directly breaks their
> system.

Indeed. Try something like "delete from pg_proc;" (not in a database
you want to keep!). This is not significantly different from the fact
that root privilege in Unix allows you to do unrecoverable stuff like
"rm -rf /". The cost/benefit ratio just isn't there for trying to
put training wheels on root, or on superusers.

> I do agree that there seems to be some room for improvement here, at least
> as far as recovering from the initial bad decision goes.

A manual update on pg_namespace.nspname would be enough for getting
out of this particular problem.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2024-01-10 18:00:01 Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger
Previous Message Peter Geoghegan 2024-01-10 15:11:49 Re: BUG #18279: Duplicate key violation and Deadlock when using ON CONFLICT/DO UPDATE with multiple unique indexes