pam_namespace improvements ..
Hi Russell,
After going thorugh the pam_namespace thread again and after talking to some of my peeps, I do see that a mode 000 instance parent can thwart attacks by non-root daemons and non-polyinstanted users on polyinstanted users.
The current implementation of pam_namespace already depends on the existance of the instance parent and allows the admin to configure the names of different instances. I will update the namespace.conf man page, and the comment text in the namespace.conf file to guide admins to appropriately create a different instance parent (and not use the poly dir itself, like the current example suggests). That way, an admin can create an intermediate directory like .inst with 000 or create a whole different directory with 000.
Thanks.
-Janak
--
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.
Quoted 4 lines · Janak Desai
After going thorugh the
pam_namespacethread again and after talking to some of my peeps, I do see that a mode 000 instance parent can thwart attacks by non-root daemons and non-polyinstanted users on polyinstanted users.
OK.
Quoted 8 lines
The current implementation of
pam_namespacealready depends on the existance of the instance parent and allows the admin to configure the names of different instances. I will update the namespace.conf man page, and the comment text in the namespace.conf file to guide admins to appropriately create a different instance parent (and not use the poly dir itself, like the current example suggests). That way, an admin can create an intermediate directory like .inst with 000 or create a whole different directory with 000.
I'm glad that we have agreement on this issue. However I would like to go further.
I would like to have the default configuration of major distributions (Fedora, Debian, and Gentoo) have some changes to make things more secure in this regard.
I believe that we need a script run at boot time to create such directories if they don't exist and rename a directory with the name but the wrong permissions before creating it if necessary. Having the administrator create the directory with mkdir and then chmod it will work for Fedora IFF a persistent file system is used for /tmp. Due to other issues SE Linux compels the use of a persistent file system for /tmp at this time (I consider this a bug and have long-term plans to fix it), however we also want to support non-SE users.
I also believe that pam_namespace should have the optional ability (determined by a command-line parameter or a config-file setting) to verify the Unix permissions and SE Linux context of the mode 000 directory and reject user logins if the permissions are considered to be inappropriate.
Configuration tools to support enabling all this functionality in a convenient manner would also be good.
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.
Quoted 27 lines · Russell Coker
Quoted 6 lines · Janak Desai
After going thorugh the
pam_namespacethread again and after talking to some of my peeps, I do see that a mode 000 instance parent can thwart attacks by non-root daemons and non-polyinstanted users on polyinstanted users.OK.
Quoted 10 lines
The current implementation of
pam_namespacealready depends on the existance of the instance parent and allows the admin to configure the names of different instances. I will update the namespace.conf man page, and the comment text in the namespace.conf file to guide admins to appropriately create a different instance parent (and not use the poly dir itself, like the current example suggests). That way, an admin can create an intermediate directory like .inst with 000 or create a whole different directory with 000.I'm glad that we have agreement on this issue. However I would like to go further.
Quoted 10 lines
I would like to have the default configuration of major distributions (Fedora, Debian, and Gentoo) have some changes to make things more secure in this regard.
I believe that we need a script run at boot time to create such directories if they don't exist and rename a directory with the name but the wrong permissions before creating it if necessary. Having the administrator create the directory with mkdir and then chmod it will work for Fedora IFF a persistent file system is used for /tmp. Due to other issues SE Linux compels the use of a persistent file system for /tmp at this time (I consider this a bug and have long-term plans to fix it), however we also want to support non-SE users.
I also believe that
pam_namespaceshould have the optional ability (determined by a command-line parameter or a config-file setting) to verify the Unix permissions and SE Linux context of the mode 000 directory and reject user logins if the permissions are considered to be inappropriate.Configuration tools to support enabling all this functionality in a convenient manner would also be good.
Ok, thanks. I will add an option to pam_namespace to allow an admin to NOT check the mode of the instance parent. By default, pam_namespace will require the mode to be 000. As far as SELinux context, what is the appropriate context for an instance parent? Isn't it ok to leave that upto the system security policy? Because of different types of polyinstantiated directories, I cannot comprehend a definitive context that pam_namespace could/should check for.
Thanks.
-Janak
--
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.
PATCH 1/1 pam_namespace : option to check instance parent mode and man page(s) updates
This patch, which applies on top of the latest pam_namespace in rawhide, adds a new
command line option to allow an admin to bypass checking of the instance parent mode. It also updates namespace.conf and pam_namespace man pages to add text relating this new option, interaction with share-subtree and possible config changes that would allow the use of pam_namespace with gdm and polyinstantiation of /tmp.
---
README | 95 ++++++++++++++++++++++++++++++--------------------- namespace.conf | 22 +++++++++-- namespace.conf.5.xml | 42 +++++++++++++--------- pam_namespace.8.xml | 79 ++++++++++++++++++++++++++++++++++++++++++ pam_namespace.c | 49 +++++++++++++++++++++++++- 5 files changed, 227 insertions(+), 60 deletions(-)
modules/pam_namespace/README +56 -39
@@ -3,17 +3,17 @@ pam_namespace module: Setup a private namespace with polyinstantiated directories. THEORY OF OPERATION: -The pam namespace module consults /etc/security/namespace.conf +The pam namespace module consults /etc/security/namespace.conf configuration file and sets up a private namespace with polyinstantiated directories for a session managed by PAM. A skeleton namespace.conf -installed by default provides example for polyinstantiating /tmp +installed by default provides example for polyinstantiating /tmp, /var/tmp and users' home directory. If an executable script /etc/security/namespace.init exists, it is used to initialize the namespace every time a new instance directory is created. The script receives the polyinstantiated directory path and the instance directory path as its arguments. - + Each line in namespace.conf describes a limit for a user in the form: <polydir> <instance_prefix> <method> <list_of_uids>
@@ -29,7 +29,7 @@ Where: the prefix to generate the final instance directory path. This directory is created if it did not exist already, and is then bind mounted on the <polydir> to provide an instance of <polydir> - based on the <method> column. The special string $HOME is replaced with + based on the <method> column. The special string $HOME is replaced with the user's home directory, and $USER with the username. This field cannot be blank.
@@ -54,43 +54,60 @@ EXAMPLE /etc/security/namespace.conf con # /var/tmp, whereas home directories will be polyinstantiated for all # users. The user name and/or context is appended to the instance prefix. # -/tmp /tmp-inst/ both root,adm -/var/tmp /var/tmp-inst/ both root,adm -$HOME $HOME.inst- context - -ARGUMENTS RECOGNIZED: - debug Verbose logging by syslog +# Note that instance directories do not have to reside inside the +# polyinstantiated directory. In the examples below, instances of /tmp +# will be created in /tmp-inst directory, where as instances of /var/tmp +# and users home directories will reside within the directories that +# are being polyinstantiated. +# +# Instance parent directories must exist for the polyinstantiation +# mechanism to work. By default, they should be created with the mode +# of 1000. pam_namespace module will enforce this mode unless it +# is explicitly called with an argument to ignore the mode of the +# instance parent. System administrators should use this argument with +# caution, as it will reduce security and isolation achieved by +# polyinstantiation. +# +/tmp /tmp-inst/ both root,adm +/var/tmp /var/tmp/tmp-inst/ both root,adm +$HOME $HOME/$USER.inst/inst- context - unmnt_remnt For programs such as su and newrole, the login - session has already setup a polyinstantiated - namespace. For these programs, polyinstantiation - is performed based on new user id or security - context, however the command first needs to - undo the polyinstantiation performed by login. - This argument instructs the command to - first undo previous polyinstantiation before - proceeding with new polyinstantiation based on - new id/context. - - unmnt_only For trusted programs that want to undo any - existing bind mounts and process instance - directories on their own, this argument allows - them to unmount currently mounted instance - directories. - - require_selinux If selinux is not enabled, return failure. - - gen_hash Instead of using the security context string - for the instance name, generate and use its - md5 hash. - - ignore_config_error If a line in the configuration file corresponding - to a polyinstantiated directory contains format - error, skip that line process the next line. - Without this option, pam will return an error - to the calling program resulting in termination - of the session. +ARGUMENTS RECOGNIZED: + debug + Verbose logging by syslog + unmnt_remnt + For programs such as su and newrole, the login session has + already setup a polyinstantiated namespace. For these programs, + polyinstantiation is performed based on new user id or security + context, however the command first needs to undo the + polyinstantiation performed by login. This argument instructs + the command to first undo previous polyinstantiation before + proceeding with new polyinstantiation based on new id/context. + + unmnt_only + For trusted programs that want to undo any existing bind mounts + and process instance directories on their own, this argument + allows them to unmount currently mounted instance directories. + + require_selinux + If selinux is not enabled, return failure. + + gen_hash + Instead of using the security context string for the instance + name, generate and use its md5 hash. + + ignore_config_error + If a line in the configuration file corresponding to a + polyinstantiated directory contains format error, skip that + line process the next line. Without this option, pam will return + an error to the calling program resulting in termination + of the session. + + ignore_instance_parent_mode + Instance parent directories by default are expected to have + the restrictive mode of 1000. Using this option, an administrator + can choose to ignore the mode of the instance parent. MODULE SERVICES PROVIDED: session open_session and close_session
modules/pam_namespace/namespace.conf +18 -4
@@ -1,7 +1,7 @@ # /etc/security/namespace.conf # # See /usr/share/doc/pam-*/txts/README.pam_namespace for more information. -# +# # Uncommenting the following three lines will polyinstantiate # /tmp, /var/tmp and user's home directories. /tmp and /var/tmp will # be polyinstantiated based on both security context as well as user
@@ -11,6 +11,20 @@ # directories will be polyinstantiated for all users. The user name # and/or context is appended to the instance prefix. # -#/tmp /tmp.inst/ both adm -#/var/tmp /var/tmp.inst/ both adm -#$HOME $HOME.inst- context +# Note that instance directories do not have to reside inside the +# polyinstantiated directory. In the examples below, instances of /tmp +# will be created in /tmp-inst directory, where as instances of /var/tmp +# and users home directories will reside within the directories that +# are being polyinstantiated. +# +# Instance parent directories must exist for the polyinstantiation +# mechanism to work. By default, they should be created with the mode +# of 1000. pam_namespace module will enforce this mode unless it +# is explicitly called with an argument to ignore the mode of the +# instance parent. System administrators should use this argument with +# caution, as it will reduce security and isolation achieved by +# polyinstantiation. +# +#/tmp /tmp-inst/ both root,adm +#/var/tmp /var/tmp/tmp-inst/ both root,adm +#$HOME $HOME/$USER.inst/inst- context
modules/pam_namespace/namespace.conf.5.xml +26 -16
64 lines not on this page · raw message
modules/pam_namespace/pam_namespace.8.xml +79 -0
109 lines not on this page · raw message
modules/pam_namespace/pam_namespace.c +48 -1
74 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] pam_namespace : option to check instance parent mode and man page(s) updates
Quoted 8 lines · Tomas Mraz
Quoted 4 lines · Janak Desai
This patch, which applies on top of the latest
pam_namespacein rawhide, adds a new
command line option to allow an admin to bypass checking of the instance parent mode. It also updates namespace.conf andpam_namespaceman pages to add text relating this new option, interaction with share-subtree and possible config changes that would allow the use ofpam_namespacewith gdm and polyinstantiation of /tmp.
Quoted 4 lines
In the documentation files there is always written that the mode of the parent directory is checked to be 1000 but in the code you check only the user, group and other bits. Should the documentation be adjusted to say 000?
Oops. The documentation is correct. The code should also check for the sticky bit. I will fix that and send updated patch later this afternoon.
-Janak
--
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.
PATCH 1/1 pam_namespace : option to check instance parent mode and man page(s) updates - v2
In reply to Janak DesaiThis patch, which applies on top of the latest pam_namespace in rawhide, adds a new command line option to allow an admin to bypass checking of the instance parent mode. It also updates namespace.conf and pam_namespace man pages to add text relating this new option, interaction with share-subtree and possible config changes that would allow the use ofpam_namespace with gdm and polyinstantiation of /tmp.
The only changes to this patch since the last time it was posted on the selinux mailing list yesterday, are the documentation updates to change the instance parent mode references to 000 from 1000. Sticky bits are not needed since the directory itself is not writable.
---
README | 95 ++++++++++++++++++++++++++++++--------------------- namespace.conf | 22 +++++++++-- namespace.conf.5.xml | 42 +++++++++++++--------- pam_namespace.8.xml | 79 ++++++++++++++++++++++++++++++++++++++++++ pam_namespace.c | 49 +++++++++++++++++++++++++- 5 files changed, 227 insertions(+), 60 deletions(-)
modules/pam_namespace/README +56 -39
@@ -3,17 +3,17 @@ pam_namespace module: Setup a private namespace with polyinstantiated directories. THEORY OF OPERATION: -The pam namespace module consults /etc/security/namespace.conf +The pam namespace module consults /etc/security/namespace.conf configuration file and sets up a private namespace with polyinstantiated directories for a session managed by PAM. A skeleton namespace.conf -installed by default provides example for polyinstantiating /tmp +installed by default provides example for polyinstantiating /tmp, /var/tmp and users' home directory. If an executable script /etc/security/namespace.init exists, it is used to initialize the namespace every time a new instance directory is created. The script receives the polyinstantiated directory path and the instance directory path as its arguments. - + Each line in namespace.conf describes a limit for a user in the form: <polydir> <instance_prefix> <method> <list_of_uids>
@@ -29,7 +29,7 @@ Where: the prefix to generate the final instance directory path. This directory is created if it did not exist already, and is then bind mounted on the <polydir> to provide an instance of <polydir> - based on the <method> column. The special string $HOME is replaced with + based on the <method> column. The special string $HOME is replaced with the user's home directory, and $USER with the username. This field cannot be blank.
@@ -54,43 +54,60 @@ EXAMPLE /etc/security/namespace.conf con # /var/tmp, whereas home directories will be polyinstantiated for all # users. The user name and/or context is appended to the instance prefix. # -/tmp /tmp-inst/ both root,adm -/var/tmp /var/tmp-inst/ both root,adm -$HOME $HOME.inst- context - -ARGUMENTS RECOGNIZED: - debug Verbose logging by syslog +# Note that instance directories do not have to reside inside the +# polyinstantiated directory. In the examples below, instances of /tmp +# will be created in /tmp-inst directory, where as instances of /var/tmp +# and users home directories will reside within the directories that +# are being polyinstantiated. +# +# Instance parent directories must exist for the polyinstantiation +# mechanism to work. By default, they should be created with the mode +# of 000. pam_namespace module will enforce this mode unless it +# is explicitly called with an argument to ignore the mode of the +# instance parent. System administrators should use this argument with +# caution, as it will reduce security and isolation achieved by +# polyinstantiation. +# +/tmp /tmp-inst/ both root,adm +/var/tmp /var/tmp/tmp-inst/ both root,adm +$HOME $HOME/$USER.inst/inst- context - unmnt_remnt For programs such as su and newrole, the login - session has already setup a polyinstantiated - namespace. For these programs, polyinstantiation - is performed based on new user id or security - context, however the command first needs to - undo the polyinstantiation performed by login. - This argument instructs the command to - first undo previous polyinstantiation before - proceeding with new polyinstantiation based on - new id/context. - - unmnt_only For trusted programs that want to undo any - existing bind mounts and process instance - directories on their own, this argument allows - them to unmount currently mounted instance - directories. - - require_selinux If selinux is not enabled, return failure. - - gen_hash Instead of using the security context string - for the instance name, generate and use its - md5 hash. - - ignore_config_error If a line in the configuration file corresponding - to a polyinstantiated directory contains format - error, skip that line process the next line. - Without this option, pam will return an error - to the calling program resulting in termination - of the session. +ARGUMENTS RECOGNIZED: + debug + Verbose logging by syslog + unmnt_remnt + For programs such as su and newrole, the login session has + already setup a polyinstantiated namespace. For these programs, + polyinstantiation is performed based on new user id or security + context, however the command first needs to undo the + polyinstantiation performed by login. This argument instructs + the command to first undo previous polyinstantiation before + proceeding with new polyinstantiation based on new id/context. + + unmnt_only + For trusted programs that want to undo any existing bind mounts + and process instance directories on their own, this argument + allows them to unmount currently mounted instance directories. + + require_selinux + If selinux is not enabled, return failure. + + gen_hash + Instead of using the security context string for the instance + name, generate and use its md5 hash. + + ignore_config_error + If a line in the configuration file corresponding to a + polyinstantiated directory contains format error, skip that + line process the next line. Without this option, pam will return + an error to the calling program resulting in termination + of the session. + + ignore_instance_parent_mode + Instance parent directories by default are expected to have + the restrictive mode of 000. Using this option, an administrator + can choose to ignore the mode of the instance parent. MODULE SERVICES PROVIDED: session open_session and close_session
modules/pam_namespace/namespace.conf +18 -4
@@ -1,7 +1,7 @@ # /etc/security/namespace.conf # # See /usr/share/doc/pam-*/txts/README.pam_namespace for more information. -# +# # Uncommenting the following three lines will polyinstantiate # /tmp, /var/tmp and user's home directories. /tmp and /var/tmp will # be polyinstantiated based on both security context as well as user
@@ -11,6 +11,20 @@ # directories will be polyinstantiated for all users. The user name # and/or context is appended to the instance prefix. # -#/tmp /tmp.inst/ both adm -#/var/tmp /var/tmp.inst/ both adm -#$HOME $HOME.inst- context +# Note that instance directories do not have to reside inside the +# polyinstantiated directory. In the examples below, instances of /tmp +# will be created in /tmp-inst directory, where as instances of /var/tmp +# and users home directories will reside within the directories that +# are being polyinstantiated. +# +# Instance parent directories must exist for the polyinstantiation +# mechanism to work. By default, they should be created with the mode +# of 000. pam_namespace module will enforce this mode unless it +# is explicitly called with an argument to ignore the mode of the +# instance parent. System administrators should use this argument with +# caution, as it will reduce security and isolation achieved by +# polyinstantiation. +# +#/tmp /tmp-inst/ both root,adm +#/var/tmp /var/tmp/tmp-inst/ both root,adm +#$HOME $HOME/$USER.inst/inst- context
modules/pam_namespace/namespace.conf.5.xml +26 -16
64 lines not on this page · raw message
modules/pam_namespace/pam_namespace.8.xml +79 -0
109 lines not on this page · raw message
modules/pam_namespace/pam_namespace.c +48 -1
74 lines not on this page · raw message