Skip to contentSkip to conversation

policy for scponly - need help

DISCUSSION Stefan SF 4 participants 9 messages Aug 19, 2004 – Aug 26, 2004 1 message not in the archive SELinux security module

lore
Share & tools
lore

Stefan SF

author
#0 lore raw

Hi,

I'm trying to build a policy for a program called "scponly". The rudimentary things went all right! Here are the files:

# domains/program/scponly.te
type scponly_exec_t, file_type, exec_type, sysadmfile;

ifdef(ssh.te',
allow sshd_t scponly_exec_t:file { getattr execute read }; allow user_t scponly_exec_t:file { entrypoint }; ')

# file_contexts/program/scponly.fc
/usr/bin/scponly                system_u:object_r:scponly_exec_t
/usr/sbin/scponlyc              system_u:object_r:scponly_exec_t

When I'm using the scponly program all things went fine, but when I'm trying to use the scponlyc program I get this message:

audit(1092936373.217:0): avc:  denied  { dac_override } for  pid=5220 exe=/usr/sbin/scponlyc capability=1 scontext=test:user_r:user_t tcontext=test:user_r:user_t tclass=capability
audit(1092936373.217:0): avc:  denied  { dac_read_search } for  pid=5220 exe=/usr/sbin/scponlyc capability=2 scontext=test:user_r:user_t tcontext=test:user_r:user_t tclass=capability

Is there a way to put the restrictions dac_* to the scponly-policy or do I have to modify the user-policy? Because the scontext and the tcontext belongs alway to the user-policy.

ciao, Stefan

#1 lore raw
Quoted 3 lines · Stefan SF

Hi,

I'm trying to build a policy for a program called "scponly".

scponly seems similar to rssh. You may want to try my rssh policy:
http://verbum.org/files/rssh_macros.te
http://verbum.org/files/rssh.te
http://verbum.org/files/rssh.fc

It would likely be sufficient to just add a regexp for scponly to rssh.fc.

Quoted 4 lines

When I'm using the scponly program all things went fine, but when I'm trying to use the scponlyc program I get this message:

audit(1092936373.217:0): avc:  denied  { dac_override } for  pid=5220 exe=/usr/sbin/scponlyc capability=1 scontext=test:user_r:user_t tcontext=test:user_r:user_t tclass=capability
audit(1092936373.217:0): avc:  denied  { dac_read_search } for  pid=5220 exe=/usr/sbin/scponlyc capability=2 scontext=test:user_r:user_t tcontext=test:user_r:user_t tclass=capability

Hmmm, odd. Are you logging in as root?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#2 lore raw

Hi!

Quoted 4 lines

scponly seems similar to rssh. You may want to try my rssh policy:
http://verbum.org/files/rssh_macros.te
http://verbum.org/files/rssh.te
http://verbum.org/files/rssh.fc

Hmm I can't make head or tail of this. I think the scponly-problem is another one. Because you don't have to transit or anything else in the rssh-policy (user -> role).

Quoted 2 lines

It would likely be sufficient to just add a regexp for scponly to rssh.fc.

For what? I think this is not a problem of correct labeling.

Quoted 1 line

Hmmm, odd. Are you logging in as root?

No, the program is only to /usr/sbin installed because it uses some functions which are only to priviliged peoples related, I think.

I've created policies all the time ;-) but nothing right was coming out! I've still the same problem, that I can't allow the user_t capabilities, without edeting the uesr.te files! It would be great, if I only have to edit the scponly-policy-files. I think all permissions for the program should go there.

Here is on of my tries:

# domains/program/scponly.te
type scponly_t, domain, privowner;
type scponly_exec_t, file_type, exec_type, sysadmfile;

domain_auto_trans(user_t, scponly_exec_t, scponly_t) domain_auto_trans(sysadm_t, scponly_exec_t, scponly_t)

role user_r types scponly_t;
role sysadm_r types scponly_t;

ifdef(ssh.te',
allow sshd_t scponly_exec_t:file { getattr execute read }; allow user_t scponly_exec_t:file { entrypoint }; ')

ifdef(user.te',
allow user_t:capability { dac_override dac_read_search }; domain_auto_trans(user_t, scponly_exec_t, scponly_$1_t); ')

I thought with a domain_auto_trans the problem should get fixed, but the output from avc is still the same.

audit(1092988519.353:0): avc:  denied  { dac_override } for  pid=7088 exe=/usr/sbin/scponlyc capability=1 scontext=test:user_r:user_t tcontext=trade:user_r:user_t tclass=capability
audit(1092988519.353:0): avc:  denied  { dac_read_search } for  pid=7088 exe=/usr/sbin/scponlyc capability=2 scontext=test:user_r:user_t tcontext=trade:user_r:user_t tclass=capability

Any hints, tipps or related policy-files would be great! ;-)

ciao, Stefan

#3 lore raw

Hello-

I'm just a newbie at this, but it looks like a term is missing from your last 'allow' statement. Perhaps it should be:

allow user_t self:capability { dac_override dac_read_search };

Richard

Quoted 62 lines

Hi!

Quoted 4 lines

scponly seems similar to rssh. You may want to try my rssh policy:
http://verbum.org/files/rssh_macros.te
http://verbum.org/files/rssh.te
http://verbum.org/files/rssh.fc

Hmm I can't make head or tail of this. I think the scponly-problem is another one. Because you don't have to transit or anything else in the rssh-policy (user -> role).

Quoted 2 lines

It would likely be sufficient to just add a regexp for scponly to rssh.fc.

For what? I think this is not a problem of correct labeling.

Quoted 1 line

Hmmm, odd. Are you logging in as root?

No, the program is only to /usr/sbin installed because it uses some functions which are only to priviliged peoples related, I think.

I've created policies all the time ;-) but nothing right was coming out! I've still the same problem, that I can't allow the user_t capabilities, without edeting the uesr.te files! It would be great, if I only have to edit the scponly-policy-files. I think all permissions for the program should go there.

Here is on of my tries:

# domains/program/scponly.te
type scponly_t, domain, privowner;
type scponly_exec_t, file_type, exec_type, sysadmfile;

domain_auto_trans(user_t, scponly_exec_t, scponly_t) domain_auto_trans(sysadm_t, scponly_exec_t, scponly_t)

role user_r types scponly_t;
role sysadm_r types scponly_t;

ifdef(ssh.te',
allow sshd_t scponly_exec_t:file { getattr execute read }; allow user_t scponly_exec_t:file { entrypoint }; ')

ifdef(user.te',
allow user_t:capability { dac_override dac_read_search }; domain_auto_trans(user_t, scponly_exec_t, scponly_$1_t); ')

I thought with a domain_auto_trans the problem should get fixed, but the output from avc is still the same.

audit(1092988519.353:0): avc: denied { dac_override } for pid=7088 exe=/usr/sbin/scponlyc capability=1 scontext=test:user_r:user_t tcontext=trade:user_r:user_t tclass=capability audit(1092988519.353:0): avc: denied { dac_read_search } for pid=7088 exe=/usr/sbin/scponlyc capability=2 scontext=test:user_r:user_t tcontext=trade:user_r:user_t tclass=capability

Quoted 5 lines

Any hints, tipps or related policy-files would be great! ;-)

ciao, Stefan

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 6 lines · Richard Simpson

Hello-

I'm just a newbie at this, but it looks like a term is missing from your last 'allow' statement. Perhaps it should be:

allow user_t self:capability { dac_override dac_read_search };

You don't want to give user_t those capabilities.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#5 lore raw

Hi,

Quoted 1 line
Quoted 1 line

allow user_t self:capability { dac_override dac_read_search };

Yes that's right. But how Walters mentioned before this is a security risk and I've read through his rssh-policy files and found a much cleaner way. I will post the policy in some days (cleanups will done).

thx, Stefan

#6 lore raw
In reply to Stefan SF
Quoted 9 lines · Stefan SF

Hi!

Quoted 4 lines

scponly seems similar to rssh. You may want to try my rssh policy:
http://verbum.org/files/rssh_macros.te
http://verbum.org/files/rssh.te
http://verbum.org/files/rssh.fc

Hmm I can't make head or tail of this. I think the scponly-problem is another one.
Because you don't have to transit or anything else in the rssh-policy (user -> role).

Exactly the point! The kernel thus ensures that the user is not able to enter the user_r role at all. This is far more secure than what you are doing with transitioning from user_t to scponly_exec_t. Instead, I only authorize the user for the rssh role.

Here, I documented the process a bit better a while ago:
http://marc.theaimsgroup.com/?l=selinux&m=107395821724390&w=2

You shouldn't need to touch user_t at all.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#7 lore raw

Hi!

Yeah that was it ;-)
Your documentation about the rssh had helped me a lot! I've now a scponly-chrootet user. I will do some policy-cleanups and post it to the list. Maybe someone can read through it and say if I had done some security risks!

Thank you very much indeed!

ciao, Stefan

A message that is not in the archive (sent off-list or not yet received): 20040820162215.GA15914@crux

author
#9 lore raw

Hi,

ok, I've altered the rules and hope that there is no big hole in it ;-) So here are the files:

domains/program/scponly.te
#DESC scponly - A shell which provides only scp/sftp access #
# It's based on Colin Walters "rssh" policy

type scponly_exec_t, file_type, exec_type, sysadmfile;

ifdef(ssh.te',
allow sshd_t scponly_exec_t:file { getattr execute read }; allow trade_t scponly_exec_t:file { entrypoint }; ')

macros/program/scponly_macros.te
#DESC scponly - A shell which provides only scp/sftp access #
# It's based on Colin Walters "rssh" policy

undefine(`scponly_domain')
ifdef(scponly.te', define(scponly_domain',
type scponly_$1_t, domain, userdomain, privlog, privfd; role scponly_$1_r types scponly_$1_t;
allow system_r scponly_$1_r;

# types for correct labeling
type scponly_$1_home_dir_t, file_type, sysadmfile;
type scponly_$1_home_t, file_type, sysadmfile;
type scponly_$1_home_ssh_t, file_type, sysadmfile;
# types for read and write
type scponly_$1_rw_t, file_type, sysadmfile;
type scponly_$1_ro_t, file_type, sysadmfile;

general_domain_access(scponly_$1_t);
uses_shlib(scponly_$1_t);
base_file_read_access(scponly_$1_t);
r_dir_file(scponly_$1_t, etc_t);
r_dir_file(scponly_$1_t, etc_runtime_t);
can_exec(scponly_$1_t, bin_t);

# basic read/write
r_dir_file(scponly_$1_t, scponly_$1_ro_t);
create_dir_file(scponly_$1_t, scponly_$1_rw_t);
# scponlyc needs to chroot
allow scponly_$1_t scponly_$1_t:capability { dac_override dac_read_search setuid sys_chroot };
allow scponly_$1_t scponly_$1_home_dir_t:dir { getattr read search };
allow scponly_$1_t scponly_$1_ro_t:file { execute execute_no_trans };

ifdef(ssh.te',
allow scponly_$1_t sshd_t:unix_stream_socket rw_stream_socket_perms; r_dir_file(sshd_t, scponly_$1_ro_t);
domain_trans(sshd_t, scponly_exec_t, scponly_$1_t);
')
')

', `

define(scponly_domain',')

')

file_contexts/program/scponly.fc
/usr/bin/scponly system_u:object_r:scponly_exec_t
/usr/sbin/scponlyc system_u:object_r:scponly_exec_t

domains/misc/local.te
scponly_domain(user)

ciao, Stefan