Re: temporary functions (and other object types)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: temporary functions (and other object types)
Date: 2010-11-06 19:02:56
Message-ID: AANLkTinyxT1Ad1HWzv0ikvHgYVpkWaW8qvA=3BAvOcVH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 6, 2010 at 1:43 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Sat, Nov 6, 2010 at 11:36 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Yeah, we changed that behavior as part of the fix for CVE-2007-2138.
>>> You'd need either SECURITY DEFINER functions or very careless use of
>>> SET ROLE/SET SESSION AUTHORIZATION for the issue to be exploitable.
>
>> Would it be practical to let foo() potentially mean pg_temp.foo()
>> outside of any SECURITY DEFINER context?
>
> Doesn't seem like a particularly good idea for the search semantics
> to be randomly different inside a SECURITY DEFINER function.  In fact,
> I'll bet you could construct an attack in the reverse direction:
> S.D. function thinks it is calling a temp function (using syntax that
> works fine when not S.D.), but control gets sent to a non-temp function
> belonging to $badguy instead.

I guess. If you search pg_temp always then it's pretty much
impossible to avoid having a security hole, if you use any non-trivial
SQL. But if you search pg_temp for non-SD only then you'll only have
a security hole if you assume (presumably without testing) that the
behavior is the same in that case. If an SD function is calling
temporary functions they'd best be ones it created, otherwise your
security is pretty much nonexistent anyway.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-11-06 19:18:11 Re: temporary functions (and other object types)
Previous Message Robert Haas 2010-11-06 18:56:49 knngist questions