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 1rybo7-00H7R7-Bt for pgsql-general@arkaria.postgresql.org; Sun, 21 Apr 2024 18:20:55 +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 1rybo6-00FYlr-19 for pgsql-general@arkaria.postgresql.org; Sun, 21 Apr 2024 18:20:54 +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 1rybo5-00FYlj-M7 for pgsql-general@lists.postgresql.org; Sun, 21 Apr 2024 18:20:53 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rybo3-002Cft-Cs for pgsql-general@lists.postgresql.org; Sun, 21 Apr 2024 18:20:53 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-78f05afc8d6so256035185a.3 for ; Sun, 21 Apr 2024 11:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713723649; x=1714328449; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=heYYQP0Hh5BDCR57K9BaQfqQ/dsdH+MH9bI5fNNqeak=; b=emSVWCaPm0EHzs5sORxLQowSm+salzkh8M8BaoQ7k3EGMKoZ1o0KySZiHPTsVbQt8H aKKoipWGb45MJdJLSKthSeg7Vh2EzPPjb5uDrmDRUR5idkM+jCbR3XbPtoXwviH0220h Fx2cKT8/yyjnDILk1WnrJ85QTwD4kP0AuT4AFkYAk2G4WTkO1+iXSIhR9tT+y7Zjm9Fp znJoR3GLXDdDUNDbQGg9zwsSI4FsTua++lI3KCA5wL7fIGizhrMuqCr2GQmpOixLOA87 pmg9xjVnwLrvAjzhR3ppKbsGvIxGsLlA1qli0vAjYecQWSMOcwYyH0UtRISP5FYgiaIW jFLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713723649; x=1714328449; h=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=heYYQP0Hh5BDCR57K9BaQfqQ/dsdH+MH9bI5fNNqeak=; b=mhS5eK8ih9ThPx0rRPYAJ7Q542C8se70JaBV1CXaqo25s6FdhoqE/GuazF7oJeRi2E V7XIbbJvXXAwrXzALA8yFAVDn/VhTUrIXnaKyptwKP6HI30ywspyJPL0v1IfcALRD4Xw 7w2FJP7++XjS5R+wHf/2XiEgEt6Ri9aJ8CDuRo8gScdhjT8miZjFcRBQ7j2HeL60IeyX qGYEXnuMvqZ3k0V3UAVwVJBqAehVc9dWmQxgb3EO3ta6fLXN0HtHKxMCF1qW13Ju1Pyu 3JYPUd43OEQ66qlr7pL9NtF3nu9MvADS1z7ONirBWP/zskXu0gPxmAkyFpDHN7XMZ/JT M31g== X-Forwarded-Encrypted: i=1; AJvYcCUh6Zet7GzJk26/hzRTs7su6yBT6L9EVsLhqbESQkIhC8Q4itBNHt5qMR4OI0cTW9hz1Q9FnvEraF0VwkH/HTj4Fz2VG9du2V+zDrFQQ0lP6X8f X-Gm-Message-State: AOJu0YwLz/Qt/8wEtg6LKQXJfQ6nxDAvhmFTNRkfGSkO9oiq4zRIrktl 5LIf1qlljemHEtBrhj/j+4HzUvfVqW+B7pVIXH4+CTgxjbBTSjFdWsQiEbLeMmGIFZWUtkevZZ+ 39YfK6cek02JDH3ucHDMuNFv8hQA= X-Google-Smtp-Source: AGHT+IGlp+2BCOMK0rTg1/GK9sPCDg9znkJUmBYaK0KnB3c02bobnStDVbrehmn9DSgmJ0OAPpkY0N9ll0B/xxg+yHw= X-Received: by 2002:a0c:d7c2:0:b0:6a0:5978:6595 with SMTP id g2-20020a0cd7c2000000b006a059786595mr6800107qvj.4.1713723649358; Sun, 21 Apr 2024 11:20:49 -0700 (PDT) MIME-Version: 1.0 References: <2720974.1713710606@sss.pgh.pa.us> In-Reply-To: <2720974.1713710606@sss.pgh.pa.us> From: yudhi s Date: Sun, 21 Apr 2024 23:50:38 +0530 Message-ID: Subject: Re: error in trigger creation To: Tom Lane Cc: "David G. Johnston" , pgsql-general Content-Type: multipart/alternative; boundary="0000000000005d01fe06169f61d5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005d01fe06169f61d5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 21, 2024 at 8:13=E2=80=AFPM Tom Lane wrote: > "David G. Johnston" writes: > > On Sunday, April 21, 2024, yudhi s wrote: > >> Are you saying something like below, in which we first create the > >> function from super user and then execute the grant? But doesn't that > mean, > >> each time we want to create a new event trigger we have to be again > >> dependent on the "super user" to modify the security definer function? > > > Dynamic SQL. See =E2=80=9Cexecute=E2=80=9D in plpgsql. > > You might as well just give that user superuser and be done with it. > It's foolish to imagine that you have any shred of security left > if you're letting a user that's not 100.00% trusted write event > triggers. (Much less execute any SQL command whatsoever, which > is what it sounds like David is suggesting you create a function > to do.) > > So do you mean , we should not create the event trigger using the "security definer" , rather have the super user do this each time we have to create the event trigger? Actually , I am not very much aware about the security part, but is it fine to give the super user privilege to the application user(say app_user) from which normally scripts/procedures get executed by the application, but nobody(individual person) can login using that user. Additionally in other databases, triggers are driven by some specific privileges (say for example in oracle "create trigger" privilege). And it doesn't need any super user and we were having many applications in which the application user (which were used for app to app login) was having these privileges, similar to "create table" privileges which comes by default to the schema who owns the objects etc. So in this case i was wondering if "event trigger" can cause any additional threat and thus there is no such privilege like "create trigger" exist in postgres and so it should be treated cautiously? --0000000000005d01fe06169f61d5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Sun, Apr 21, 2024 at 8:13=E2=80=AFPM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
"Dav= id G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sunday, April 21, 2024, yudhi s <learnerdatabase99@gmail.com> wrote= :
>> Are you saying something like below, in which we first create the<= br> >> function from super user and then execute the grant? But doesn'= ;t that mean,
>> each time we want to create a new event trigger we have to be agai= n
>> dependent on the "super user" to modify the security def= iner function?

> Dynamic SQL.=C2=A0 See =E2=80=9Cexecute=E2=80=9D in plpgsql.

You might as well just give that user superuser and be done with it.
It's foolish to imagine that you have any shred of security left
if you're letting a user that's not 100.00% trusted write event
triggers.=C2=A0 (Much less execute any SQL command whatsoever, which
is what it sounds like David is suggesting you create a function
to do.)


So do you mean , we should = not create the event trigger using the "security definer" , rathe= r have the super user do this each time we have to create the event trigger= ?

Actually , I am not very much aware about the se= curity part, but is it fine to give the super user privilege to the applica= tion user(say app_user) from which normally scripts/procedures get executed= by the application, but nobody(individual person) can login using that use= r.

Additionally in other databases, triggers are d= riven by some specific=C2=A0privileges (say for example in oracle "cre= ate trigger" privilege). And it doesn't=C2=A0need any super user a= nd we were having=C2=A0many applications in which the application user (whi= ch were used for app to app login) was having these privileges, similar to = "create table" privileges which=C2=A0comes by default to the sche= ma who owns the objects=C2=A0 etc. So in this case i was wondering if "= ;event trigger" can cause any additional threat and thus there is no s= uch privilege like "create trigger" exist in postgres and so it s= hould be treated=C2=A0cautiously?
--0000000000005d01fe06169f61d5--