Skip to main content
edited title
Link
imans77
  • 111
  • 6

Need a Role that can CREATE USER but not allowed to GRANT Predefined Roles in PostgreSQL <16

Removed thanks and backticked properties, options and roles
Source Link

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLECREATE ROLE and CREATE DBCREATE DB roles given to them, so that they can create their own databases and new users with stricter roles. The

The problem is, with CREATE ROLECREATE ROLE permission, the user can GRANT himself "pg_execute_server_program"pg_execute_server_program role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. eE.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Update: I looked and found that ADMIN_OPTIONADMIN_OPTION has been added in PostgreSQL 16 to resolve such issue. My problem is we're using PostgreSQL version 13,14,15 and we can't just force upgrade all clusters.

Thanks.

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLE and CREATE DB roles given to them, so that they can create their own databases and new users with stricter roles. The problem is, with CREATE ROLE permission, the user can GRANT himself "pg_execute_server_program" role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. e.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Update: I looked and found that ADMIN_OPTION has been added in PostgreSQL 16 to resolve such issue. My problem is we're using PostgreSQL version 13,14,15 and we can't just force upgrade all clusters.

Thanks.

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLE and CREATE DB roles given to them, so that they can create their own databases and new users with stricter roles.

The problem is, with CREATE ROLE permission, the user can GRANT himself pg_execute_server_program role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. E.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Update: I looked and found that ADMIN_OPTION has been added in PostgreSQL 16 to resolve such issue. My problem is we're using PostgreSQL version 13,14,15 and we can't just force upgrade all clusters.

add an update section
Source Link
imans77
  • 111
  • 6

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLE and CREATE DB roles given to them, so that they can create their own databases and new users with stricter roles. The problem is, with CREATE ROLE permission, the user can GRANT himself "pg_execute_server_program" role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. e.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Update: I looked and found that ADMIN_OPTION has been added in PostgreSQL 16 to resolve such issue. My problem is we're using PostgreSQL version 13,14,15 and we can't just force upgrade all clusters.

Thanks.

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLE and CREATE DB roles given to them, so that they can create their own databases and new users with stricter roles. The problem is, with CREATE ROLE permission, the user can GRANT himself "pg_execute_server_program" role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. e.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Thanks.

We are administrating DB in kubernetes to our customers. For each new cluster, we create a new user with CREATE ROLE and CREATE DB roles given to them, so that they can create their own databases and new users with stricter roles. The problem is, with CREATE ROLE permission, the user can GRANT himself "pg_execute_server_program" role, and then use reverse shell attack and then get shell from our pod and read the environment variables, which is not desired. e.g. we have several secrets in env vars that the customer can take advantage of and then increase their attack range and take over more things.

In short, I want to have a user that can create new users, but can't grant himself specific predefined roles.

Update: I looked and found that ADMIN_OPTION has been added in PostgreSQL 16 to resolve such issue. My problem is we're using PostgreSQL version 13,14,15 and we can't just force upgrade all clusters.

Thanks.

make the title more descriptive
Link
imans77
  • 111
  • 6
Loading
Source Link
imans77
  • 111
  • 6
Loading