Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4HgO-0008Ib-B8 for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 11:08:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u4HgM-00HE1c-Fm for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 11:08:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4HgM-00HE1M-4f for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 11:08:54 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u4HgJ-00019h-1w for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 11:08:54 +0000 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-72b82c8230aso1123650a34.2 for ; Mon, 14 Apr 2025 04:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744628931; x=1745233731; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QP2YxMrt1HXgGroCDGJO8O8QHywVXsNbbk9P6/h1ZY4=; b=gxE7AfSBvSiO0ULTU9KgsYyli9iRbW2XIsbVULTHsZcdxTQNbiduZMrooYFzjGlxX6 w4LaSk/3h3VPIcRUIzmqb7w2hEWFzPDmb0f8W3WuCa2mCNFC8vzHz5704N000fQBVYr0 MkkLbNTzchqtSJg0fPsrtsuZPv74RlcaULq9yk7c9YT7+CKxKRbnVpCTo0JvTSUVrOAc f/EvF38MIVSCVUy4B/mEZ/bHrm3G/F5Q0z51grX22lgc9fJCXEJLPGDXNBY9535t4gGY x4O97385+NRot5GBkvj2LeFXnOWrXFJiw3sSvR6W2JJ/Dsj/75NmJxXPI89r7jkvGqLt CNyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744628931; x=1745233731; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QP2YxMrt1HXgGroCDGJO8O8QHywVXsNbbk9P6/h1ZY4=; b=ILcCl2jJVehHt3w0vBYZvLtR9k68urCmFXkR/fzvyzlfVgUB68EshjUJaozi70bYHY LLfhbroXNwq4pdwkelsyPP716fmtND6Pz1bwBQ/gcBJPD8MJzDr7RHbtopaP3A2GziDp vARIe5vRoRgkB7v3JyTJ10xhV6eq2UlxDtTb48sBDlEmdK7geMShm1Zy+DOcAdRLr6+0 32+ZXTd03azAOvDpwTQT+XikWDBXU1PVcKacpUkFLWT7B/I+BXdXt+9M1/F6wG2KicNb Ml0g8/20R0LI7Xs4RW7wSUCJGIqJx0s4JUWjXF01DahBALWon5y9EYy/n2I9MD7bhLOn pzcQ== X-Gm-Message-State: AOJu0YyAqtSJ3Y+oOjhMUvhogRbhb/sedX9iZlZ+g6mkvfuPU70HeQoE dbAZUDHQF2K5RUEbTjVkZPxk1M7nZB7A9IBpPAePrvpGbAZUmYtiHbPNs51C+xUzAZQZrXuiG3+ oSx1CSNz66oYsAb/T+nPHCgz5l2YegA== X-Gm-Gg: ASbGncv20UxMGdLGqkyPwZD0zc/LaL1daxmLbPAE7Rl5fHoILLai3PNgkyRzcVhOSFT 8drt6kgMeiTJXl7lXxEoPDSnH+gKY251zJmAyLYvz0itdp/FC/BOdZIUVfz4AtLEs5PgauRS/R/ LtYMDayJQMdKDmeiVvHPrarZmh X-Google-Smtp-Source: AGHT+IFGXaFY4nfoG6YI0lscdRztg6x/25CLrpn2wjF5QRdAX5iTnM+iZCxGA5oCAweJ0J+EL/Jnk/HAa6I8JLRp3PI= X-Received: by 2002:a05:6808:1389:b0:3f8:8977:7294 with SMTP id 5614622812f47-400850d4062mr7263907b6e.31.1744628930757; Mon, 14 Apr 2025 04:08:50 -0700 (PDT) MIME-Version: 1.0 References: <1b6d736c-3046-4b8f-a636-eaa323be7eb4@technowledgy.de> In-Reply-To: <1b6d736c-3046-4b8f-a636-eaa323be7eb4@technowledgy.de> From: Dominique Devienne Date: Mon, 14 Apr 2025 13:08:20 +0200 X-Gm-Features: ATxdqUF0lUUlJAeBrNHKP-VTp8kA1B9YSjPMnhEYqyDWUdRmFPWtHmKGC4Tos8Y Message-ID: Subject: Re: Event-Triggers for DB owners instead of just SUPERUSER To: Wolfgang Walther , tgl@sss.pgh.pa.us Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 14, 2025 at 12:09=E2=80=AFPM Wolfgang Walther wrote: > > From Dominique Devienne: > > Can't event-triggers also be available to DB owners, instead of just SU= PERUSER? > > There's a recent -hackers thread exactly about this: > https://www.postgresql.org/message-id/flat/CAGRrpzbtYDkg7_xwfzrqByYgCJQbb= L38tADyuN%2B6tAkbA-Pnkg%40mail.gmail.com Hi. Thanks for the pointer Wolfgang. I've perused that thread, and Tom seems pretty against it, bummer... (see extract below). From Tom: > Here is the real problem: database owners are not specially > privileged in Postgres. Yeah, they can drop their DB, but they > don't have automatic permissions to mess with other people's > objects inside the DB. (Much the same can be said of schema > owners.) So any proposal that effectively gives DB owners > such privileges is going to fail. I realize that some other > DBMSes assign more privileges to schema or DB owners, but we > don't and I don't think we're open to changing that. Tom, I don't want to mess with other people's data. I want to track DDL changes in the schemas the "app" manages in that DB, for auditing reasons. I don't want the DB owner to do DML changes, except to the tables it can INSERT into, as usual, per the normal access rules. And the DB Owner will NOT have SUPERUSER. Not even the ROLE that created the DB or its owner. > I think you need to be thinking of this in terms of "what sort > of feature can we add that can be allowed to any SQL user?" > The notion I proposed earlier that an event trigger only fires > on queries executed by roles the trigger's owner belongs to > is (AFAICS) safe to allow to anyone. If that's not good enough > for your notion of what a DB owner should be able to do, the > answer is to grant the DB owner membership in every role that > uses her database. That's effectively what the feature you're > suggesting would do anyway. In my case, the DB Owner is not a MEMBER per-se (no set_option or inherit_option), BUT it will be the one who did create the ROLEs that will own the DB objects (SCHEMAs and TABLEs and co.), so it will have admin_option. So if admin_option is "good enough" to generate ROLE cycles, with the mess that created in "my app" against v16+, then it should also be "good enough" to fire event triggers on too. Like someone on that thread, I'm not sure to see where the privilege escalation is coming from. It sounds as-if the event trigger executes with SUPERUSER. But does it? In my case, the trigger would execute as the DB owner, based on the SECURITY DEFINER of the trigger proc, and that ROLE can't write (or mess) nilly willy in the normal access rules. So where's the problem exactly? In practice, as I wrote, in my case, the DB Owner is the one which created all ROLEs that owns any of the SCHEMAs, so it could mess with those, since it has ADMIN OPTION on all those ROLEs. But I don't see how that's any different for event-triggers compared to non-trigger SQL. I'm sure my view is naive, from not knowing PostgreSQL enough. But that's why I'm asking questions here, to get educated. And presenting my use-cases, to inform future devs. Thanks, --DD