Re: [HACKERS] Fixing insecure security definer functions

2007-08-10 Thread Sergiy Vyshnevetskiy
3. Add optional clauses to CREATE FUNCTION and ALTER FUNCTION to specify the propath value. I suggest, but am not wedded to, PATH 'foo, bar' PATH NONE Since PATH NONE is the default, it's not really needed in CREATE FUNCTION, but it seems useful to allow it for ALTER FUNCTION.

Re: [HACKERS] Fixing insecure security definer functions

2007-05-29 Thread Josh Berkus
Stephen, Tom, Eeek. *Which* caller's search_path? The string you're handed might've come from multiple levels up. I would say the outer-most. If people inbetween want to mess with things, let them qualify it before handing it down. Clearly, an already-qualified object would be left

Re: [HACKERS] Fixing insecure security definer functions

2007-05-29 Thread Stephen Frost
Tom, Josh, * Josh Berkus ([EMAIL PROTECTED]) wrote: Based on further IRC, I can personally see a solution which would be generally useful. Further, this solution doesn't require (or shouldn't) any modification of the existing function_path solution. It just requires two functions, which

Re: [HACKERS] Fixing insecure security definer functions

2007-05-28 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: I would like to fix this for 8.3. I don't have a patch yet but want to get buy-in on a design before feature freeze. I propose the following, fully-backward-compatible design: [...] Comments? In talking w/ Jeff Davis on IRC today, another thought

Re: [HACKERS] Fixing insecure security definer functions

