Re: server authentication over Unix-domain sockets

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: server authentication over Unix-domain sockets
Date: 2010-06-11 11:55:25
Message-ID: AANLkTimo4PtGHRx38Sgge93Xjl2kFRVlQPJbe7IH-Z50@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, May 30, 2010 at 13:00, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> It has been discussed several times in the past that there is no way for
> a client to authenticate a server over Unix-domain sockets.  So
> depending on circumstances, a local user could easily insert his own
> server and collect passwords and data.  Suggestions for possible
> remedies included:
>
> You can put the socket file in a sufficiently write-protected directory.
> But that would strongly deviate from the default setup, and anyway the
> client still cannot readily verify that the server is the right one.
>
> You can also run SSL over Unix-domain sockets.  This is currently
> disabled in the code, but it would work just fine.  But it's obviously
> kind of awkward, and the connection overhead was noticeable in tests.
>
> Then it was suggested to use the local "ident" mechanism in reverse, so
> the client could verify what user the server runs under.  I have
> implemented a prototype of this.  You can put, e.g.,
>
> requirepeer=postgres
>
> into the connection parameters, and the connection will be rejected
> unless the process at the other end of the socket is running as
> postgres.
>
> The patch needs some portability work and possible refactoring because
> of that, but before I embark on that, comments on the concept?

I like it. ISTM like something that would be very useful - an easy way
to get a fair amount of extra security in the case of local
connections, at almost zero cost. Just an "export
PGREQUIREPEER=postgres" in .profile goes a long way :-)

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pr, Solaiyappan (NSN - IN/Bangalore) 2010-06-11 11:56:03 PG 9.1 tentative timeline
Previous Message Magnus Hagander 2010-06-11 11:53:31 Re: server authentication over Unix-domain sockets