Bugtraq: Having Fun With PostgreSQL

Lists: pgsql-hackers
From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-17 01:12:11
Message-ID: 20070617011211.GA4727@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

A message entitled "Having Fun With PostgreSQL" was posted to Bugtraq
today. I haven't read through the paper yet so I don't know if the
author discusses security problems that need attention or if the
article is more like a compilation of "Stupid PostgreSQL Tricks."

http://www.securityfocus.com/archive/1/471541/30/0/threaded

--
Michael Fuhr


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-17 02:42:55
Message-ID: 24660.1182048175@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> A message entitled "Having Fun With PostgreSQL" was posted to Bugtraq
> today. I haven't read through the paper yet so I don't know if the
> author discusses security problems that need attention or if the
> article is more like a compilation of "Stupid PostgreSQL Tricks."
> http://www.securityfocus.com/archive/1/471541/30/0/threaded

It appears he's discovered the astonishing facts that

1. The out-of-the-box authentication setup is "trust".
2. A superuser can make the database do whatever he wants (within
the OS privilege limits of the postgres user).

We've debated #1 before, and a lot of repackagers change it, but I
don't really feel a strong urge to change it in the source distro.
As for #2, that's not a bug, it's intended behavior.

regards, tom lane

PS: I skimmed the paper pretty fast, so it's possible I missed
something interesting, but it sure looked like "what else is new?"


From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-17 02:44:53
Message-ID: Pine.BSO.4.64.0706161939270.8025@resin.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, 16 Jun 2007, Michael Fuhr wrote:

> A message entitled "Having Fun With PostgreSQL" was posted to Bugtraq
> today. I haven't read through the paper yet so I don't know if the
> author discusses security problems that need attention or if the
> article is more like a compilation of "Stupid PostgreSQL Tricks."
>
> http://www.securityfocus.com/archive/1/471541/30/0/threaded

The crux of this seems to be two-fold:
1. If dblink is installed, an untrusted user could use it to gain
privileges, either using trust/ident auth (you have a superuser named
after the account the postmaster is runing as), or can be scripted to
brute force passwords.
2. If you are a superuser, you can gain access to the external system, ie,
by creating C language functions.

Neither of these are news to me, but maybe some new postgres admin will
read it and figure out to disable trust auth and not to let untrusted
users call dblink (either not install it or REVOKE the rights to call it).

--
Around computers it is difficult to find the correct unit of time to
measure progress. Some cathedrals took a century to complete. Can you
imagine the grandeur and scope of a program that would take as long?
-- Epigrams in Programming, ACM SIGPLAN Sept. 1982


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 02:54:23
Message-ID: 4675F3DF.4040403@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
>> A message entitled "Having Fun With PostgreSQL" was posted to Bugtraq
>> today. I haven't read through the paper yet so I don't know if the
>> author discusses security problems that need attention or if the
>> article is more like a compilation of "Stupid PostgreSQL Tricks."
>> http://www.securityfocus.com/archive/1/471541/30/0/threaded
>
> It appears he's discovered the astonishing facts that
>
> 1. The out-of-the-box authentication setup is "trust".
> 2. A superuser can make the database do whatever he wants (within
> the OS privilege limits of the postgres user).
>
> We've debated #1 before, and a lot of repackagers change it, but I
> don't really feel a strong urge to change it in the source distro.
> As for #2, that's not a bug, it's intended behavior.

On #1, the fact that we allow trust as default is embarrassing. It would
be just as bad as having the default root password be password on a
linux box. We should be using md5 and force passing the password with
initdb.

Sincerely,

Joshua D. Drake

>
> regards, tom lane
>
> PS: I skimmed the paper pretty fast, so it's possible I missed
> something interesting, but it sure looked like "what else is new?"
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 04:38:46
Message-ID: 87tzt5khbd.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The world rejoiced as jd(at)commandprompt(dot)com ("Joshua D. Drake") wrote:
> Tom Lane wrote:
>> Michael Fuhr <mike(at)fuhr(dot)org> writes:
>>> A message entitled "Having Fun With PostgreSQL" was posted to Bugtraq
>>> today. I haven't read through the paper yet so I don't know if the
>>> author discusses security problems that need attention or if the
>>> article is more like a compilation of "Stupid PostgreSQL Tricks."
>>> http://www.securityfocus.com/archive/1/471541/30/0/threaded
>> It appears he's discovered the astonishing facts that
>> 1. The out-of-the-box authentication setup is "trust".
>> 2. A superuser can make the database do whatever he wants (within
>> the OS privilege limits of the postgres user).
>> We've debated #1 before, and a lot of repackagers change it, but I
>> don't really feel a strong urge to change it in the source distro.
>> As for #2, that's not a bug, it's intended behavior.
>
> On #1, the fact that we allow trust as default is embarrassing. It
> would be just as bad as having the default root password be password
> on a linux box. We should be using md5 and force passing the password
> with initdb.

That won't help; that would introduce the "embarrassment" of having a
known default password.

This is a case where it takes careful thought to grasp whether there
is a problem or not.

If all we do is to shift the embarrassment around, that's not much
help.
--
output = reverse("moc.liamg" "@" "enworbbc")
http://linuxfinances.info/info/slony.html
"If all you can see is vast masses of end-users chewing their cud and
running Win95 on Gateways, then what good is platform independence?"
-- David LeBlanc (dleblanc(at)mindspring(dot)com)


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Christopher Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 05:02:18
Message-ID: 467611DA.1030804@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Christopher Browne wrote:
> The world rejoiced as jd(at)commandprompt(dot)com ("Joshua D. Drake") wrote:
>> Tom Lane wrote:

>>> We've debated #1 before, and a lot of repackagers change it, but I
>>> don't really feel a strong urge to change it in the source distro.
>>> As for #2, that's not a bug, it's intended behavior.
>> On #1, the fact that we allow trust as default is embarrassing. It
>> would be just as bad as having the default root password be password
>> on a linux box. We should be using md5 and force passing the password
>> with initdb.
>
> That won't help; that would introduce the "embarrassment" of having a
> known default password.

No it wouldn't unless the packagers set it up to do that. My point is
that when a packager (or source) runs initdb, it would prompt for the
postgres user password. Just like when you create a ssh key or cert etc...

Joshua D. Drake

>
> This is a case where it takes careful thought to grasp whether there
> is a problem or not.
>
> If all we do is to shift the embarrassment around, that's not much
> help.

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 05:31:47
Message-ID: 699.1182144707@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Christopher Browne <cbbrowne(at)acm(dot)org> writes:
> The world rejoiced as jd(at)commandprompt(dot)com ("Joshua D. Drake") wrote:
>> On #1, the fact that we allow trust as default is embarrassing.

> This is a case where it takes careful thought to grasp whether there
> is a problem or not.
> If all we do is to shift the embarrassment around, that's not much
> help.

We've argued this in considerable detail in the past. The bottom line
is that the trust default is the worst possible choice, except for all
the others. One of the more obvious problems with the others is that
a newbie who can't get into his database at all will not become a
Postgres adopter...

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 05:58:11
Message-ID: 2316.1182146291@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> Christopher Browne wrote:
>> That won't help; that would introduce the "embarrassment" of having a
>> known default password.

> No it wouldn't unless the packagers set it up to do that. My point is
> that when a packager (or source) runs initdb, it would prompt for the
> postgres user password.

Practically every existing packaging of PG tries to run initdb as a
hidden, behind-the-scenes, definitely not-interactive procedure.

regards, tom lane


From: "Magnus Hagander" <magnus(at)hagander(dot)net>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 06:12:53
Message-ID: 20070618061316.B3576DCCA7F@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> >> That won't help; that would introduce the "embarrassment" of having a
> >> known default password.
>
> > No it wouldn't unless the packagers set it up to do that. My point is
> > that when a packager (or source) runs initdb, it would prompt for the
> > postgres user password.
>
> Practically every existing packaging of PG tries to run initdb as a
> hidden, behind-the-scenes, definitely not-interactive procedure.
>

afaik, practically every existing packaging of pg has *already* solved the problem and does not set trust as default anyway. ident sameuser I think is the most
common.

One thing I've thought about doing is to remove the default in initdb completely and *force* the user to choose auth type. Packagers can then just use that to
set ident or whatever. and interactive users can pick trust if they really need it, but it will be a known choice.

/Magnus


From: Devrim GÜNDÜZ <devrim(at)CommandPrompt(dot)com>
To: "Joshua D(dot) Drake" <jd(at)CommandPrompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 09:22:27
Message-ID: 1182158547.4592.7.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On Mon, 2007-06-18 at 01:58 -0400, Tom Lane wrote:

> Practically every existing packaging of PG tries to run initdb as a
> hidden, behind-the-scenes, definitely not-interactive procedure.

Also, from RPM perspective: RPMs are *not* interactive, and will *never*
be. So we cannot ask user a password during initdb, or such.

Regards,
--
Devrim GÜNDÜZ
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Jeremy Drake <pgsql(at)jdrake(dot)com>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 10:27:23
Message-ID: 20070618102723.GP7531@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Jeremy Drake (pgsql(at)jdrake(dot)com) wrote:
> The crux of this seems to be two-fold:
> 1. If dblink is installed, an untrusted user could use it to gain
> privileges, either using trust/ident auth (you have a superuser named
> after the account the postmaster is runing as), or can be scripted to
> brute force passwords.

The dblink w/ ident case is at least somewhat interesting since, iirc
anyway, if you install dblink it comes with permissions for anyone to
run it. That's pretty ugly if your PG superuser is the same user
PostgreSQL runs as and you're using ident (which is quite common, esp.
over unix sockets). The answer here being, don't allow just anyone to
run dblink.

> 2. If you are a superuser, you can gain access to the external system, ie,
> by creating C language functions.

Which, as an issue, is pretty much resolved in 8.2 anyway... You'd have
to be able to compile and/or upload new libraries to the system w/ 8.2
since the PG_MODULE_MAGIC is required now.

> Neither of these are news to me, but maybe some new postgres admin will
> read it and figure out to disable trust auth and not to let untrusted
> users call dblink (either not install it or REVOKE the rights to call it).

I'm strongly tempted to say this should be set up as the default for
dblink, if it's not too hard to implement (I'd expect there's already a
.sql which does the in-db create function and whatnot, just revoke all
from it after it's created and tell people to create views using it
instead as superuser).

Thanks,

Stephen


From: Jim Nasby <decibel(at)decibel(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-18 17:09:23
Message-ID: 1BE7D620-FF6A-4F77-B4A0-ABC78A472FC7@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Jun 18, 2007, at 12:58 AM, Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
>> Christopher Browne wrote:
>>> That won't help; that would introduce the "embarrassment" of
>>> having a
>>> known default password.
>
>> No it wouldn't unless the packagers set it up to do that. My point is
>> that when a packager (or source) runs initdb, it would prompt for the
>> postgres user password.
>
> Practically every existing packaging of PG tries to run initdb as a
> hidden, behind-the-scenes, definitely not-interactive procedure.

I know there's issues with using ident sameuser via TCP, but what
about for filesystem socket connections?

As for the interactive/non-interactive, we could just leave that as
an option to initdb, and make the default to ask for a password.
Packagers would just need to feed the right option to initdb.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Jim Nasby <decibel(at)decibel(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-19 18:27:34
Message-ID: 200706191127.34630.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jim,

> I know there's issues with using ident sameuser via TCP, but what
> about for filesystem socket connections?

Not all OSes support ident ... Solaris and OpenBSD for two, don't, because
they see ident as insecure.

We switched the default to "trust localhost only" after many, many complaints
by newbies that they had installed PostgreSQL but couldn't log into it.
Other than maybe putting more emphasis on setting up the superuser password
in the tutorial, I really don't think that we should change the behavior.

--
Josh Berkus
PostgreSQL @ Sun
San Francisco


From: Jim Nasby <decibel(at)decibel(dot)org>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-22 20:57:21
Message-ID: 20A5D273-70AB-4F26-B649-431495429348@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Jun 19, 2007, at 1:27 PM, Josh Berkus wrote:
>> I know there's issues with using ident sameuser via TCP, but what
>> about for filesystem socket connections?
>
> Not all OSes support ident ... Solaris and OpenBSD for two, don't,
> because
> they see ident as insecure.

What about the unix domain socket, though? AFAIK that doesn't rely on
ident but some other method...
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jim Nasby <decibel(at)decibel(dot)org>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-22 23:22:53
Message-ID: 29495.1182554573@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jim Nasby <decibel(at)decibel(dot)org> writes:
> On Jun 19, 2007, at 1:27 PM, Josh Berkus wrote:
>> Not all OSes support ident ... Solaris and OpenBSD for two, don't,
>> because they see ident as insecure.

> What about the unix domain socket, though? AFAIK that doesn't rely on
> ident but some other method...

On OpenBSD we use getpeereid() for unix sockets, and there are
equivalent things on some other Unixen. We could never go over to
ident as the standard default, though, because not all platforms
have these sorts of features (if indeed they have unix sockets at
all ...); and in any case it's not very secure for TCP.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 10:00:37
Message-ID: 467CEF45.6090600@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander wrote:
>>>> That won't help; that would introduce the "embarrassment" of
>>>> having a known default password.
>>> No it wouldn't unless the packagers set it up to do that. My
>>> point is that when a packager (or source) runs initdb, it would
>>> prompt for the postgres user password.
>> Practically every existing packaging of PG tries to run initdb as a
>> hidden, behind-the-scenes, definitely not-interactive procedure.
>>
>
> afaik, practically every existing packaging of pg has *already*
> solved the problem and does not set trust as default anyway. ident
> sameuser I think is the most common.
>
> One thing I've thought about doing is to remove the default in initdb
> completely and *force* the user to choose auth type. Packagers can
> then just use that to set ident or whatever. and interactive users
> can pick trust if they really need it, but it will be a known choice.
>
>

Since nobody comemnted on this, let me turn it around and ask: Does
anybody have any reason *not* to do this?

If not, I'll just make it happen... (that should at least make people
speak up :P)

//Magnus


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 12:41:40
Message-ID: 467D1504.5070005@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander wrote:
> Magnus Hagander wrote:
>
>>>>> That won't help; that would introduce the "embarrassment" of
>>>>> having a known default password.
>>>>>
>>>> No it wouldn't unless the packagers set it up to do that. My
>>>> point is that when a packager (or source) runs initdb, it would
>>>> prompt for the postgres user password.
>>>>
>>> Practically every existing packaging of PG tries to run initdb as a
>>> hidden, behind-the-scenes, definitely not-interactive procedure.
>>>
>>>
>> afaik, practically every existing packaging of pg has *already*
>> solved the problem and does not set trust as default anyway. ident
>> sameuser I think is the most common.
>>
>> One thing I've thought about doing is to remove the default in initdb
>> completely and *force* the user to choose auth type. Packagers can
>> then just use that to set ident or whatever. and interactive users
>> can pick trust if they really need it, but it will be a known choice.
>>
>>
>>
>
> Since nobody comemnted on this, let me turn it around and ask: Does
> anybody have any reason *not* to do this?
>
> If not, I'll just make it happen... (that should at least make people
> speak up :P)
>
>
>

It will break the buildfarm. Of course I can unbreak it by adding
"--auth=trust" to the initdb args (and if we go this route we'll need to
do that for the regression temp installs too), but we'd need every
buildfarm member to have upgraded before we put it in. Is that really
the sort of disruption you want right now?

cheers

andrew


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 12:43:27
Message-ID: 467D156F.5080307@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan wrote:
>
>
> Magnus Hagander wrote:
>> Magnus Hagander wrote:
>>
>>>>>> That won't help; that would introduce the "embarrassment" of
>>>>>> having a known default password.
>>>>>>
>>>>> No it wouldn't unless the packagers set it up to do that. My
>>>>> point is that when a packager (or source) runs initdb, it would
>>>>> prompt for the postgres user password.
>>>>>
>>>> Practically every existing packaging of PG tries to run initdb as a
>>>> hidden, behind-the-scenes, definitely not-interactive procedure.
>>>>
>>>>
>>> afaik, practically every existing packaging of pg has *already*
>>> solved the problem and does not set trust as default anyway. ident
>>> sameuser I think is the most common.
>>>
>>> One thing I've thought about doing is to remove the default in initdb
>>> completely and *force* the user to choose auth type. Packagers can
>>> then just use that to set ident or whatever. and interactive users
>>> can pick trust if they really need it, but it will be a known choice.
>>>
>>>
>>>
>>
>> Since nobody comemnted on this, let me turn it around and ask: Does
>> anybody have any reason *not* to do this?
>>
>> If not, I'll just make it happen... (that should at least make people
>> speak up :P)
>>
>>
>>
>
> It will break the buildfarm. Of course I can unbreak it by adding
> "--auth=trust" to the initdb args (and if we go this route we'll need to
> do that for the regression temp installs too), but we'd need every
> buildfarm member to have upgraded before we put it in. Is that really
> the sort of disruption you want right now?

Ouch. No. Didn't think of that.

If we want to do that, we should probably do it right at the start of
the 8.4 cycle then?

//Magnus


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 16:02:43
Message-ID: 14982.1182614563@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> One thing I've thought about doing is to remove the default in initdb
>> completely and *force* the user to choose auth type. Packagers can
>> then just use that to set ident or whatever. and interactive users
>> can pick trust if they really need it, but it will be a known choice.

> Since nobody comemnted on this, let me turn it around and ask: Does
> anybody have any reason *not* to do this?

I'll object if no one else does: this will break existing installation
habits and processes to no real benefit.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 16:14:23
Message-ID: 467D46DF.5020406@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> One thing I've thought about doing is to remove the default in initdb
>>> completely and *force* the user to choose auth type. Packagers can
>>> then just use that to set ident or whatever. and interactive users
>>> can pick trust if they really need it, but it will be a known choice.
>
>> Since nobody comemnted on this, let me turn it around and ask: Does
>> anybody have any reason *not* to do this?
>
> I'll object if no one else does: this will break existing installation
> habits and processes to no real benefit.

The benefit would be that PostgreSQL would be "secure by default". Which
we are *not* today.

As a comparison, that's been one of the most common complaints against
Windows earlier - stuff is installed and enabled by default, and only if
you already know the system do you know that you should disable it. The
same thing applies here - if you don't already know how PostgreSQL
works, you will by default install a database that's completely without
authentication.

//Magnus


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 16:41:42
Message-ID: 15360.1182616902@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> Tom Lane wrote:
>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> One thing I've thought about doing is to remove the default in initdb
>>> completely and *force* the user to choose auth type.

>> I'll object if no one else does: this will break existing installation
>> habits and processes to no real benefit.

> The benefit would be that PostgreSQL would be "secure by default". Which
> we are *not* today.

No, we would NOT be "secure by default". We'd only be secure by default
if we forced the user to pick a secure auth method, for whatever value
of "secure" is politically correct.

A change like this will make exactly 0 difference to users of
prepackaged installations, since AFAIK all packages make their own
decisions about what default auth method to use (and since they are
targeting specific platforms, they have more context to make this choice
than we do). It will also be useless and annoying to experienced users
of the source code, since they already know what to do. The only group
that will be affected will be newbie installers-from-source (which I
bet is a mighty small group these days). And those people will find
that Postgres' first demand on them is to read and understand some
rather complex documentation to try to pick a default auth method.
You really think that this group is particularly likely to get it right?
If it were an open-and-shut decision we'd probably just move to a
non-trust default.

I would also argue that trust auth is not such an evil option that we
mustn't allow it to be the default. On a single-user machine it's
actually perfectly sane, seeing that we don't allow TCP connections
by default.

I think what this change would mostly do is put still another barrier
in the way of people trying out Postgres. There's already a darn steep
learning curve; we don't need a cliff at the very start.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 18:03:17
Message-ID: 467D6065.2050300@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> Tom Lane wrote:
>>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>>> One thing I've thought about doing is to remove the default in initdb
>>>> completely and *force* the user to choose auth type.
>
>>> I'll object if no one else does: this will break existing installation
>>> habits and processes to no real benefit.
>
>> The benefit would be that PostgreSQL would be "secure by default". Which
>> we are *not* today.
>
> No, we would NOT be "secure by default". We'd only be secure by default
> if we forced the user to pick a secure auth method, for whatever value
> of "secure" is politically correct.

Good point. But we'd at least force the user to read up on things. (Or
guess, but there's nothing we can do about that at all)

> A change like this will make exactly 0 difference to users of
> prepackaged installations, since AFAIK all packages make their own
> decisions about what default auth method to use (and since they are
> targeting specific platforms, they have more context to make this choice
> than we do).

Agreed.

> It will also be useless and annoying to experienced users
> of the source code, since they already know what to do.

Well, it would help them not to forget an important step, but agreed in
principle.

> The only group
> that will be affected will be newbie installers-from-source (which I
> bet is a mighty small group these days). And those people will find
> that Postgres' first demand on them is to read and understand some
> rather complex documentation to try to pick a default auth method.
> You really think that this group is particularly likely to get it right?
> If it were an open-and-shut decision we'd probably just move to a
> non-trust default.

In that case, md5 would seem to be the reasonable choice - unless we
want something platform specific somehow set by autoconf or so (I'd say
ident sameuser over unix sockets make a lot of sense on platforms that
support it).

> I would also argue that trust auth is not such an evil option that we
> mustn't allow it to be the default. On a single-user machine it's
> actually perfectly sane, seeing that we don't allow TCP connections
> by default.

Is there really such a thing as a single-user machine running
PostgreSQL? Maybe single "human user", but if you're not running some
other services on it (webserver, mailserver, whatever) it's not very
likely to be running pg, I think.

> I think what this change would mostly do is put still another barrier
> in the way of people trying out Postgres. There's already a darn steep
> learning curve; we don't need a cliff at the very start.

Didn't we just say that these users are most likely running a
pre-packaged version anyway?

Either way, it's not critical, given that the majority of our users use
some kind of pre-packaged deal, but I still think we could do better.

Out of curiosity, how do other databases deal with this? The only one
I've been installing recently is MSSQL which basically lets you chose
between SSPI
(ident-sameuser-over-sockets-and-kerberos-over-network-equivalent) or
password (md5 equivalent, AFAIK). It does *not* let you use empty
passwords, which is what would be equivalent with our "trust".

//Magnus


From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 18:40:29
Message-ID: 709CD56D-3F46-45B4-B5CB-F7B7DB0B4434@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Jun 23, 2007, at 11:03 AM, Magnus Hagander wrote:

>
>> I would also argue that trust auth is not such an evil option that we
>> mustn't allow it to be the default. On a single-user machine it's
>> actually perfectly sane, seeing that we don't allow TCP connections
>> by default.
>
> Is there really such a thing as a single-user machine running
> PostgreSQL? Maybe single "human user", but if you're not running some
> other services on it (webserver, mailserver, whatever) it's not very
> likely to be running pg, I think.

My laptop and dev boxes are all single user (and all do trust
on unix sockets).

I have several webserver boxes that use local postgresql
installations. Again, trust works just fine for that. There's
no security issue unless someone has compromised the
box (probably via the webapp), and if they've done that
they already have the keys to the castle. Mailserver, ditto.

We deploy CRM systems, running on dedicated boxes,
to customers. While they tend to get configured with
md5 access, just because it's tidy and easy to explain
to IT security folks, they'd actually be just as secure with
trust auth.

> Out of curiosity, how do other databases deal with this? The only one
> I've been installing recently is MSSQL which basically lets you chose
> between SSPI
> (ident-sameuser-over-sockets-and-kerberos-over-network-equivalent) or
> password (md5 equivalent, AFAIK). It does *not* let you use empty
> passwords, which is what would be equivalent with our "trust".

But that's not an installation from source. That's a packaged
installation, provided by the distribution owner. It's much more
comparable to, say, a Debian package.

