pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave <dave@hawk-systems.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: logic check of pg_hba.conf configuration
Date: Sun, 10 Mar 2002 21:07:45 -0500
Message-ID: <6045.1015812465@sss.pgh.pa.us> (raw)
In-Reply-To: <DBEIKNMKGOBGNDHAAKGNOEIMNAAA.dave@hawk-systems.com>
References: <DBEIKNMKGOBGNDHAAKGNOEIMNAAA.dave@hawk-systems.com>

"Dave" <dave@hawk-systems.com> writes:
> running version 7.0

7.0?  Not even 7.0.something?  You really ought to update.
But I digress...

> current pg_hba.conf contains//
> local        all                                           trust
> host         sameuser    127.0.0.1     255.255.255.255     password

This strikes me as very wrong.  Line 1 says that you will trust any
process running on the local host, and then in line 2 you want to be
much more paranoid simply because the connection is loopback TCP and
not Unix-socket transport.  Anyone who can get at a Perl script running
on your box can surely have his choice of transport methods from there
to the database; so I don't see the percentage in closing the door to
127.0.0.1 while leaving the Unix-socket door wide open.

Also, if line 2 is intended for scripted access, password authentication
seems like a poor choice.  Where's the script going to get the password?
Surely it's a bad idea to encourage people to store passwords directly
in PHP scripts ... yet that's exactly what you'll get with this.

Depending on how your scripting support is set up, you might consider

local        all                                           password
host         sameuser    127.0.0.1     255.255.255.255     ident

This (assuming you are running a trustworthy ident daemon) would allow
scripts to connect without a password as long as they are running under
the Unix userid matching their database name and database user id; so
the security issue moves away from PG and into whatever you use to
authenticate the right to create/run a script.

Local admins would have to give a password, which is annoying but at
least not a security hole.  If you were to update to 7.1 or 7.2 you
would have more flexibility; in particular it'd be possible to shield
the Unix-socket file with filesystem permissions, which would be a much
nicer way of restricting admin access than passwords.  (You can't
realistically run pg_dump from a cron task if admin access requires
passwords :-(.)

> host         all         123.45.678.1 255.255.255.255     trust

Okay as long as you really really trust all users on that machine.
You might also want to think about whether your network is firewalled
sufficiently that an attacker could not inject packets claiming to be
from that machine.

> host         all         0.0.0.0       0.0.0.0             reject

You realize of course that this is redundant (dropping off the end
of pg_hba.conf is an implicit reject).  Okay as documentation though.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <6045.1015812465@sss.pgh.pa.us>
Permalink:  ../6045.1015812465@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6045.1015812465@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dave@hawk-systems.com
  Subject: Re: logic check of pg_hba.conf configuration
  In-Reply-To: <6045.1015812465@sss.pgh.pa.us>
  References: <DBEIKNMKGOBGNDHAAKGNOEIMNAAA.dave@hawk-systems.com> <6045.1015812465@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox