This post was originally published in 2023 and was updated in 2025.

Security is always a moving target, and PostgreSQL 15 makes important changes that close off a long-standing risk: default privileges on the public schema. For years, any new user could create objects in the public schema unless you explicitly revoked their rights. That default behavior could open the door to unauthorized changes or compliance violations if overlooked.

PostgreSQL 15 addresses this by revoking the CREATE privilege on the public schema for all users except the database owner. This update shifts ownership and access control in a way that strengthens database security out of the box.

When we create a table without specifying the schema name, it gets created in the schema, which is set as per the search_path. By default, The first part of search_path defines the schema with the same name as the current user, and the second part of search_path refers to the public schema

Postgres looks for the schemas sequentially according to the list mentioned in the search_path, so when we execute create table command, Postgres creates the table in the first schema mentioned in the search_path. If it is not present, it creates it in the following schema.

Similarly, if the schema name is not specified in the select query, Postgres will search for tables within the named schema according to the search_path.

Public Schema security upgrade in PostgreSQL 15

Up to Postgres 14, whenever you create a database user, by default, it gets created with CREATE and USAGE privileges on the public schema.

It means that until Postgres 14, any user can write to the public schema until you manually revoke the user’s create privilege on the public schema. 

Starting with PostgreSQL 15, the CREATE privilege on public schema is revoked/removed from all users except the database owner. 

In Postgres 15, now new users cannot create tables or write data to Postgres public schema by default. You have to grant create privilege to the new user manually. 

The usage privilege on the public schema for the new users is still present in Postgres 15, like in Postgres 14 and previous versions.

The example below shows that a new user (test1) can create a table in Postgres 14 without granting any privileges.

The example below shows that Postgres 15 only allows new users (test1) to create tables by granting them create privileges on the public schema.

The following example shows that the usage privilege on the public schema for the new users is still present in Postgres 15, like in Postgres 14 and previous versions.

Public schema ownership changes in PostgreSQL 15

In Postgres 14 and previous versions, by default, the public schema is owned by the bootstrap superuser (postgres), but from Postgres 15, ownership of the public schema has been changed to the new pg_database_owner role. It enables every database owner to own the database’s public schema. 

The below example shows the ownership changes between Postgres 14 and Postgres 15.

Postgres 14

Postgres 15

Visit the links below for further details about the Postgres schemas.

PostgreSQL 15’s changes to public schema privileges are a reminder that security is never “set and forget.” Every new release introduces adjustments that help you close gaps and stay compliant, but only if you know where to look and how to apply them.

If compliance and data protection are top priorities for your PostgreSQL environment, you’ll want to go deeper than schema permissions. Explore our resource How Percona for PostgreSQL Meets Compliance and Security Standards to see how you can align PostgreSQL with today’s toughest regulations while keeping full control of your deployment.

 

How Percona ensures compliance and security

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Naira

how do we revoke the default privilege that allows all user to create a table on public schema? I have tried below but not working:

  • REVOKE ALL ON ALL TABLES IN SCHEMA public FROM public, readonly;