2 policy_module(ipsec, 1.11.0)
4 ########################################
11 ## Allow racoon to read shadow
14 gen_tunable(racoon_read_shadow, false)
18 init_daemon_domain(ipsec_t, ipsec_exec_t)
19 role system_r types ipsec_t;
21 # type for ipsec configuration file(s) - not for keys
22 type ipsec_conf_file_t;
23 files_type(ipsec_conf_file_t)
25 type ipsec_initrc_exec_t;
26 init_script_file(ipsec_initrc_exec_t)
28 # type for file(s) containing ipsec keys - RSA or preshared
29 type ipsec_key_file_t;
30 files_type(ipsec_key_file_t)
33 logging_log_file(ipsec_log_t)
35 # Default type for IPSEC SPD entries
39 files_tmp_file(ipsec_tmp_t)
41 # type for runtime files, including pluto.ctl
43 files_pid_file(ipsec_var_run_t)
46 type ipsec_mgmt_exec_t;
47 init_system_domain(ipsec_mgmt_t, ipsec_mgmt_exec_t)
48 corecmd_shell_entry_type(ipsec_mgmt_t)
49 role system_r types ipsec_mgmt_t;
51 type ipsec_mgmt_lock_t;
52 files_lock_file(ipsec_mgmt_lock_t)
54 type ipsec_mgmt_var_run_t;
55 files_pid_file(ipsec_mgmt_var_run_t)
59 init_daemon_domain(racoon_t, racoon_exec_t)
60 role system_r types racoon_t;
63 files_tmp_file(racoon_tmp_t)
67 init_system_domain(setkey_t, setkey_exec_t)
68 role system_r types setkey_t;
70 ########################################
75 allow ipsec_t self:capability { net_admin dac_override dac_read_search setpcap sys_nice };
76 dontaudit ipsec_t self:capability sys_tty_config;
77 allow ipsec_t self:process { getcap setcap getsched signal setsched };
78 allow ipsec_t self:tcp_socket create_stream_socket_perms;
79 allow ipsec_t self:udp_socket create_socket_perms;
80 allow ipsec_t self:key_socket create_socket_perms;
81 allow ipsec_t self:fifo_file read_fifo_file_perms;
82 allow ipsec_t self:netlink_xfrm_socket { create_netlink_socket_perms nlmsg_write };
84 allow ipsec_t ipsec_initrc_exec_t:file read_file_perms;
86 allow ipsec_t ipsec_conf_file_t:dir list_dir_perms;
87 read_files_pattern(ipsec_t, ipsec_conf_file_t, ipsec_conf_file_t)
88 read_lnk_files_pattern(ipsec_t, ipsec_conf_file_t, ipsec_conf_file_t)
90 allow ipsec_t ipsec_key_file_t:dir list_dir_perms;
91 manage_files_pattern(ipsec_t, ipsec_key_file_t, ipsec_key_file_t)
92 read_lnk_files_pattern(ipsec_t, ipsec_key_file_t, ipsec_key_file_t)
94 manage_dirs_pattern(ipsec_t, ipsec_tmp_t, ipsec_tmp_t)
95 manage_files_pattern(ipsec_t, ipsec_tmp_t, ipsec_tmp_t)
96 files_tmp_filetrans(ipsec_t, ipsec_tmp_t, { dir file })
98 manage_files_pattern(ipsec_t, ipsec_var_run_t, ipsec_var_run_t)
99 manage_sock_files_pattern(ipsec_t, ipsec_var_run_t, ipsec_var_run_t)
100 files_pid_filetrans(ipsec_t, ipsec_var_run_t, { file sock_file })
102 can_exec(ipsec_t, ipsec_mgmt_exec_t)
104 # pluto runs an updown script (by calling popen()!) as this is by default
105 # a shell script, we need to find a way to make things work without
106 # letting all sorts of stuff possibly be run...
107 # so try flipping back into the ipsec_mgmt_t domain
108 corecmd_shell_domtrans(ipsec_t, ipsec_mgmt_t)
109 allow ipsec_mgmt_t ipsec_t:fd use;
110 allow ipsec_mgmt_t ipsec_t:fifo_file rw_fifo_file_perms;
111 dontaudit ipsec_mgmt_t ipsec_t:unix_stream_socket { read write };
112 allow ipsec_mgmt_t ipsec_t:process sigchld;
114 kernel_read_kernel_sysctls(ipsec_t)
115 kernel_list_proc(ipsec_t)
116 kernel_read_proc_symlinks(ipsec_t)
117 # allow pluto to access /proc/net/ipsec_eroute;
118 kernel_read_system_state(ipsec_t)
119 kernel_read_network_state(ipsec_t)
120 kernel_read_software_raid_state(ipsec_t)
121 kernel_request_load_module(ipsec_t)
122 kernel_getattr_core_if(ipsec_t)
123 kernel_getattr_message_if(ipsec_t)
125 corecmd_exec_shell(ipsec_t)
126 corecmd_exec_bin(ipsec_t)
128 # Pluto needs network access
129 corenet_all_recvfrom_unlabeled(ipsec_t)
130 corenet_tcp_sendrecv_all_if(ipsec_t)
131 corenet_raw_sendrecv_all_if(ipsec_t)
132 corenet_tcp_sendrecv_all_nodes(ipsec_t)
133 corenet_raw_sendrecv_all_nodes(ipsec_t)
134 corenet_tcp_sendrecv_all_ports(ipsec_t)
135 corenet_tcp_bind_all_nodes(ipsec_t)
136 corenet_udp_bind_all_nodes(ipsec_t)
137 corenet_tcp_bind_reserved_port(ipsec_t)
138 corenet_tcp_bind_isakmp_port(ipsec_t)
139 corenet_udp_bind_isakmp_port(ipsec_t)
140 corenet_udp_bind_ipsecnat_port(ipsec_t)
141 corenet_sendrecv_generic_server_packets(ipsec_t)
142 corenet_sendrecv_isakmp_server_packets(ipsec_t)
144 dev_read_sysfs(ipsec_t)
145 dev_read_rand(ipsec_t)
146 dev_read_urand(ipsec_t)
148 domain_use_interactive_fds(ipsec_t)
150 files_list_tmp(ipsec_t)
151 files_read_etc_files(ipsec_t)
152 files_read_usr_files(ipsec_t)
154 fs_getattr_all_fs(ipsec_t)
155 fs_search_auto_mountpoints(ipsec_t)
157 term_use_console(ipsec_t)
158 term_dontaudit_use_all_ttys(ipsec_t)
160 auth_use_nsswitch(ipsec_t)
162 init_use_fds(ipsec_t)
163 init_use_script_ptys(ipsec_t)
165 logging_send_syslog_msg(ipsec_t)
167 miscfiles_read_localization(ipsec_t)
169 sysnet_domtrans_ifconfig(ipsec_t)
171 userdom_dontaudit_use_unpriv_user_fds(ipsec_t)
172 userdom_dontaudit_search_user_home_dirs(ipsec_t)
175 seutil_sigchld_newrole(ipsec_t)
179 udev_read_db(ipsec_t)
182 ########################################
184 # ipsec_mgmt Local policy
187 allow ipsec_mgmt_t self:capability { dac_override dac_read_search net_admin setpcap sys_nice };
188 dontaudit ipsec_mgmt_t self:capability sys_tty_config;
189 allow ipsec_mgmt_t self:process { getsched ptrace setrlimit signal };
190 allow ipsec_mgmt_t self:unix_stream_socket create_stream_socket_perms;
191 allow ipsec_mgmt_t self:tcp_socket create_stream_socket_perms;
192 allow ipsec_mgmt_t self:udp_socket create_socket_perms;
193 allow ipsec_mgmt_t self:key_socket create_socket_perms;
194 allow ipsec_mgmt_t self:fifo_file rw_fifo_file_perms;
196 allow ipsec_mgmt_t ipsec_mgmt_lock_t:file manage_file_perms;
197 files_lock_filetrans(ipsec_mgmt_t, ipsec_mgmt_lock_t, file)
199 manage_dirs_pattern(ipsec_mgmt_t, ipsec_tmp_t, ipsec_tmp_t)
200 manage_files_pattern(ipsec_mgmt_t, ipsec_tmp_t, ipsec_tmp_t)
201 files_tmp_filetrans(ipsec_mgmt_t, ipsec_tmp_t, { dir file })
203 manage_files_pattern(ipsec_mgmt_t, ipsec_log_t, ipsec_log_t)
204 logging_log_filetrans(ipsec_mgmt_t, ipsec_log_t, file)
206 allow ipsec_mgmt_t ipsec_mgmt_var_run_t:file manage_file_perms;
207 files_pid_filetrans(ipsec_mgmt_t, ipsec_mgmt_var_run_t, file)
209 manage_files_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t)
210 manage_lnk_files_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t)
212 allow ipsec_mgmt_t ipsec_var_run_t:sock_file manage_sock_file_perms;
213 files_pid_filetrans(ipsec_mgmt_t, ipsec_var_run_t, sock_file)
215 # _realsetup needs to be able to cat /var/run/pluto.pid,
216 # run ps on that pid, and delete the file
217 read_files_pattern(ipsec_mgmt_t, ipsec_t, ipsec_t)
218 read_lnk_files_pattern(ipsec_mgmt_t, ipsec_t, ipsec_t)
220 # logger, running in ipsec_mgmt_t needs to use sockets
221 allow ipsec_mgmt_t self:unix_dgram_socket { create connect write };
222 allow ipsec_mgmt_t ipsec_t:unix_dgram_socket { create connect write };
224 allow ipsec_mgmt_t ipsec_conf_file_t:file read_file_perms;
226 manage_files_pattern(ipsec_mgmt_t, ipsec_key_file_t, ipsec_key_file_t)
227 manage_lnk_files_pattern(ipsec_mgmt_t, ipsec_key_file_t, ipsec_key_file_t)
228 files_etc_filetrans(ipsec_mgmt_t, ipsec_key_file_t, file)
230 # whack needs to connect to pluto
231 stream_connect_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t, ipsec_t)
233 can_exec(ipsec_mgmt_t, ipsec_mgmt_exec_t)
234 allow ipsec_mgmt_t ipsec_mgmt_exec_t:lnk_file read;
236 domtrans_pattern(ipsec_mgmt_t, ipsec_exec_t, ipsec_t)
238 kernel_rw_net_sysctls(ipsec_mgmt_t)
239 # allow pluto to access /proc/net/ipsec_eroute;
240 kernel_read_system_state(ipsec_mgmt_t)
241 kernel_read_network_state(ipsec_mgmt_t)
242 kernel_read_software_raid_state(ipsec_mgmt_t)
243 kernel_read_kernel_sysctls(ipsec_mgmt_t)
244 kernel_getattr_core_if(ipsec_mgmt_t)
245 kernel_getattr_message_if(ipsec_mgmt_t)
247 files_read_kernel_symbol_table(ipsec_mgmt_t)
248 files_getattr_kernel_modules(ipsec_mgmt_t)
250 # the default updown script wants to run route
251 # the ipsec wrapper wants to run /usr/bin/logger (should we put
252 # it in its own domain?)
253 corecmd_exec_bin(ipsec_mgmt_t)
254 corecmd_exec_shell(ipsec_mgmt_t)
256 dev_read_rand(ipsec_mgmt_t)
257 dev_read_urand(ipsec_mgmt_t)
259 domain_use_interactive_fds(ipsec_mgmt_t)
260 # denials when ps tries to search /proc. Do not audit these denials.
261 domain_dontaudit_list_all_domains_state(ipsec_mgmt_t)
262 # suppress audit messages about unnecessary socket access
263 # cjp: this seems excessive
264 domain_dontaudit_rw_all_udp_sockets(ipsec_mgmt_t)
265 domain_dontaudit_rw_all_key_sockets(ipsec_mgmt_t)
267 files_read_etc_files(ipsec_mgmt_t)
268 files_exec_etc_files(ipsec_mgmt_t)
269 files_read_etc_runtime_files(ipsec_mgmt_t)
270 files_read_usr_files(ipsec_mgmt_t)
271 files_dontaudit_getattr_default_dirs(ipsec_mgmt_t)
272 files_dontaudit_getattr_default_files(ipsec_mgmt_t)
273 files_list_tmp(ipsec_mgmt_t)
275 fs_getattr_xattr_fs(ipsec_mgmt_t)
276 fs_list_tmpfs(ipsec_mgmt_t)
278 term_use_console(ipsec_mgmt_t)
279 term_dontaudit_getattr_unallocated_ttys(ipsec_mgmt_t)
281 init_use_script_ptys(ipsec_mgmt_t)
282 init_exec_script_files(ipsec_mgmt_t)
283 init_use_fds(ipsec_mgmt_t)
284 init_labeled_script_domtrans(ipsec_mgmt_t, ipsec_initrc_exec_t)
286 logging_send_syslog_msg(ipsec_mgmt_t)
288 miscfiles_read_localization(ipsec_mgmt_t)
290 modutils_domtrans_insmod(ipsec_mgmt_t)
292 seutil_dontaudit_search_config(ipsec_mgmt_t)
294 sysnet_domtrans_ifconfig(ipsec_mgmt_t)
296 userdom_use_user_terminals(ipsec_mgmt_t)
299 consoletype_exec(ipsec_mgmt_t)
303 nscd_socket_use(ipsec_mgmt_t)
307 # ideally it would not need this. It wants to write to /root/.rnd
308 file_type_auto_trans(ipsec_mgmt_t, sysadm_home_dir_t, sysadm_home_t, file)
310 allow ipsec_mgmt_t dev_fs:file_class_set getattr;
313 ########################################
315 # Racoon local policy
318 allow racoon_t self:capability { net_admin net_bind_service };
319 allow racoon_t self:netlink_route_socket create_netlink_socket_perms;
320 allow racoon_t self:unix_dgram_socket { connect create ioctl write };
321 allow racoon_t self:netlink_selinux_socket { bind create read };
322 allow racoon_t self:udp_socket create_socket_perms;
323 allow racoon_t self:key_socket create_socket_perms;
324 allow racoon_t self:fifo_file rw_fifo_file_perms;
326 manage_dirs_pattern(racoon_t, racoon_tmp_t, racoon_tmp_t)
327 manage_files_pattern(racoon_t, racoon_tmp_t, racoon_tmp_t)
328 files_tmp_filetrans(racoon_t, racoon_tmp_t, { dir file })
330 can_exec(racoon_t, racoon_exec_t)
332 can_exec(racoon_t, setkey_exec_t)
335 manage_files_pattern(racoon_t, ipsec_var_run_t, ipsec_var_run_t)
336 manage_sock_files_pattern(racoon_t, ipsec_var_run_t, ipsec_var_run_t)
337 files_pid_filetrans(racoon_t, ipsec_var_run_t, file)
339 allow racoon_t ipsec_conf_file_t:dir list_dir_perms;
340 read_files_pattern(racoon_t, ipsec_conf_file_t, ipsec_conf_file_t)
341 read_lnk_files_pattern(racoon_t, ipsec_conf_file_t, ipsec_conf_file_t)
343 allow racoon_t ipsec_key_file_t:dir list_dir_perms;
344 read_files_pattern(racoon_t, ipsec_key_file_t, ipsec_key_file_t)
345 read_lnk_files_pattern(racoon_t, ipsec_key_file_t, ipsec_key_file_t)
347 kernel_read_system_state(racoon_t)
348 kernel_read_network_state(racoon_t)
349 kernel_request_load_module(racoon_t)
351 corecmd_exec_shell(racoon_t)
352 corecmd_exec_bin(racoon_t)
354 corenet_all_recvfrom_unlabeled(racoon_t)
355 corenet_tcp_sendrecv_all_if(racoon_t)
356 corenet_udp_sendrecv_all_if(racoon_t)
357 corenet_tcp_sendrecv_all_nodes(racoon_t)
358 corenet_udp_sendrecv_all_nodes(racoon_t)
359 corenet_tcp_bind_all_nodes(racoon_t)
360 corenet_udp_bind_all_nodes(racoon_t)
361 corenet_udp_bind_isakmp_port(racoon_t)
362 corenet_udp_bind_ipsecnat_port(racoon_t)
364 dev_read_urand(racoon_t)
366 # allow racoon to set contexts on ipsec policy and SAs
367 domain_ipsec_setcontext_all_domains(racoon_t)
369 files_read_etc_files(racoon_t)
371 fs_dontaudit_getattr_xattr_fs(racoon_t)
373 # allow racoon to use avc_has_perm to check context on proposed SA
374 selinux_compute_access_vector(racoon_t)
376 auth_use_nsswitch(racoon_t)
378 ipsec_setcontext_default_spd(racoon_t)
380 locallogin_use_fds(racoon_t)
382 logging_send_syslog_msg(racoon_t)
383 logging_send_audit_msgs(racoon_t)
385 miscfiles_read_localization(racoon_t)
387 sysnet_exec_ifconfig(racoon_t)
389 auth_can_read_shadow_passwords(racoon_t)
390 tunable_policy(`racoon_read_shadow',`
391 auth_tunable_read_shadow(racoon_t)
394 ########################################
396 # Setkey local policy
399 allow setkey_t self:capability net_admin;
400 allow setkey_t self:key_socket create_socket_perms;
401 allow setkey_t self:netlink_route_socket create_netlink_socket_perms;
403 allow setkey_t ipsec_conf_file_t:dir list_dir_perms;
404 read_files_pattern(setkey_t, ipsec_conf_file_t, ipsec_conf_file_t)
405 read_lnk_files_pattern(setkey_t, ipsec_conf_file_t, ipsec_conf_file_t)
407 kernel_request_load_module(setkey_t)
409 # allow setkey utility to set contexts on SA's and policy
410 domain_ipsec_setcontext_all_domains(setkey_t)
412 files_read_etc_files(setkey_t)
414 init_dontaudit_use_fds(setkey_t)
416 # allow setkey to set the context for ipsec SAs and policy.
417 ipsec_setcontext_default_spd(setkey_t)
419 locallogin_use_fds(setkey_t)
421 miscfiles_read_localization(setkey_t)
423 seutil_read_config(setkey_t)
425 userdom_use_user_terminals(setkey_t)