Re: dblink vs SQL/MED - security and implementation details

From: Joe Conway <mail(at)joeconway(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Martin Pihlak <martin(dot)pihlak(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: dblink vs SQL/MED - security and implementation details
Date: 2009-01-06 03:54:14
Message-ID: 4962D5E6.7020902@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> Joe Conway wrote:
>> I'm mainly concerned about re-opening security holes that we spent a
>> lot of time debating and subsequently closing. I suspect if we assume
>> that any FDW-derived connect string can bypass the checks we put in
>> place, we will regret it later. But I'm open to arguments on both
>> sides...
>
> Can you elaborate what security issues you are concerned about?

For example: on a freshly installed postgres installation, that does
*not* require authentication, you would get the following behavior which
previously was found to be unacceptable:

8<--------------------------------------------------------------
--
-- as the superuser
--
CREATE FOREIGN DATA WRAPPER postgresql LIBRARY 'postgresql_fdw'
LANGUAGE C;
CREATE SERVER fdtest FOREIGN DATA WRAPPER postgresql
OPTIONS (dbname 'contrib_regression');
CREATE USER dblink_regression_test;
CREATE USER MAPPING FOR dblink_regression_test SERVER fdtest;
\c - dblink_regression_test
psql (8.4devel)
You are now connected to database "contrib_regression" as user
"dblink_regression_test".
--
-- now as untrusted user dblink_regression_test
--
contrib_regression=> SELECT dblink_connect('myconn', 'fdtest');
dblink_connect
----------------
OK
(1 row)

contrib_regression=> SELECT * FROM dblink('myconn','SELECT
current_user') AS t(u text);
u
----------
postgres
(1 row)
8<--------------------------------------------------------------

Now, we can blame the superuser for explicitly allowing this, but I
don't see that as much different from the previously voiced security
concerns. I'm sure there are other privilege escalation scenarios, but I
haven't tried at all hard to think of them...

Joe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2009-01-06 04:07:08 Re: QuickLZ compression algorithm (Re: Inclusion in the PostgreSQL backend for toasting rows)
Previous Message Bruce Momjian 2009-01-06 03:16:50 Re: Fix for compiler warning in reloptions.c