ssh policy new interfaces
v2 cover ssh policy new interfaces
New interfaces for ssh policy which can be used with git hosting software.
Alexander Miroshnichenko (2):
ssh: Add ssh_exec_keygen interface
ssh: Add interface ssh_search_dir
policy/modules/services/ssh.if | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
Signature · 1 line
2.21.0
PATCH v2 1/2 ssh: Add ssh_exec_keygen interface
--- policy/modules/services/ssh.if | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
policy/modules/services/ssh.if +19 -0
@@ -701,6 +701,25 @@ interface(`ssh_read_user_home_files',` userdom_search_user_home_dirs($1) ') +######################################## +## <summary> +## Execute the ssh key generator in the caller domain. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed to transition. +## </summary> +## </param> +# +interface(`ssh_exec_keygen',` + gen_require(` + type ssh_keygen_exec_t; + ') + + corecmd_search_bin($1) + can_exec($1, ssh_keygen_exec_t) +') + ######################################## ## <summary> ## Execute the ssh key generator in the ssh keygen domain.
Signature · 1 line
2.21.0
Re: [PATCH v2 1/2] ssh: Add ssh_exec_keygen interface
Quoted 10 lines · Alexander Miroshnichenko
Signed-off-by Alexander Miroshnichenko <[email protected]>--- policy/modules/services/ssh.if | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)policy/modules/services/ssh.if +0
-0
policy/modules/services/ssh.if interface(`ssh_read_user_home_files',` · line 710
Quoted 10 lines
policy/modules/services/ssh.if +7
-0@@ -701,6 +701,25 @@ interface(`ssh_read_user_home_files',` userdom_search_user_home_dirs($1) ') +######################################## +## <summary> +## Execute the ssh key generator in the caller domain. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed to transition.
"Domain allowed access." Its not a transition. I suppose you have a use for this interface?
Quoted 18 lines
policy/modules/services/ssh.if +12
-0+## </summary> +## </param> +# +interface(`ssh_exec_keygen',` + gen_require(` + type ssh_keygen_exec_t; + ') + + corecmd_search_bin($1) + can_exec($1, ssh_keygen_exec_t) +') + ######################################## ## <summary> ## Execute the ssh key generator in the ssh keygen domain.Signature · 1 line
2.21.0
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
PATCH v2 2/2 ssh: Add interface ssh_search_dir
In reply to Alexander MiroshnichenkoCreate interface ssh_search_dir to allow ssh_server search for keys in non-standard location.
--- policy/modules/services/ssh.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
policy/modules/services/ssh.if +18 -0
@@ -680,6 +680,24 @@ interface(`ssh_agent_exec',` can_exec($1, ssh_agent_exec_t) ') +######################################## +## <summary> +## Search for keys in non-standard location +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`ssh_search_dir',` + gen_require(` + type sshd_t; + ') + + allow sshd_t $1:dir search_dir_perms; +') + ######################################## ## <summary> ## Read ssh home directory content
Signature · 1 line
2.21.0
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
Quoted 21 lines · Alexander Miroshnichenko
Create interface
ssh_search_dirto allowssh_serversearch for keys in non-standard location.Signed-off-by Alexander Miroshnichenko <[email protected]>--- policy/modules/services/ssh.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)policy/modules/services/ssh.if +6
-0@@ -680,6 +680,24 @@ interface(`ssh_agent_exec',` can_exec($1, ssh_agent_exec_t) ') +######################################## +## <summary> +## Search for keys in non-standard location +## </summary> +## <param name="domain"> +## <summary>
policy/modules/services/ssh.if interface(`ssh_agent_exec',` · line 698
Quoted 10 lines
policy/modules/services/ssh.if +10
-0+## Domain allowed access. +## </summary> +## </param> +# +interface(`ssh_search_dir',` + gen_require(` + type sshd_t; + ') + + allow sshd_t $1:dir search_dir_perms;
This is generally not allowed. The caller should generally be the source.
Regardless of the above. Keys should be in user home directories. I wonder what specific scenario prompted you to propose this interface?
Quoted 8 lines
policy/modules/services/ssh.if +2
-0+') + ######################################## ## <summary> ## Read ssh home directory contentSignature · 1 line
2.21.0
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
Quoted 27 lines · Dominick Grift
Quoted 26 lines · Alexander Miroshnichenko
Create interface
ssh_search_dirto allowssh_serversearch for keys in non-standard location.Signed-off-by Alexander Miroshnichenko <[email protected]>--- policy/modules/services/ssh.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)policy/modules/services/ssh.if +11
-0@@ -680,6 +680,24 @@ interface(`ssh_agent_exec',` can_exec($1, ssh_agent_exec_t) ') +######################################## +## <summary> +## Search for keys in non-standard location +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`ssh_search_dir',`
Quoted 8 lines
policy/modules/services/ssh.if interface(`ssh_agent_exec',` · line 698
Quoted 5 lines
policy/modules/services/ssh.if +5
-0+ gen_require(` + type sshd_t; + ') + + allow sshd_t $1:dir search_dir_perms;This is generally not allowed. The caller should generally be the source.
Regardless of the above. Keys should be in user home directories. I wonder what specific scenario prompted you to propose this interface?
GIT hosting software like gitolite/gitosis/gitea manage users ssh keys and store them own location like /var/lib/gitolite/.ssh . /var/lib/gitolite have gitosis_var_lib_t type, /var/lib/gitolite/.ssh have gitosis_ssh_home_t type (in patched policy which I want to submit). If sshd does not have { search getattr } permissions to full path to ssh key user fail to login.
Can you propose corret way to give such permissions to multiple policies?
It is incorrect to label /var/lib/gitolite as user_home_dir_t type, IMHO.
Quoted 6 lines
Quoted 5 lines
policy/modules/services/ssh.if +2
-0+') + ######################################## ## <summary> ## Read ssh home directory content ...
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
Quoted 39 lines · Alexander Miroshnichenko
Quoted 29 lines · Dominick Grift
Quoted 28 lines · Alexander Miroshnichenko
Create interface
ssh_search_dirto allowssh_serversearch for keys in non-standard location.Signed-off-by Alexander Miroshnichenko <[email protected]>--- policy/modules/services/ssh.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)policy/modules/services/ssh.if +12
-0@@ -680,6 +680,24 @@ interface(`ssh_agent_exec',` can_exec($1, ssh_agent_exec_t) ') +######################################## +## <summary> +## Search for keys in non-standard location +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`ssh_search_dir',` + gen_require(`Quoted 8 lines
policy/modules/services/ssh.if interface(`ssh_agent_exec',` · line 698
Quoted 4 lines
policy/modules/services/ssh.if +4
-0+ type sshd_t; + ') + + allow sshd_t $1:dir search_dir_perms;This is generally not allowed. The caller should generally be the source. Regardless of the above. Keys should be in user home directories. I wonder what specific scenario prompted you to propose this interface?
Quoted 8 lines
GIT hosting software like gitolite/gitosis/gitea manage users ssh keys and store them own location like
/var/lib/gitolite/.ssh./var/lib/gitolitehavegitosis_var_lib_ttype,/var/lib/gitolite/.sshhavegitosis_ssh_home_ttype (in patched policy which I want to submit).
If sshd does not have { search getattr } permissions to full path to ssh key user fail to login.
Can you propose corret way to give such permissions to multiple policies? It is incorrect to label/var/lib/gitoliteasuser_home_dir_ttype, IMHO.
Yes this sucks. I would probably do the following instead:
1. echo "ignoredirs=/var/lib/gitolite" >> /etc/selinux/semanage.conf
2. semodule -B && restorecon -RvF /var/lib/gitolite
3. gitosis_read_lib_files(sshd_t)
Dont bother with labeling /var/lib/gitolite/.ssh differently
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
policy/modules/services/ssh.if +2
-0+') + ######################################## ## <summary> ## Read ssh home directory content ...
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
Quoted 8 lines · Dominick Grift
Quoted 1 line · Alexander Miroshnichenko
On четверг, 20 июня 2019 г. 17:50:11 MSK, Dominick Grift wrote: ...
Yes this sucks. I would probably do the following instead:
1. echo "ignoredirs=/var/lib/gitolite" >>
/etc/selinux/semanage.conf
2. semodule -B && restorecon -RvF/var/lib/gitolite
3.gitosis_read_lib_files(sshd_t)
I can't use sshd_t in another policy without require statement.
Or I need to add gitosis_read_lib_files(sshd_t) to ssh.te policy file.
All 3 steps are ugly comparing with new ssh_search_dir() interface.
Why such restrictions where caller must be the source for interface? It is not flexible.
Quoted 5 lines
Dont bother with labeling
/var/lib/gitolite/.sshdifferentlyQuoted 1 line
...
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
Quoted 10 lines · Alexander Miroshnichenko
Quoted 8 lines · Dominick Grift
Quoted 1 line · Alexander Miroshnichenko
On четверг, 20 июня 2019 г. 17:50:11 MSK, Dominick Grift wrote: ...
Yes this sucks. I would probably do the following instead:
1. echo "ignoredirs=/var/lib/gitolite" >>
/etc/selinux/semanage.conf
2. semodule -B && restorecon -RvF/var/lib/gitolite
3.gitosis_read_lib_files(sshd_t)
Quoted 5 lines
I can't use
sshd_tin another policy without require statement. Or I need to addgitosis_read_lib_files(sshd_t)to ssh.te policy file. All 3 steps are ugly comparing with newssh_search_dir()interface. Why such restrictions where caller must be the source for interface? It is not flexible.
You would need to add the gitosis_read_var_lib_files(sshd_t) to ssh.te yes.
I agree that this is ugly but the alternative is even more ugly, and I will say that this is just what I would do (you might want to wait for maintainer's advice instead of taking my advice) This is one of those scenario's that are the exception rather than the rule. All options are bad.
The "restriction" is actually an unwritten rule as I cannot find any references to it in https://github.com/SELinuxProject/refpolicy/wiki/StyleGuide so you might be able to get away with it.
Quoted 7 lines
Quoted 6 lines
Dont bother with labeling
/var/lib/gitolite/.sshdifferentlyQuoted 1 line
...
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
Re: [PATCH v2 2/2] ssh: Add interface ssh_search_dir
In reply to Dominick GriftQuoted 49 lines · Dominick Grift
Quoted 39 lines · Alexander Miroshnichenko
Quoted 29 lines · Dominick Grift
Quoted 28 lines · Alexander Miroshnichenko
Create interface
ssh_search_dirto allowssh_serversearch for keys in non-standard location.Signed-off-by Alexander Miroshnichenko <[email protected]>--- policy/modules/services/ssh.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)policy/modules/services/ssh.if +12
-0@@ -680,6 +680,24 @@ interface(`ssh_agent_exec',` can_exec($1, ssh_agent_exec_t) ') +######################################## +## <summary> +## Search for keys in non-standard location +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`ssh_search_dir',` + gen_require(`Quoted 8 lines
policy/modules/services/ssh.if interface(`ssh_agent_exec',` · line 698
Quoted 4 lines
policy/modules/services/ssh.if +4
-0+ type sshd_t; + ') + + allow sshd_t $1:dir search_dir_perms;This is generally not allowed. The caller should generally be the source. Regardless of the above. Keys should be in user home directories. I wonder what specific scenario prompted you to propose this interface?
Quoted 8 lines
GIT hosting software like gitolite/gitosis/gitea manage users ssh keys and store them own location like
/var/lib/gitolite/.ssh./var/lib/gitolitehavegitosis_var_lib_ttype,/var/lib/gitolite/.sshhavegitosis_ssh_home_ttype (in patched policy which I want to submit).
If sshd does not have { search getattr } permissions to full path to ssh key user fail to login.
Can you propose corret way to give such permissions to multiple policies? It is incorrect to label/var/lib/gitoliteasuser_home_dir_ttype, IMHO.
Quoted 7 lines
Yes this sucks. I would probably do the following instead:
1. echo "ignoredirs=/var/lib/gitolite" >>
/etc/selinux/semanage.conf
2. semodule -B && restorecon -RvF/var/lib/gitolite
3.gitosis_read_lib_files(sshd_t)Dont bother with labeling
/var/lib/gitolite/.sshdifferently
But this is just what I would do (if were ever forced to use gitolite). Others may have different opinions.
Quoted 14 lines
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
policy/modules/services/ssh.if +2
-0+') + ######################################## ## <summary> ## Read ssh home directory content ...Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift