Re: WAL file location

From: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Sullivan <andrew(at)libertyrms(dot)info>, PostgreSQL Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WAL file location
Date: 2002-07-30 22:02:35
Message-ID: 3D470CFB.36DE1736@fourpalms.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> The trouble with relying on environment variables for paths (especially
> paths to places that we might scribble on) is that the postmaster has
> no idea which strings in its environment were actually intended for that
> use, and which were not.

True, in the simplest implementation (Peter E. has suggested extensions
to address this complaint). But not relevant to security under likely
scenarios. See below.

> As an example, the postmaster very likely has $HOME in its environment.
> This means that anyone with createdb privilege can try to create a
> database in the postgres user's home directory. It's relatively
> harmless (since what will actually get mkdir'd is some name like
> /home/postgres/base/173918, which likely can't overwrite anything
> interesting) but it's still not a good idea.

Actually, this can not happen! You will see that the combination of
initlocation, environment variables, and other backend requirements will
force this kind of exploit to fail, since PostgreSQL requires a
structure of directories (like $PGDATA/data/base) but the environment
variable is only allowed to prepend the "data/base/oid" part of the
path.

So the directory *must* be set up properly beforehand, and must have the
correct structure, greatly reducing if not eliminating possible
exploits.

This is *not* possible in any scenerio for which the postmaster or a
server instance or a client connection has full control over the
attributes and definitions of data storage areas. Decoupling them
(requiring two distinct orthogonal mechanisms) is what enhances security
and data integrity. None of the "I hate environment variables"
discussions have addressed this issue.

> $PWD would be another likely attack point, and possibly one could do
> something with $PATH, not to mention any custom environment variables
> that might happen to exist in the local environment.

Again, not likely possible. See above.

> If we add more environment-variable-dependent mechanisms to allow more
> different things to be done, we increase substantially the odds of
> creating an exploitable security hole.

No. See above.

> > In any case, it'd be a _very good_ thing to have a tablespace-like
> > facility.
> Absolutely. But let's not drive it off environment variables.
> A config file is far safer.

Disagree, but in a friendly sort of way ;) I will likely implement both,
if either. Along the way I will give some specific use cases so we don't
go 'round on this topic every time...

- Thomas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-07-30 22:08:44 Re: DROP COLUMN round 4
Previous Message Thomas Swan 2002-07-30 21:48:40 Re: SET LOCAL again