2007-05-28 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes: It would be useful to have a function which could be passed a relative (to the caller's search path) object name and would return the fully qualified name of that object. In this way, functions could be written which take relative arguments from the

Re: [HACKERS] Fixing insecure security definer functions

2007-05-28 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: Stephen Frost [EMAIL PROTECTED] writes: It would be useful to have a function which could be passed a relative (to the caller's search path) object name and would return the fully qualified name of that object. In this way, functions could be written

Re: [HACKERS] Fixing insecure security definer functions

2007-05-28 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes: The 'special' bit here is that pg_getfullpath() would work relative to the caller's search_path even inside of a function which has its 'PATH' set. Eeek. *Which* caller's search_path? The string you're handed might've come from multiple levels up.

Re: [HACKERS] Fixing insecure security definer functions

2007-05-28 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: Stephen Frost [EMAIL PROTECTED] writes: The 'special' bit here is that pg_getfullpath() would work relative to the caller's search_path even inside of a function which has its 'PATH' set. Eeek. *Which* caller's search_path? The string you're handed

Re: [HACKERS] Fixing insecure security definer functions

2007-04-19 Thread Peter Eisentraut
Stephen Frost wrote: While I agree that raising a warning makes sense I don't believe it should be forced.  There may be cases where, even in security definer functions, the current search_path should be used (though, of course, care must be taken in writing such functions). I really wonder

Re: [HACKERS] Fixing insecure security definer functions

2007-03-29 Thread Tom Lane
As was pointed out awhile ago http://archives.postgresql.org/pgsql-general/2007-02/msg00673.php it's insecure to run a SECURITY DEFINER function with a search_path setting that's under the control of someone who wishes to subvert the function. Even for non-security-definer functions, it seems

Re: [HACKERS] Fixing insecure security definer functions

2007-03-29 Thread Merlin Moncure
On 3/29/07, Tom Lane [EMAIL PROTECTED] wrote: As was pointed out awhile ago http://archives.postgresql.org/pgsql-general/2007-02/msg00673.php it's insecure to run a SECURITY DEFINER function with a search_path setting that's under the control of someone who wishes to subvert the function. Even

Re: [HACKERS] Fixing insecure security definer functions

2007-03-29 Thread Stephen Frost
* Merlin Moncure ([EMAIL PROTECTED]) wrote: fwiw, I think this is a great solution...because the default behavior is preserved you get through without any extra guc settings (although you may want to add one anyways). I agree that the proposed solution looks good. maybe security definer

Re: [HACKERS] Fixing insecure security definer functions

2007-03-29 Thread Merlin Moncure
On 3/29/07, Stephen Frost [EMAIL PROTECTED] wrote: * Merlin Moncure ([EMAIL PROTECTED]) wrote: fwiw, I think this is a great solution...because the default behavior is preserved you get through without any extra guc settings (although you may want to add one anyways). I agree that the

Re: [HACKERS] Fixing insecure security definer functions

2007-03-29 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes: * Merlin Moncure ([EMAIL PROTECTED]) wrote: maybe security definer functions should raise a warning for implicit PATH NONE, and possibly even deprecate that behavior and force people to type it out in future (8.4+) releases. While I agree that raising

Re: [HACKERS] Fixing insecure security definer functions

2007-02-16 Thread Merlin Moncure
On 2/15/07, Tom Lane [EMAIL PROTECTED] wrote: Merlin Moncure [EMAIL PROTECTED] writes: yikes! If you guys go through with forcing functions to attach to objects when they are created, it will break almost every project I've ever worked on :(. The schema/function combo fits into all kinds

Re: [HACKERS] Fixing insecure security definer functions

2007-02-15 Thread Merlin Moncure
On 2/13/07, Tom Lane [EMAIL PROTECTED] wrote: I would suggest that the search path be added as an explicit parameter to CREATE FUNCTION, with a default of the current setting. The main reason for this is that it's going to be a real PITA for pg_dump if we don't allow an explicit specification.

Re: [HACKERS] Fixing insecure security definer functions

2007-02-15 Thread Tom Lane
Merlin Moncure [EMAIL PROTECTED] writes: yikes! If you guys go through with forcing functions to attach to objects when they are created, it will break almost every project I've ever worked on :(. The schema/function combo fits into all kinds of de facto partitioning strategies and

Re: [HACKERS] Fixing insecure security definer functions

2007-02-14 Thread Zeugswetter Andreas ADI SD
Regarding the advisory on possibly insecure security definer functions that I just sent out (by overriding the search path you can make the function do whatever you want with the privileges of the function owner), the favored solution after some initial discussion in the core team was to

Re: [HACKERS] Fixing insecure security definer functions

2007-02-14 Thread Peter Eisentraut
Am Mittwoch, 14. Februar 2007 10:21 schrieb Zeugswetter Andreas ADI SD: Have you considered hardcoding the schema for each object where it was found at creation time ? Unless anyone has solved the halting problem lately, I don't think it's possible to determine at creation time which objects

Re: [HACKERS] Fixing insecure security definer functions

2007-02-14 Thread Jeff Davis
On Tue, 2007-02-13 at 20:01 -0500, Tom Lane wrote: I would suggest that the search path be added as an explicit parameter to CREATE FUNCTION, with a default of the current setting. The main reason for this is that it's going to be a real PITA for pg_dump if we don't allow an explicit

Re: [HACKERS] Fixing insecure security definer functions

2007-02-14 Thread Josh Berkus
Andreas, Have you considered hardcoding the schema for each object where it was found at creation time ? This seems more intuitive to me. This isn't practical. Consider the schema qualification syntax for operators. -- --Josh Josh Berkus PostgreSQL @ Sun San Francisco

[HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Peter Eisentraut
Regarding the advisory on possibly insecure security definer functions that I just sent out (by overriding the search path you can make the function do whatever you want with the privileges of the function owner), the favored solution after some initial discussion in the core team was to save

Re: [HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Stephen Frost
* Peter Eisentraut ([EMAIL PROTECTED]) wrote: Regarding the advisory on possibly insecure security definer functions that I just sent out (by overriding the search path you can make the function do whatever you want with the privileges of the function owner), the favored solution after some

Re: [HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes: * Peter Eisentraut ([EMAIL PROTECTED]) wrote: Regarding the advisory on possibly insecure security definer functions that I just sent out (by overriding the search path you can make the function do whatever you want with the privileges of the function

Re: [HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes: It'll break most of the functions that we have in our production systems... They're not security definer functions but it's routine for us to switch between different schemas to run a function on. What about pushing all the in-function references down

Re: [HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: Stephen Frost [EMAIL PROTECTED] writes: It'll break most of the functions that we have in our production systems... They're not security definer functions but it's routine for us to switch between different schemas to run a function on. What about

Re: [HACKERS] Fixing insecure security definer functions

2007-02-13 Thread Andrew Dunstan
Peter Eisentraut wrote: Regarding the advisory on possibly insecure security definer functions that I just sent out (by overriding the search path you can make the function do whatever you want with the privileges of the function owner), the favored solution after some initial discussion in