MySQL installs with an empty root password for access from
localhost or the machines own IP address. It also installs an
account with network access to any database beginning with
"test" and possibly some more ill-defined accounts with local
access.

Part of the suggested post-install process for mysql involves
deleting some of those accounts and setting password for root.

Cheers,
Steve


From: Kenneth Marshall <ktm(at)rice(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, jd(at)commandprompt(dot)com, cbbrowne(at)acm(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-23 22:23:19
Message-ID: 20070623222319.GB17397@it.is.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jun 23, 2007 at 12:02:43PM -0400, Tom Lane wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
> >> One thing I've thought about doing is to remove the default in initdb
> >> completely and *force* the user to choose auth type. Packagers can
> >> then just use that to set ident or whatever. and interactive users
> >> can pick trust if they really need it, but it will be a known choice.
>
> > Since nobody comemnted on this, let me turn it around and ask: Does
> > anybody have any reason *not* to do this?
>
> I'll object if no one else does: this will break existing installation
> habits and processes to no real benefit.
>
> regards, tom lane
>
I agree with Tom on this. We have a number of install and provisioning
scripts that would become ridiculously convoluted and problematic if the
default is changed from trust. It is not unreasonable to expect a certain
degree of competence from anyone running a database server. Our default
postgresql install script asks for a system password and sets everything
to md5. If the user knows enough to stray from the default install, they
are assumed to know enough to keep out of trouble.

Cheers,
Ken


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Atkins <steve(at)blighty(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-24 15:55:09
Message-ID: 18966.1182700509@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Steve Atkins <steve(at)blighty(dot)com> writes:
> On Jun 23, 2007, at 11:03 AM, Magnus Hagander wrote:
>> Out of curiosity, how do other databases deal with this?

> MySQL installs with an empty root password for access from
> localhost or the machines own IP address. It also installs an
> account with network access to any database beginning with
> "test" and possibly some more ill-defined accounts with local
> access.

FWIW, on mysql 5.0.42 I see only "root(at)localhost" and "root(at)127(dot)0(dot)0(dot)1"
in a fresh-out-of-the-box installation; not sure where you got these
other accounts, maybe a distro-specific modification?

But the bottom line is that mysql's out-of-the-box behavior is
*exactly* like our trust-for-local-connections behavior. Anyone
on the box can do "mysql -u root ..." and the server will accept
them as being superuser (they don't even have to know to enter an
empty password, in my experience).

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Steve Atkins <steve(at)blighty(dot)com>, pgsql-hackers(at)postgresql(dot)org, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-24 16:30:30
Message-ID: 467E9C26.8010502@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Steve Atkins <steve(at)blighty(dot)com> writes:
>
>> On Jun 23, 2007, at 11:03 AM, Magnus Hagander wrote:
>>
>>> Out of curiosity, how do other databases deal with this?
>>>
>
>
>> MySQL installs with an empty root password for access from
>> localhost or the machines own IP address. It also installs an
>> account with network access to any database beginning with
>> "test" and possibly some more ill-defined accounts with local
>> access.
>>
>
> FWIW, on mysql 5.0.42 I see only "root(at)localhost" and "root(at)127(dot)0(dot)0(dot)1"
> in a fresh-out-of-the-box installation; not sure where you got these
> other accounts, maybe a distro-specific modification?
>
> But the bottom line is that mysql's out-of-the-box behavior is
> *exactly* like our trust-for-local-connections behavior. Anyone
> on the box can do "mysql -u root ..." and the server will accept
> them as being superuser (they don't even have to know to enter an
> empty password, in my experience).
>

This is all documented. For 5.1.x see:
http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html

Perhaps we should add a section to our docs on securing the database.

cheers

andredw


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 17:02:13
Message-ID: 20070625170213.GC19717@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jun 23, 2007 at 06:14:23PM +0200, Magnus Hagander wrote:
> The benefit would be that PostgreSQL would be "secure by default". Which
> we are *not* today.

To achieve the "secure by default" feature that you want (and I like
the scare-quotes -- I agree with those that think this adds no real
security, but I think you're right to worry about the perception
angle in this case), why not have a ./configure option that sets the
default trust level for the build? The option could default to
something "secure", but experienced users' build scripts would only
have to be altered to include --default-authentication="trust" or
something like that. Using this approach, packagers can also
continue to do what they want.

A
--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
However important originality may be in some fields, restraint and
adherence to procedure emerge as the more significant virtues in a
great many others. --Alain de Botton


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 17:31:52
Message-ID: 1378.1182792712@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> To achieve the "secure by default" feature that you want (and I like
> the scare-quotes -- I agree with those that think this adds no real
> security, but I think you're right to worry about the perception
> angle in this case), why not have a ./configure option that sets the
> default trust level for the build?

Why is that better than the initdb-time option we already have?
Locking down options earlier rather than later is usually not a win.

regards, tom lane


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 19:54:45
Message-ID: 20070625195445.GJ19717@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 25, 2007 at 01:31:52PM -0400, Tom Lane wrote:
> Why is that better than the initdb-time option we already have?
> Locking down options earlier rather than later is usually not a win.

Like I said, I don't actually think it _is_ better. But it would
solve the problem that some people think it's a bad thing that you
run superuser-type commands without reading the manual, and then get
a badly-secured system. (The idea here, incidentally, is not to
replace the initdb-time option, but to set the default of the initdb
command.)

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
When my information changes, I alter my conclusions. What do you do sir?
--attr. John Maynard Keynes


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 21:01:20
Message-ID: 6174.1182805280@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> On Mon, Jun 25, 2007 at 01:31:52PM -0400, Tom Lane wrote:
>> Why is that better than the initdb-time option we already have?
>> Locking down options earlier rather than later is usually not a win.

> Like I said, I don't actually think it _is_ better. But it would
> solve the problem that some people think it's a bad thing that you
> run superuser-type commands without reading the manual, and then get
> a badly-secured system. (The idea here, incidentally, is not to
> replace the initdb-time option, but to set the default of the initdb
> command.)

But, per previous discussion, the people that would be affected are
only the ones building from source. If they didn't read the manual
for initdb (nor notice the warning it puts out about trust auth),
they *certainly* didn't look for any nonstandard configure options.
The normal build process for any open-source package is

./configure
make
sudo make install
... now what? OK, time to read the manual ...

regards, tom lane


From: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 23:22:48
Message-ID: 5a0a9d6f0706251622n6e259584w8d4007e8043ce8e1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 6/25/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> > On Mon, Jun 25, 2007 at 01:31:52PM -0400, Tom Lane wrote:
> >> Why is that better than the initdb-time option we already have?
> >> Locking down options earlier rather than later is usually not a win.
>
> > Like I said, I don't actually think it _is_ better. But it would
> > solve the problem that some people think it's a bad thing that you
> > run superuser-type commands without reading the manual, and then get
> > a badly-secured system. (The idea here, incidentally, is not to
> > replace the initdb-time option, but to set the default of the initdb
> > command.)
>
> But, per previous discussion, the people that would be affected are
> only the ones building from source. If they didn't read the manual
> for initdb (nor notice the warning it puts out about trust auth),
> they *certainly* didn't look for any nonstandard configure options.
> The normal build process for any open-source package is
>
> ./configure
> make
> sudo make install
> ... now what? OK, time to read the manual ...

Since they presumably don't know about initdb yet, yeah, I figure
they'll be reading the manual. We already talk about how to initdb.
It seems reasonable to have the manual talk about how to initially
connect to your "secure by default" database and create a
non-superuser working user.

I like the idea of it being a configure flag, it seems the least
invasive way to do it.

Andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-25 23:31:28
Message-ID: 7946.1182814288@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com> writes:
> On 6/25/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> The normal build process for any open-source package is
>>
>> ./configure
>> make
>> sudo make install
>> ... now what? OK, time to read the manual ...

> Since they presumably don't know about initdb yet, yeah, I figure
> they'll be reading the manual. We already talk about how to initdb.
> It seems reasonable to have the manual talk about how to initially
> connect to your "secure by default" database and create a
> non-superuser working user.

+1 on having such a discussion in the manual (someone else suggested
that already IIRC). But I'm not seeing what a configure flag brings
to the party.

regards, tom lane


From: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 18:10:56
Message-ID: 5a0a9d6f0706261110l7e365cd0o787db86b51ae8dde@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 6/25/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com> writes:
> > On 6/25/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> The normal build process for any open-source package is
> >>
> >> ./configure
> >> make
> >> sudo make install
> >> ... now what? OK, time to read the manual ...
>
> > Since they presumably don't know about initdb yet, yeah, I figure
> > they'll be reading the manual. We already talk about how to initdb.
> > It seems reasonable to have the manual talk about how to initially
> > connect to your "secure by default" database and create a
> > non-superuser working user.
>
> +1 on having such a discussion in the manual (someone else suggested
> that already IIRC). But I'm not seeing what a configure flag brings
> to the party.

Like Andrew Sullivan said above, if we want to achieve the dubious
goal of being "secure by default" this seems like the least invasive
way to change the process so that we can be buzzword compliant.

Andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 19:08:59
Message-ID: 26514.1182884939@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com> writes:
> On 6/25/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> +1 on having such a discussion in the manual (someone else suggested
>> that already IIRC). But I'm not seeing what a configure flag brings
>> to the party.

> Like Andrew Sullivan said above, if we want to achieve the dubious
> goal of being "secure by default" this seems like the least invasive
> way to change the process so that we can be buzzword compliant.

It still wouldn't make us "secure by default". Not unless you propose
to actually change the default.

In any case, what is "secure by default"? The current default
configuration is entirely secure against outside attacks, because it
doesn't even allow outside connections. As for inside connections,
"secure" is still largely dependent on what your threat model is.
The paper that started this whole thread pointed out that "ident" auth
can expose you to problems even over a Unix socket, given the right set
of conditions. Shall we reject "ident" as not being sufficiently
secure? Better get rid of Kerberos, too, since that depends on an
outside server that could be compromised. And MD5 is certainly not good
enough, since PG doesn't force you to change to a new 12-character
not-in-the-dictionary password every week. Any of these things could be
considered to be not secure enough, depending on the user's situation.

I'm all for providing a more thorough discussion of these matters in
the manual. I'm not for changing the default behavior, nor for throwing
another roadblock into a day-zero newbie's experience with Postgres.
Ultimately it's the user's responsibility to determine what is
adequately secure for him.

regards, tom lane


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 19:26:13
Message-ID: 20070626192613.GR23306@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jun 26, 2007 at 03:08:59PM -0400, Tom Lane wrote:
> It still wouldn't make us "secure by default". Not unless you propose
> to actually change the default.

Perhaps I wasn't clear enough, but the suggestion I made (for
something I actually don't care about, I hasten to add again) was
that the configure switch _would_ be set to something different by
default. So it would require that those who need trust to work would
have to enable it on purpose; but (I suggested) at a not-too-invasive
point. It'd just be another configure option, and you usually have
to reconsider those at major version upgrade anyway. Nevertheless,

> In any case, what is "secure by default"?

. . .I agree that the checkbox is a dumb one. I think the entire
topic isn't worth the amount of electrons already spilled over it. I
don't see anyone clamouring for this and I see at least one person
strongly opposed. I think it should be regarded as Dead, Jim.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
I remember when computers were frustrating because they *did* exactly what
you told them to. That actually seems sort of quaint now.
--J.D. Baldwin


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>, "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 19:47:09
Message-ID: 87wsxqts5e.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> As for inside connections, "secure" is still largely dependent on what your
> threat model is.

Indeed I think closing Postgres to access based on the unix userid of the
connecting user is the wrong threat model. That's basically saying you don't
trust the unix userid of the system in which case you're really up a creek.

On the other hand dblink allows something that most sysadmins would consider
outside the normal bounds and of concern in their threat model. It allows a
privilege escalation since it allows any user to make an arbitrary TCP unix
connection as another user. I think that's the angle this should be closed
from.

Put another way there is a fundamental incompatibility between the default
settings for Postgres and the default settings for dblink though. If you
install both and accept the default configuration for both then one subverts
the security of the other. The side that's outside the norm here is dblink,
and in fact it not only subverts Postgres but could allow an attacker to
subvert other systems' security too.

All that really has to happen is that dblink should by default not be callable
by any user other than Postgres. DBAs should be required to manually run
"GRANT EXECUTE ON dblink_connect(text) TO public;" if that's what he wants.

It would be more obvious running that command that you're allowing any user to
make connections as Postgres, and at least whatever piece of documentation
contains that instruction would be a convenient place to put a warning about
it.

The only problem with this is that dblink provides 36 different functions (why
so many?!) My first thought is it could provide a pair of plpgsql functions to
grant or revoke access to all its functions to a specified role. But perhaps
someone else has a cleverer idea.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>, "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 20:56:13
Message-ID: 28568.1182891373@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> All that really has to happen is that dblink should by default not be
> callable by any user other than Postgres.

Yeah, that is not an unreasonable change. Someone suggested it far
upthread, but we seem to have gotten distracted :-(

> The only problem with this is that dblink provides 36 different functions

I think just having the install script revoke public execute access
on the connection-establishing functions would be sufficient. There
are only two of 'em.

regards, tom lane


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 21:30:21
Message-ID: 20070626213021.GJ7531@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> > All that really has to happen is that dblink should by default not be
> > callable by any user other than Postgres.
>
> Yeah, that is not an unreasonable change. Someone suggested it far
> upthread, but we seem to have gotten distracted :-(

Indeed, I know I did, though I think there were others also. :)

> > The only problem with this is that dblink provides 36 different functions
>
> I think just having the install script revoke public execute access
> on the connection-establishing functions would be sufficient. There
> are only two of 'em.

Agreed. We might want to mention this issue in the documentation
somewhere also, though I'm not really sure where. :/ Basically:

"Be very careful with functions which allow a user to make a remote
connection (eg: dblink). When ident is used as an authentication
mechanism it may be possible for a regular user to gain superuser
priviledges. Functions run in the database backend, which runs as
the OS user the backend was started under. Therefore, connections from
the database backend will be authenticated as the OS user the backend
was started under would be- which using ident generally means a
password-less connection to the database superuser account by means of a
local filesystem socket."

Thanks,

Stephen


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Hammond" <andrew(dot)george(dot)hammond(at)gmail(dot)com>, "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 21:43:24
Message-ID: 87ir9atmrn.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
>> All that really has to happen is that dblink should by default not be
>> callable by any user other than Postgres.
>
> Yeah, that is not an unreasonable change. Someone suggested it far
> upthread, but we seem to have gotten distracted :-(

On the subject of privilege escalation in contrib modules, I just did some
quick searches. Other modules using suspect calls are: pg_adminpack, and
tsearch2 (aside from pg_standby and pgbench which are stand-alone programs).

It looks like pg_adminpack uses requireSuperuser religiously so that should be
fine.

tsearch2 looks kind of suspect though. I'm not very familiar with it but is
there any protection against an attacker specifying arbitrary files as
dictionary, thesaurus, or stemmer files, allowing the user to open a file as
the postgres user instead of his own privileges?

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-26 22:17:28
Message-ID: 46819078.70005@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
>
>> All that really has to happen is that dblink should by default not be
>> callable by any user other than Postgres.
>>
>
> Yeah, that is not an unreasonable change. Someone suggested it far
> upthread, but we seem to have gotten distracted :-(
>
>
>> The only problem with this is that dblink provides 36 different functions
>>
>
> I think just having the install script revoke public execute access
> on the connection-establishing functions would be sufficient. There
> are only two of 'em.
>
>
>

+1 on this.

cheers

andrew


From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: "Jeremy Drake" <pgsql(at)jdrake(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 01:59:14
Message-ID: 63550.75.177.135.163.1182909554.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jeremy Drake wrote:

> 2. If you cannot tell what process is connecting on a local socket (which
> I suspect you cannot portably),

See ident_unix() in hba.c.

It might not be 100% portable but I think it's fairly close for platforms
that actually have unix sockets.

cheers

andrew


From: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 02:07:56
Message-ID: 4681C67C.4070803@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gregory Stark wrote:
> All that really has to happen is that dblink should by default not be callable
> by any user other than Postgres. DBAs should be required to manually run
> "GRANT EXECUTE ON dblink_connect(text) TO public;" if that's what he wants.

That serves the purpose of making PG "secure by default" (whatever that means
exactly) well, and surely is a good short-term solution.
But it severely limits the usefulness of dblink on setup where PG uses
ident auth either via TCP or unix-sockets - there seems to be no way to
securely users use dblink in such a setup.

Therefore I think there should be a ToDO
"Explore how dblink can be made safe if used together with ident authentication"
or something similar.

The ideal solution would IMHO be to authenticate a user using dblink as
the user he used to connect to PG in the first place - but since ident is
handled outside of PG that might be impossible to archive without some
really bad hacks. So maybe just finding a way to disable ident auth for
connections made via dblink is sufficient.

greetings, Florian Pflug


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 02:20:42
Message-ID: 20070627022042.GK7531@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Florian Pflug (fgp(dot)phlo(dot)org(at)gmail(dot)com) wrote:
> Gregory Stark wrote:
> >All that really has to happen is that dblink should by default not be
> >callable
> >by any user other than Postgres. DBAs should be required to manually run
> >"GRANT EXECUTE ON dblink_connect(text) TO public;" if that's what he wants.
>
> That serves the purpose of making PG "secure by default" (whatever that
> means
> exactly) well, and surely is a good short-term solution.
> But it severely limits the usefulness of dblink on setup where PG uses
> ident auth either via TCP or unix-sockets - there seems to be no way to
> securely users use dblink in such a setup.

Uh, have the admin create appropriate views.

> Therefore I think there should be a ToDO
> "Explore how dblink can be made safe if used together with ident
> authentication"
> or something similar.

I disagree. What dblink *does* is insecure and in general *shouldn't*
be something regular users can do. That goes well and beyond just the
ident case, imv, but it's handy thing to point to atm.

> The ideal solution would IMHO be to authenticate a user using dblink as
> the user he used to connect to PG in the first place - but since ident is
> handled outside of PG that might be impossible to archive without some
> really bad hacks. So maybe just finding a way to disable ident auth for
> connections made via dblink is sufficient.

erm, this isn't dblink anymore, this is cross-database stuff that should
be done completely differently from dblink, if it's going to be done at
all.

Thanks,

Stephen


From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 02:21:43
Message-ID: Pine.BSO.4.64.0706261912130.8025@resin.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 26 Jun 2007, Tom Lane wrote:

> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> > All that really has to happen is that dblink should by default not be
> > callable by any user other than Postgres.
>
> Yeah, that is not an unreasonable change. Someone suggested it far
> upthread, but we seem to have gotten distracted :-(

An idea came to me while thinking about this. The particular use-case
that I use dblink for is connecting to another database in the same
database cluster. ISTM (without looking at any code) that the postmaster
could keep track of who is properly authenticated in each backend, and see
if a connection is being created from that backend to allow connections as
the user in that backend.

I had a couple ideas about this:
1. If you can tell what process is connecting on a local socket, store a
mapping of pid to userid in the postmaster shmem and if a connection is
originating from a pid in this table and is attempting to authenticate as
the corresponding userid, allow it.

2. If you cannot tell what process is connecting on a local socket (which
I suspect you cannot portably), generate a random "token" and stash it in
shared memory mapping it to a userid, and then on authentication, send
this token to the postmaster to prove that you have already authenticated.
This has the downside of turning an exploit where a non-privileged user
can read arbitrary postgres memory, they could potentially gain the
privilieges of any logged on user, but the best idea is to not have that
kind of bug ;)

I know this is not the time for thinking about such things, but it may be
an idea for 8.4...

--
It's really quite a simple choice: Life, Death, or Los Angeles.


From: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>
To: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 16:23:49
Message-ID: 46828F15.7020404@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephen Frost wrote:
> * Florian Pflug (fgp(dot)phlo(dot)org(at)gmail(dot)com) wrote:
>> Gregory Stark wrote:
>>> All that really has to happen is that dblink should by default not be
>>> callable
>>> by any user other than Postgres. DBAs should be required to manually run
>>> "GRANT EXECUTE ON dblink_connect(text) TO public;" if that's what he wants.
>> That serves the purpose of making PG "secure by default" (whatever that
>> means
>> exactly) well, and surely is a good short-term solution.
>> But it severely limits the usefulness of dblink on setup where PG uses
>> ident auth either via TCP or unix-sockets - there seems to be no way to
>> securely users use dblink in such a setup.
>
> Uh, have the admin create appropriate views.
I meant letting them use it to connect to abitrary databases and hosts, not
executing only predefined quries. My wording wasn't clear in that regard,
though.

>> Therefore I think there should be a ToDO
>> "Explore how dblink can be made safe if used together with ident
>> authentication"
>> or something similar.
>
> I disagree. What dblink *does* is insecure and in general *shouldn't*
> be something regular users can do. That goes well and beyond just the
> ident case, imv, but it's handy thing to point to atm.
I fail to see why dblink is any more insecure than, say, plpgsql or
plperl (not plperlu). It doesn't give any more priviliges than pgsql
would. The only exception IMHO are privileges that you get because
dblink issues that connection from a specific machine as a specific user.

What other security problems does dblink impose? Maybe I'm just being blind..

greetings, Florian Pflug


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-27 19:33:20
Message-ID: 20070627193320.GL7531@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Florian Pflug (fgp(dot)phlo(dot)org(at)gmail(dot)com) wrote:
> Stephen Frost wrote:
> >Uh, have the admin create appropriate views.
> I meant letting them use it to connect to abitrary databases and hosts, not
> executing only predefined quries. My wording wasn't clear in that regard,
> though.

Perhaps I wasn't clear. My response to that is "don't.". It's not a
safe or sane thing for a user to be able to do.

> >I disagree. What dblink *does* is insecure and in general *shouldn't*
> >be something regular users can do. That goes well and beyond just the
> >ident case, imv, but it's handy thing to point to atm.

> I fail to see why dblink is any more insecure than, say, plpgsql or
> plperl (not plperlu). It doesn't give any more priviliges than pgsql
> would. The only exception IMHO are privileges that you get because
> dblink issues that connection from a specific machine as a specific user.

Trusted languages shouldn't be able to open socket connections. If
plpgsql (erm, don't think so) or plperl (I hope it can't...) can do that
then they should be marked as untrusted.

Thanks,

Stephen


From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Date: 2007-06-28 06:16:21
Message-ID: Pine.BSO.4.64.0706272308300.8025@resin.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 26 Jun 2007, Andrew Dunstan wrote:

> Jeremy Drake wrote:
>
> > 2. If you cannot tell what process is connecting on a local socket (which
> > I suspect you cannot portably),
>
>
> See ident_unix() in hba.c.
>
> It might not be 100% portable but I think it's fairly close for platforms
> that actually have unix sockets.

It looks to me (looking at docs on the various functions used there) that
only Linux supports getting the PID of the connecting process. The other
various *BSD methods tend only to give the uid and gid, which will not be
helpful if the connection is coming from another backend in the same
cluster.

In the linux case, it looks like one would need to get the client pid, try
to get the PGPROC entry for it, if it exists get the roleid out of that
and allow connections as that role.

For any other case, some sort of painful protocol hack would be in order.
The best way I can see is to see if the client process is owned by the
same user as the database cluster, and if so send an auth request (like
the SCM_CRED one), which would be responded to with the pid and a random
sequence stored in the PGPROC entry. The server then proves the backend
really is the one it claims to be by looking up the PID's PGPROC entry,
and making sure the token matches.

This is all just thinking out loud, of course... I have no plans to
implement this in the short-term, but it may be an interesting project in
the future.

--
I like to believe that people in the long run are going to do more to
promote peace than our governments. Indeed, I think that people want
peace so much that one of these days governments had better get out of
the way and let them have it.
-- Dwight D. Eisenhower