2009-03-23 10:37:46

by Kohei KaiGai

[permalink] [raw]
Subject: [refpolicy] The status of SE-PostgreSQL

Here is a bad news.

I've had a discussion in pgsql-hackers list for a long time, but
we cannot get a conclusion that SE-PostgreSQL should be merged
in the PostgreSQL v8.4 which is the next major release, and it
was postponed to the v8.5 development cycle due to lack of time
for enough reviewing the feature.

If it can be released on schedule, the v8.4 is released on the
second quarter of 2009, and the v8.5 will be relased on a year
later (but it tend to delay a few months).
So, it is necessary to apply SE-PostgreSQL patches or install
it from RPM package distributed via Fedora project. :(

Under the discussion, I got a few suggestions in its security
design, and it seems to me fair enough. Some of them needs to
change definitions in the default policy.

See the following items,

* new permission: db_database:{superuser}

They required a new permission to control database superuser
privileges similar to "root" capability in operating system.
The concept of superuser is common for some of major DBMSs,
not only PostgreSQL. In addition, it seems to me well symmetric
with operating system.

The db_database:{superuser} controls whether the client can
perform as database superuser on the given database, or not.

* undesired permission: db_database:{set_param get_param}

They wondered the necessity of these checks, because SQL spec
does not require checks in set/get database parameters.
I didn't think it is necessary the security design of SELinux
should be symmetric with SQL, but I also thought these might
be unnecessary due to another reason.
In PostgreSQL, the scope of database parameters are session
local and initialized on the connection startup, so we cannot
use it as a pass to communicate between different two or more
domains.

* undesired permission: db_table/db_column/db_tuple:{use}

I originally proposed the {use} permission to set up write-only
tables, but it might be a misdesign.
(Sorry, a bit long description.)

At the initial design, SE-PostgreSQL applied {select} permission
for all the refered tables, columns and tuples. But, it also means
{select} permission is necessary for conditional DELETE or UPDATE
even if its content is not exposed to the client.
So, I proposed the privilege into two different permission: {select}
and {use}. The {select} allows the client to refer the object and
its content can be returned to him. The {use} also allows the client
to refer the object but its content has to be consumed internally.

Example)
SELECT a, b FROM t WHERE c = 5;
In this case, we need {select} on column t.a and t.b, but {use}
is required on column t.c because its content is consumed by
SE-PostgreSQL itself and not returned to the client.

Example)
UPDATE t SET x = 20 WHERE y = 'aaa';
In this case, we need {update} on column t.x, and {use} on t.y,
but {select} is not necessary.

However, we can break it rapidly with a clever condition clause.
For example, we can get a result from the first trial:
DELETE FROM account WHERE userid = 100 and creditno like '1%';

If this query removes a tuple, it means the first character of
credit card number is '1'. If not so, he can try it 9 times.
Then, he can get the information without {select} permission,
with enough small number of trials.

They concluded the "{use}" permission cannot work correctly, and
danger to expect it does not allow to leak contexnt to the outside.
I can agree this opinion.


The attached patch add/remove these permissions.
Any comments please.

Thanks,
--
OSS Platform Development Division, NEC
KaiGai Kohei <[email protected]>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: refpolicy-sepgsql-perms.patch
Type: text/x-patch
Size: 5130 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20090323/d55fa108/attachment.bin


2009-03-23 15:25:39

by Stephen Smalley

[permalink] [raw]
Subject: [refpolicy] The status of SE-PostgreSQL

On Mon, 2009-03-23 at 19:37 +0900, KaiGai Kohei wrote:
> Here is a bad news.
>
> I've had a discussion in pgsql-hackers list for a long time, but
> we cannot get a conclusion that SE-PostgreSQL should be merged
> in the PostgreSQL v8.4 which is the next major release, and it
> was postponed to the v8.5 development cycle due to lack of time
> for enough reviewing the feature.
>
> If it can be released on schedule, the v8.4 is released on the
> second quarter of 2009, and the v8.5 will be relased on a year
> later (but it tend to delay a few months).
> So, it is necessary to apply SE-PostgreSQL patches or install
> it from RPM package distributed via Fedora project. :(
>
> Under the discussion, I got a few suggestions in its security
> design, and it seems to me fair enough. Some of them needs to
> change definitions in the default policy.
>
> See the following items,
>
> * new permission: db_database:{superuser}
>
> They required a new permission to control database superuser
> privileges similar to "root" capability in operating system.
> The concept of superuser is common for some of major DBMSs,
> not only PostgreSQL. In addition, it seems to me well symmetric
> with operating system.
>
> The db_database:{superuser} controls whether the client can
> perform as database superuser on the given database, or not.

Any chance of splitting this up into finer-grained privileges?
And what precisely are the implications of this permission: does it
effectively make all of the other permission checks irrelevant for the
subject? In comparison, the SELinux capability permissions only allow
the subject to override e.g. DAC file checks, not the SELinux MAC file
checks.

>
> * undesired permission: db_database:{set_param get_param}
>
> They wondered the necessity of these checks, because SQL spec
> does not require checks in set/get database parameters.
> I didn't think it is necessary the security design of SELinux
> should be symmetric with SQL, but I also thought these might
> be unnecessary due to another reason.
> In PostgreSQL, the scope of database parameters are session
> local and initialized on the connection startup, so we cannot
> use it as a pass to communicate between different two or more
> domains.

Are any of the database parameters security-relevant (not just
information flow)?

--
Stephen Smalley
National Security Agency

2009-03-24 01:13:50

by Kohei KaiGai

[permalink] [raw]
Subject: [refpolicy] The status of SE-PostgreSQL

>> See the following items,
>>
>> * new permission: db_database:{superuser}
>>
>> They required a new permission to control database superuser
>> privileges similar to "root" capability in operating system.
>> The concept of superuser is common for some of major DBMSs,
>> not only PostgreSQL. In addition, it seems to me well symmetric
>> with operating system.
>>
>> The db_database:{superuser} controls whether the client can
>> perform as database superuser on the given database, or not.
>
> Any chance of splitting this up into finer-grained privileges?

I basically think it is good idea from the viewpoint of security.
However, if they separate the superuser privige into finer-grained
ones without SQL specification, its design will fully depends on
PostgreSQL.

> And what precisely are the implications of this permission: does it
> effectively make all of the other permission checks irrelevant for the
> subject? In comparison, the SELinux capability permissions only allow
> the subject to override e.g. DAC file checks, not the SELinux MAC file
> checks.

In currently, it checks the context of client (subject) and the one
of database (object), but it can be fixed soon.
We already have several permissions on db_database class. Some of
them are checked on the database object, and the "superuser" is
checked on the subject itself. Is it no matter?

>> * undesired permission: db_database:{set_param get_param}
>>
>> They wondered the necessity of these checks, because SQL spec
>> does not require checks in set/get database parameters.
>> I didn't think it is necessary the security design of SELinux
>> should be symmetric with SQL, but I also thought these might
>> be unnecessary due to another reason.
>> In PostgreSQL, the scope of database parameters are session
>> local and initialized on the connection startup, so we cannot
>> use it as a pass to communicate between different two or more
>> domains.
>
> Are any of the database parameters security-relevant (not just
> information flow)?

It provide a parameter of "sepostgresql=(on|off)" to turn on/off
its feature, but it is not allowed to change via SQL commands.
This parameter is initialized with the configuration file on
the server startup time, then it is handled as read-only.

If a man who can modify "$PGDATA/postgresql.conf" disables
SE-PostgreSQL, we have the matter in different place.

Thanks,
--
OSS Platform Development Division, NEC
KaiGai Kohei <[email protected]>