Re: security definer default for some PL languages (SQL/PSM)? - Mailing list pgsql-hackers

From Albe Laurenz
Subject Re: security definer default for some PL languages (SQL/PSM)?
Date
Msg-id 52EF20B2E3209443BC37736D00C3C1380C2AFF0B@EXADV1.host.magwien.gv.at
Whole thread Raw
In response to security definer default for some PL languages (SQL/PSM)?  ("Pavel Stehule" <pavel.stehule@hotmail.com>)
List pgsql-hackers
Peter Eisentraut wrote:
>> SQL/PSM default for SQL procedures are SECURITY DEFINER (like views),
>
> I can't find this in the standard.  Where did you get this
> information?

I only have a draft version of SQL:2003, which says in the 'Foundation'
book, chapter 11.50 ("<SQL-invoked routine>"), about the "<rights
clause>"
(which can be "SQL SECURITY INVOKER" or "SQL SECURITY DEFINER") in
Syntax Rule
19) b):

"If R is an SQL routine, then if <rights clause> is not specified,
then SQL SECURITY DEFINER is implicit."

It adds, however, in chapter 4.27.2, that
"An SQL routine is an SQL-invoked routine whose <language clause>
specifies SQL."

Rule 20) b) of chapter 11.50 says that

"If R is an external routine, then if <external security clause> is not
specified, then EXTERNAL SECURITY IMPLEMENTATION DEFINED is implicit."

Here, "An external routine is one whose <language clause> does not
specify SQL."

"Implementation defined" here means the obvious thing.


So one can make a case that SQL functions should be SECURITY DEFINER by
default, but for all other procedural languages the standard explicitly
sets no rules.

For me, who comes from a UNIX background, SECURITY INVOKER is the
natural
default value, and the standard's decision surprises me. I guess that it
is counter-intuitive to most people, and moreover it would break
compatibility with current behaviour.
I think that it is wise to break with the standard in this case,
SECURITY INVOKER being the safer option.

It should be noted, however, that Oracle's PL/SQL functions have
AUTHID DEFINER by default, which corresponds to our SECURITY DEFINER.

Yours,
Laurenz Albe


pgsql-hackers by date:

Previous
From: "Pavel Stehule"
Date:
Subject: is "add MOVE point" in ToDo valid still?
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCHES] SGML index build fix