1 policy_module(ssh, 2.2.0)
3 ########################################
10 ## allow host key based authentication
13 gen_tunable(allow_ssh_keysign, false)
17 ## Allow ssh logins as sysadm_r:sysadm_t
20 gen_tunable(ssh_sysadm_login, false)
24 ## allow sshd to forward port connections
27 gen_tunable(sshd_forward_ports, false)
30 attribute ssh_agent_type;
33 type ssh_keygen_exec_t;
34 init_system_domain(ssh_keygen_t, ssh_keygen_exec_t)
37 corecmd_executable_file(sshd_exec_t)
39 ssh_server_template(sshd)
40 init_daemon_domain(sshd_t, sshd_exec_t)
42 type sshd_initrc_exec_t;
43 init_script_file(sshd_initrc_exec_t)
46 files_type(sshd_key_t)
50 typealias ssh_t alias { user_ssh_t staff_ssh_t sysadm_ssh_t };
51 typealias ssh_t alias { auditadm_ssh_t secadm_ssh_t };
52 application_domain(ssh_t, ssh_exec_t)
53 ubac_constrained(ssh_t)
55 type ssh_agent_exec_t;
56 corecmd_executable_file(ssh_agent_exec_t)
59 typealias ssh_agent_tmp_t alias { user_ssh_agent_tmp_t staff_ssh_agent_tmp_t sysadm_ssh_agent_tmp_t };
60 typealias ssh_agent_tmp_t alias { auditadm_ssh_agent_tmp_t secadm_ssh_agent_tmp_t };
61 files_tmp_file(ssh_agent_tmp_t)
62 ubac_constrained(ssh_agent_tmp_t)
65 type ssh_keysign_exec_t;
66 typealias ssh_keysign_t alias { user_ssh_keysign_t staff_ssh_keysign_t sysadm_ssh_keysign_t };
67 typealias ssh_keysign_t alias { auditadm_ssh_keysign_t secadm_ssh_keysign_t };
68 application_domain(ssh_keysign_t, ssh_keysign_exec_t)
69 ubac_constrained(ssh_keysign_t)
72 typealias ssh_tmpfs_t alias { user_ssh_tmpfs_t staff_ssh_tmpfs_t sysadm_ssh_tmpfs_t };
73 typealias ssh_tmpfs_t alias { auditadm_ssh_tmpfs_t secadm_ssh_tmpfs_t };
74 files_tmpfs_file(ssh_tmpfs_t)
75 ubac_constrained(ssh_tmpfs_t)
78 typealias ssh_home_t alias { home_ssh_t user_ssh_home_t user_home_ssh_t staff_home_ssh_t sysadm_home_ssh_t };
79 typealias ssh_home_t alias { auditadm_home_ssh_t secadm_home_ssh_t };
80 userdom_user_home_content(ssh_home_t)
83 init_ranged_daemon_domain(sshd_t, sshd_exec_t, s0 - mcs_systemhigh)
86 ##############################
88 # SSH client local policy
91 allow ssh_t self:capability { setuid setgid dac_override dac_read_search };
92 allow ssh_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
93 allow ssh_t self:fd use;
94 allow ssh_t self:fifo_file rw_fifo_file_perms;
95 allow ssh_t self:unix_dgram_socket { create_socket_perms sendto };
96 allow ssh_t self:unix_stream_socket { create_stream_socket_perms connectto };
97 allow ssh_t self:shm create_shm_perms;
98 allow ssh_t self:sem create_sem_perms;
99 allow ssh_t self:msgq create_msgq_perms;
100 allow ssh_t self:msg { send receive };
101 allow ssh_t self:tcp_socket create_stream_socket_perms;
102 can_exec(ssh_t, ssh_exec_t)
104 # Read the ssh key file.
105 allow ssh_t sshd_key_t:file read_file_perms;
107 manage_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t)
108 manage_lnk_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t)
109 manage_fifo_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t)
110 manage_sock_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t)
111 fs_tmpfs_filetrans(ssh_t, ssh_tmpfs_t, { dir file lnk_file sock_file fifo_file })
113 manage_dirs_pattern(ssh_t, ssh_home_t, ssh_home_t)
114 manage_sock_files_pattern(ssh_t, ssh_home_t, ssh_home_t)
115 userdom_user_home_dir_filetrans(ssh_t, ssh_home_t, { dir sock_file })
116 userdom_stream_connect(ssh_t)
118 # Allow the ssh program to communicate with ssh-agent.
119 stream_connect_pattern(ssh_t, ssh_agent_tmp_t, ssh_agent_tmp_t, ssh_agent_type)
121 allow ssh_t sshd_t:unix_stream_socket connectto;
123 # ssh client can manage the keys and config
124 manage_files_pattern(ssh_t, ssh_home_t, ssh_home_t)
125 read_lnk_files_pattern(ssh_t, ssh_home_t, ssh_home_t)
127 # ssh servers can read the user keys and config
128 manage_dirs_pattern(ssh_server, ssh_home_t, ssh_home_t)
129 manage_files_pattern(ssh_server, ssh_home_t, ssh_home_t)
130 userdom_user_home_dir_filetrans(ssh_server, ssh_home_t, dir)
131 userdom_admin_home_dir_filetrans(ssh_server, ssh_home_t, dir)
133 kernel_read_kernel_sysctls(ssh_t)
134 kernel_read_system_state(ssh_t)
136 corenet_all_recvfrom_unlabeled(ssh_t)
137 corenet_all_recvfrom_netlabel(ssh_t)
138 corenet_tcp_sendrecv_generic_if(ssh_t)
139 corenet_tcp_sendrecv_generic_node(ssh_t)
140 corenet_tcp_sendrecv_all_ports(ssh_t)
141 corenet_tcp_connect_ssh_port(ssh_t)
142 corenet_sendrecv_ssh_client_packets(ssh_t)
143 corenet_tcp_bind_generic_node(ssh_t)
144 corenet_tcp_bind_all_unreserved_ports(ssh_t)
146 dev_read_urand(ssh_t)
148 fs_getattr_all_fs(ssh_t)
149 fs_search_auto_mountpoints(ssh_t)
151 # run helper programs - needed eg for x11-ssh-askpass
152 corecmd_exec_shell(ssh_t)
153 corecmd_exec_bin(ssh_t)
155 domain_use_interactive_fds(ssh_t)
157 files_list_home(ssh_t)
158 files_read_usr_files(ssh_t)
159 files_read_etc_runtime_files(ssh_t)
160 files_read_etc_files(ssh_t)
161 files_read_var_files(ssh_t)
163 logging_send_syslog_msg(ssh_t)
164 logging_read_generic_logs(ssh_t)
166 auth_use_nsswitch(ssh_t)
168 miscfiles_read_localization(ssh_t)
169 miscfiles_read_generic_certs(ssh_t)
171 seutil_read_config(ssh_t)
173 userdom_dontaudit_list_user_home_dirs(ssh_t)
174 userdom_search_user_home_dirs(ssh_t)
175 # Write to the user domain tty.
176 userdom_use_user_terminals(ssh_t)
177 # needs to read krb/write tgt
178 userdom_read_user_tmp_files(ssh_t)
179 userdom_write_user_tmp_files(ssh_t)
180 userdom_read_user_home_content_symlinks(ssh_t)
182 tunable_policy(`allow_ssh_keysign',`
183 domtrans_pattern(ssh_t, ssh_keysign_exec_t, ssh_keysign_t)
186 tunable_policy(`use_nfs_home_dirs',`
187 fs_manage_nfs_dirs(ssh_t)
188 fs_manage_nfs_files(ssh_t)
191 tunable_policy(`use_samba_home_dirs',`
192 fs_manage_cifs_dirs(ssh_t)
193 fs_manage_cifs_files(ssh_t)
196 # for port forwarding
197 tunable_policy(`user_tcp_server',`
198 corenet_tcp_bind_ssh_port(ssh_t)
199 corenet_tcp_bind_generic_node(ssh_t)
203 xserver_user_x_domain_template(ssh, ssh_t, ssh_tmpfs_t)
204 xserver_domtrans_xauth(ssh_t)
207 ########################################
209 # ssh_keygen local policy
212 # ssh_keygen_t is the type of the ssh-keygen program when run at install time
215 dontaudit ssh_keygen_t self:capability sys_tty_config;
216 allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
217 allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
219 allow ssh_keygen_t sshd_key_t:file manage_file_perms;
220 files_etc_filetrans(ssh_keygen_t, sshd_key_t, file)
222 manage_dirs_pattern(ssh_keygen_t, ssh_home_t, ssh_home_t)
223 manage_files_pattern(ssh_keygen_t, ssh_home_t, ssh_home_t)
224 userdom_admin_home_dir_filetrans(ssh_keygen_t, ssh_home_t, dir)
226 kernel_read_kernel_sysctls(ssh_keygen_t)
228 fs_search_auto_mountpoints(ssh_keygen_t)
230 dev_read_sysfs(ssh_keygen_t)
231 dev_read_urand(ssh_keygen_t)
233 term_dontaudit_use_console(ssh_keygen_t)
235 domain_use_interactive_fds(ssh_keygen_t)
237 files_read_etc_files(ssh_keygen_t)
239 init_use_fds(ssh_keygen_t)
240 init_use_script_ptys(ssh_keygen_t)
242 logging_send_syslog_msg(ssh_keygen_t)
244 userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t)
247 nscd_socket_use(ssh_keygen_t)
251 seutil_sigchld_newrole(ssh_keygen_t)
255 udev_read_db(ssh_keygen_t)
258 ##############################
260 # ssh_keysign_t local policy
263 tunable_policy(`allow_ssh_keysign',`
264 allow ssh_keysign_t self:capability { setgid setuid };
265 allow ssh_keysign_t self:unix_stream_socket create_socket_perms;
267 allow ssh_keysign_t sshd_key_t:file read_file_perms;
269 dev_read_urand(ssh_keysign_t)
271 files_read_etc_files(ssh_keysign_t)
275 tunable_policy(`allow_ssh_keysign',`
276 nscd_socket_use(ssh_keysign_t)
280 #################################
284 # sshd_t is the domain for the sshd program.
287 # so a tunnel can point to another ssh tunnel
288 allow sshd_t self:netlink_route_socket r_netlink_socket_perms;
289 allow sshd_t self:key { search link write };
290 allow sshd_t self:process setcurrent;
292 kernel_search_key(sshd_t)
293 kernel_link_key(sshd_t)
295 term_use_all_ptys(sshd_t)
296 term_setattr_all_ptys(sshd_t)
297 term_setattr_all_ttys(sshd_t)
298 term_relabelto_all_ptys(sshd_t)
299 term_use_ptmx(sshd_t)
302 corenet_tcp_bind_xserver_port(sshd_t)
303 corenet_sendrecv_xserver_server_packets(sshd_t)
305 userdom_read_user_home_content_files(sshd_t)
306 userdom_read_user_home_content_symlinks(sshd_t)
307 userdom_search_admin_dir(sshd_t)
308 userdom_manage_tmp_role(system_r, sshd_t)
309 userdom_spec_domtrans_unpriv_users(sshd_t)
310 userdom_signal_unpriv_users(sshd_t)
312 tunable_policy(`sshd_forward_ports',`
313 corenet_tcp_bind_all_unreserved_ports(sshd_t)
314 corenet_tcp_connect_all_ports(sshd_t)
317 tunable_policy(`ssh_sysadm_login',`
318 # Relabel and access ptys created by sshd
319 # ioctl is necessary for logout() processing for utmp entry and for w to
321 # some versions of sshd on the new SE Linux require setattr
322 userdom_signal_all_users(sshd_t)
326 daemontools_service_domain(sshd_t, sshd_exec_t)
330 kerberos_keytab_template(sshd, sshd_t)
334 ftp_dyntrans_sftpd(sshd_t)
335 ftp_dyntrans_anon_sftpd(sshd_t)
339 gitosis_manage_lib_files(sshd_t)
343 inetd_tcp_service_domain(sshd_t, sshd_exec_t)
347 nx_read_home_files(sshd_t)
351 rpm_use_script_fds(sshd_t)
355 rssh_spec_domtrans(sshd_t)
356 # For reading /home/user/.ssh
357 rssh_read_ro_content(sshd_t)
361 usermanage_domtrans_passwd(sshd_t)
362 usermanage_read_crack_db(sshd_t)
366 unconfined_shell_domtrans(sshd_t)
370 xserver_domtrans_xauth(sshd_t)
374 tunable_policy(`ssh_sysadm_login',`
375 # Relabel and access ptys created by sshd
376 # ioctl is necessary for logout() processing for utmp entry and for w to
378 # some versions of sshd on the new SE Linux require setattr
379 allow sshd_t ptyfile:chr_file relabelto;
382 domain_trans(sshd_t, xauth_exec_t, userdomain)
386 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
388 # Relabel and access ptys created by sshd
389 # ioctl is necessary for logout() processing for utmp entry and for w to
391 # some versions of sshd on the new SE Linux require setattr
392 allow sshd_t userpty_type:chr_file { relabelto rw_inherited_chr_file_perms setattr_chr_file_perms };
396 ########################################
398 # ssh_keygen local policy
401 # ssh_keygen_t is the type of the ssh-keygen program when run at install time
404 dontaudit ssh_keygen_t self:capability sys_tty_config;
405 allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
406 allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
408 allow ssh_keygen_t sshd_key_t:file manage_file_perms;
409 files_etc_filetrans(ssh_keygen_t, sshd_key_t, file)
411 kernel_read_kernel_sysctls(ssh_keygen_t)
413 fs_search_auto_mountpoints(ssh_keygen_t)
415 dev_read_sysfs(ssh_keygen_t)
416 dev_read_urand(ssh_keygen_t)
418 term_dontaudit_use_console(ssh_keygen_t)
420 domain_use_interactive_fds(ssh_keygen_t)
422 files_read_etc_files(ssh_keygen_t)
424 init_use_fds(ssh_keygen_t)
425 init_use_script_ptys(ssh_keygen_t)
427 auth_use_nsswitch(ssh_keygen_t)
429 logging_send_syslog_msg(ssh_keygen_t)
431 userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t)
434 seutil_sigchld_newrole(ssh_keygen_t)
438 udev_read_db(ssh_keygen_t)