Skip to contentSkip to conversation

sshd transition points (user@ip or net_context with setcon)

DISCUSSION Luke Kenneth Casson Leighton 3 participants 5 messages Feb 21, 2005 – Apr 22, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

hi,

after kindly receiving a message which advised how to achieve the same net effect as sought (using AllowUsers in sshd_config) i was wondering if anyone considered it _actually_ worthwhile to go ahead and provide a means to achieve the same effect (as AllowUsers) with SE-Linux policy and some modifications to sshd (to use setcon and thereby be able to do net_contexts on a per-user basis).

basically: can anyone think of a justification for the mods to sshd - _other than_ a "defense in depth" argument, given that what i originally aimed to do achieves the same end-result as AllowUsers?

e.g. oh i dunno, being able to lock down the priv_sep sshd, and the monitor process, because they would have distinct selinux domains?

[the fact that if someone helped me come up with a justification
i could then utilise that to maybe get some extra $ out of the client is purely coincidental :) ]

i'd be more than happy to accept "no, we believe the present sshd selinux arrangement is perfectly good enough for most xyz circumstances".

l.

Signature · 8 lines
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

--
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.
#1 lore raw
Quoted 3 lines · Luke Kenneth Casson Leighton

e.g. oh i dunno, being able to lock down the priv_sep sshd, and the monitor process, because they would have distinct selinux domains?

Being able to assign different permissions (particularly different capabilities) to the listening sshd, parent monitor process, and unprivileged child process seems useful. But that doesn't require anything per-user and can be done _before_ the user identity is even acquired from the client. It would be better to switch domains prior to processing input from the client (other than the initial connection) to reduce the likelihood of exploitation prior to the domain switch.

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.
#3 lore raw
In reply to Luke Kenneth Casson Leighton
Quoted 7 lines · Luke Kenneth Casson Leighton

*hand-waving* something along the lines of AllowUsers not showing up in the avc audit logs? doesn't cut it because the authentication failure from a different location would appear in the auth logs instead.

*more-hand-waving* sshd's multi-stage approach isn't tracked well enough by the selinux strict policy yet?

I think using AllowUsers makes sense for the original problem you described, and that the multiple sshd instance approach makes sense when you want to isolate the reachable roles per interface. The latter point (about sshd's privsep architecture not being fully leveraged by SELinux yet) is certainly valid, but not necessarily justifying for your intended usage.

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.
#2 lore raw
In reply to Stephen Smalley
Quoted 10 lines · Stephen Smalley
Quoted 3 lines · Luke Kenneth Casson Leighton

e.g. oh i dunno, being able to lock down the priv_sep sshd, and the monitor process, because they would have distinct selinux domains?

Being able to assign different permissions (particularly different capabilities) to the listening sshd, parent monitor process, and unprivileged child process seems useful. But that doesn't require anything per-user and can be done _before_ the user identity is even acquired from the client.

yes.

Quoted 3 lines

It would be better to switch domains prior to
processing input from the client (other than the initial connection) to reduce the likelihood of exploitation prior to the domain switch.

i anticipate that this would be a multi-stage approach, requiring several distinct domains, to mirror the fact that sshd itself is a multi-stage paranoid demon [no, that's not a spelling mistake].

even though it's the "later" stages that i [personally] am more interested in, i think it'd be a case of "in for a penny in for a pound" so the use of several setcon() calls to mirror each fork() plus set[e]uid() would be required.

so there's quite a bit involved, hence reasons like "nice" don't quite cut it. "defense in depth" is a good reason, but not enough of one to justify the client paying for the work to be done.

*hand-waving* something along the lines of AllowUsers not showing up in the avc audit logs? doesn't cut it because the authentication failure from a different location would appear in the auth logs instead.

*more-hand-waving* sshd's multi-stage approach isn't tracked well enough by the selinux strict policy yet?

l.

--
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
In reply to Luke Kenneth Casson Leighton
Quoted 6 lines · Luke Kenneth Casson Leighton

after kindly receiving a message which advised how to achieve the same net effect as sought (using AllowUsers in sshd_config) i was wondering if anyone considered it _actually_ worthwhile to go ahead and provide a means to achieve the same effect (as AllowUsers) with SE-Linux policy and some modifications to sshd (to use setcon and thereby be able to do net_contexts on a per-user basis).

Have you considered using sshd_extern_t?

The current policy allows you to configure inetd to run sshd via:
runcon system_u:system_r:sshd_extern_t sshd -- -i

You could have sshd being run with the default context for connections corresponding to trusted IP addresses and use runcon to get sshd_extern_t for others. The policy is flexible enough to allow multiple sshd contexts to be added easily which correspond to different combinations of user roles.

Some inetd programs allow running different programs based on IP address, while others require you to use a different port for each one (maybe have the firewall convert incoming connections to different destination ports based on the source IP Address).

The disadvantage of AllowUsers is that it's enforced by the sshd itself. If you are concerned about the security of the sshd then restricting external users to security contexts that don't permit any damage is a good idea.

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
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.