Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBzWQ-0001SE-16 for pgsql-admin@arkaria.postgresql.org; Wed, 21 Jun 2023 15:13:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qBzWO-0001I3-RR for pgsql-admin@arkaria.postgresql.org; Wed, 21 Jun 2023 15:13:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBzWO-0001Ht-6i for pgsql-admin@lists.postgresql.org; Wed, 21 Jun 2023 15:13:24 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qBzWK-003qEi-D0 for pgsql-admin@lists.postgresql.org; Wed, 21 Jun 2023 15:13:23 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-56fff21c2ebso64447497b3.3 for ; Wed, 21 Jun 2023 08:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; t=1687360398; x=1689952398; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=Kqmb3rprEzIGwVb4ekH9Sq91ZgkEnr2Z+Sr1UJaSw4Q=; b=irg/NbK5+h78uzwF+zNW4m+xIwQVmYhcC68AHSwFSM4IKzTUVnZ5rXhkW7GMjjeowb NSLgiyl0phEInNy4ygYFAJsAJqss2IbCZBnr4upRTpHMmqhXq8tXlhGOAB2aK7IRSHnp RxQVhakDuFYNc66TGEHQ3pfJdiLKlzXcg9JrKsrNfOiQ6E0ND+Q0mst1VktqyLg68zG1 C0Q1lVNlHqOOi8G+T6gTDpNg/TAV4lH8sv0uQ+R02JbXQipEYUi6Z3AiDBcu7FqBfsGN q2j7WdBHuUuWbIpigGpFTc+WaF7O93VJ6RGnowIDGTdTNSrNAq3g2o7zTnI7gzQpcyLp B1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687360398; x=1689952398; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Kqmb3rprEzIGwVb4ekH9Sq91ZgkEnr2Z+Sr1UJaSw4Q=; b=k9jYB7Kgc4SWbkR6jNQolJsWv3HAJnOnYgo307EBawF9Rv7foBb9WKxZOl77UjvH0U SY51cqqjCl9cF5qlfzQWyguyXmc4WwDJHKzwr0naIiXalrRzy7aTxBz1ikMbbGqzSf/b kcFC47+Nem72SraR1GJD8ZS2m0MGPpXeygOmBqhE7lOVX5bwKi9QU077bxDeEThWkIC9 Pc3fvE6KvCHmLf3+uCVHUG4ii1OFJTAnyU5mwsYZuuYDtJVbXt+m4y/qPMck3ctCmWUY JxPIQqgwu3JCn8c35a9lODdLJsPx/AOiTBqjKTnwg8dOA1Gl6K0GwIjYwXowZ9c8BykU rs6A== X-Gm-Message-State: AC+VfDwfax679HpZ+TSgS+5uhNKSRj2wbSmJD7ZQoTve/EZDvJWgRaH0 JG0ady1XLgX4JsGQrE2rPtfyTQ== X-Google-Smtp-Source: ACHHUZ5zQBAU6nO79kUjjdKL5ol/Mc8rc2eVR8+MhZ/eYqRA4HNRDzWTMOKMvSRxu1DntfAZYyOZhw== X-Received: by 2002:a0d:df87:0:b0:56c:fe54:4181 with SMTP id i129-20020a0ddf87000000b0056cfe544181mr15622808ywe.44.1687360398658; Wed, 21 Jun 2023 08:13:18 -0700 (PDT) Received: from [192.168.4.41] (162-239-31-113.lightspeed.dybhfl.sbcglobal.net. [162.239.31.113]) by smtp.gmail.com with ESMTPSA id g2-20020a816b02000000b0056d2dd6c5bcsm1175312ywc.89.2023.06.21.08.13.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Jun 2023 08:13:18 -0700 (PDT) Message-ID: <4fe50104-af62-95dc-abcb-75abd47025a7@joeconway.com> Date: Wed, 21 Jun 2023 11:13:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Bhasker Bathini , Holger Jakobs Cc: pgsql-admin@lists.postgresql.org References: <310498031.1194425.1687354401566@office.mailbox.org> <44912597-d81a-aece-2222-5a2e116dc0e1@jakobs.com> From: Joe Conway Subject: Re: Why do i need to install set_user extension if i can directly grant all required privileges to user? In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/21/23 10:38, Bhasker Bathini wrote: > Thank you for the quick response. > > What if i can grant all the required privileges or even making the user > a superuser, why do i need set_user ? > > Does set_user is just to make sure users with direct privileges wont > accidently modify critical information/parameters unless they set the > session to elevated privileged role to perform the operation? > > I am not able to find a reason why i need set_user extension? There are two main use cases for set_user: 1/ Allow an unprivileged admin role to escalate to superuser, but (to the extent possible) ensure every command issued is logged for audit purposes. It can also block things like COPY PROGRAM and ALTER SYSTEM that might allow them to do things you do not wish to allow. Once escalated, there are ways they could bypass the controls, but the act of bypassing itself would get logged, so if you monitor and alert you would catch it. 2/ Allow a single unprivileged role to be used to switch to other unprivileged roles, without having to grant all of them, and with the ability to set a random token so that switching back (and thus to indirectly other roles) requires the token. Think in terms of a web app that uses a single role to log in but then switches to a actual users role. Or a proxy or load balancer of sorts. -- Joe Conway PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com