clamav.te 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. policy_module(clamav, 1.11.1)
  2. ## <desc>
  3. ## <p>
  4. ## Determine whether clamscan can
  5. ## read user content files.
  6. ## </p>
  7. ## </desc>
  8. gen_tunable(clamav_read_user_content_files_clamscan, false)
  9. ## <desc>
  10. ## <p>
  11. ## Determine whether clamscan can read
  12. ## all non-security files.
  13. ## </p>
  14. ## </desc>
  15. gen_tunable(clamav_read_all_non_security_files_clamscan, false)
  16. ## <desc>
  17. ## <p>
  18. ## Determine whether can clamd use JIT compiler.
  19. ## </p>
  20. ## </desc>
  21. gen_tunable(clamd_use_jit, false)
  22. ########################################
  23. #
  24. # Declarations
  25. #
  26. type clamd_t;
  27. type clamd_exec_t;
  28. init_daemon_domain(clamd_t, clamd_exec_t)
  29. type clamd_etc_t;
  30. files_config_file(clamd_etc_t)
  31. type clamd_initrc_exec_t;
  32. init_script_file(clamd_initrc_exec_t)
  33. type clamd_unit_file_t;
  34. systemd_unit_file(clamd_unit_file_t)
  35. type clamd_tmp_t;
  36. files_tmp_file(clamd_tmp_t)
  37. type clamd_var_log_t;
  38. logging_log_file(clamd_var_log_t)
  39. type clamd_var_lib_t;
  40. files_type(clamd_var_lib_t)
  41. type clamd_var_run_t;
  42. files_pid_file(clamd_var_run_t)
  43. typealias clamd_var_run_t alias clamd_sock_t;
  44. type clamscan_t;
  45. type clamscan_exec_t;
  46. init_daemon_domain(clamscan_t, clamscan_exec_t)
  47. type clamscan_tmp_t;
  48. files_tmp_file(clamscan_tmp_t)
  49. type freshclam_t;
  50. type freshclam_exec_t;
  51. init_daemon_domain(freshclam_t, freshclam_exec_t)
  52. type freshclam_var_log_t;
  53. logging_log_file(freshclam_var_log_t)
  54. ########################################
  55. #
  56. # Clamd local policy
  57. #
  58. allow clamd_t self:capability { kill setgid setuid dac_override };
  59. dontaudit clamd_t self:capability sys_tty_config;
  60. allow clamd_t self:process signal;
  61. allow clamd_t self:fifo_file rw_fifo_file_perms;
  62. allow clamd_t self:unix_stream_socket { accept connectto listen };
  63. allow clamd_t self:tcp_socket { listen accept };
  64. allow clamd_t clamd_etc_t:dir list_dir_perms;
  65. read_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
  66. read_lnk_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
  67. manage_dirs_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
  68. manage_files_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
  69. files_tmp_filetrans(clamd_t, clamd_tmp_t, { file dir })
  70. manage_dirs_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
  71. manage_files_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
  72. manage_sock_files_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
  73. manage_dirs_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
  74. append_files_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
  75. create_files_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
  76. setattr_files_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
  77. logging_log_filetrans(clamd_t, clamd_var_log_t, { dir file })
  78. manage_dirs_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
  79. manage_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
  80. manage_sock_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
  81. files_pid_filetrans(clamd_t, clamd_var_run_t, { dir file sock_file })
  82. kernel_dontaudit_list_proc(clamd_t)
  83. kernel_read_sysctl(clamd_t)
  84. kernel_read_kernel_sysctls(clamd_t)
  85. kernel_read_system_state(clamd_t)
  86. kernel_read_vm_sysctls(clamd_t)
  87. corecmd_exec_shell(clamd_t)
  88. corenet_all_recvfrom_unlabeled(clamd_t)
  89. corenet_all_recvfrom_netlabel(clamd_t)
  90. corenet_tcp_sendrecv_generic_if(clamd_t)
  91. corenet_tcp_sendrecv_generic_node(clamd_t)
  92. corenet_tcp_sendrecv_all_ports(clamd_t)
  93. corenet_tcp_bind_generic_node(clamd_t)
  94. corenet_sendrecv_generic_server_packets(clamd_t)
  95. corenet_tcp_bind_generic_port(clamd_t)
  96. corenet_sendrecv_generic_client_packets(clamd_t)
  97. corenet_tcp_connect_generic_port(clamd_t)
  98. corenet_sendrecv_clamd_server_packets(clamd_t)
  99. corenet_tcp_bind_clamd_port(clamd_t)
  100. dev_read_rand(clamd_t)
  101. dev_read_urand(clamd_t)
  102. domain_use_interactive_fds(clamd_t)
  103. files_read_etc_runtime_files(clamd_t)
  104. files_search_spool(clamd_t)
  105. auth_use_nsswitch(clamd_t)
  106. logging_send_syslog_msg(clamd_t)
  107. miscfiles_read_localization(clamd_t)
  108. tunable_policy(`clamd_use_jit',`
  109. allow clamd_t self:process execmem;
  110. ',`
  111. dontaudit clamd_t self:process execmem;
  112. ')
  113. optional_policy(`
  114. amavis_read_lib_files(clamd_t)
  115. amavis_read_spool_files(clamd_t)
  116. amavis_spool_filetrans(clamd_t, clamd_var_run_t, sock_file)
  117. amavis_create_pid_files(clamd_t)
  118. ')
  119. optional_policy(`
  120. cron_use_fds(clamd_t)
  121. cron_use_system_job_fds(clamd_t)
  122. cron_rw_pipes(clamd_t)
  123. ')
  124. optional_policy(`
  125. exim_read_spool_files(clamd_t)
  126. ')
  127. optional_policy(`
  128. mta_read_config(clamd_t)
  129. mta_send_mail(clamd_t)
  130. ')
  131. ########################################
  132. #
  133. # Freshclam local policy
  134. #
  135. allow freshclam_t self:capability { setgid setuid dac_override };
  136. allow freshclam_t self:fifo_file rw_fifo_file_perms;
  137. allow freshclam_t self:unix_stream_socket { accept listen };
  138. allow freshclam_t self:tcp_socket { accept listen };
  139. allow freshclam_t clamd_etc_t:dir list_dir_perms;
  140. read_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
  141. read_lnk_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
  142. manage_dirs_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
  143. manage_files_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
  144. manage_files_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t)
  145. files_pid_filetrans(freshclam_t, clamd_var_run_t, file)
  146. append_files_pattern(freshclam_t, freshclam_var_log_t, freshclam_var_log_t)
  147. create_files_pattern(freshclam_t, freshclam_var_log_t, freshclam_var_log_t)
  148. setattr_files_pattern(freshclam_t, freshclam_var_log_t, freshclam_var_log_t)
  149. logging_log_filetrans(freshclam_t, freshclam_var_log_t, file)
  150. stream_connect_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t, clamd_t)
  151. read_files_pattern(freshclam_t, clamd_var_log_t, clamd_var_log_t)
  152. kernel_dontaudit_list_proc(freshclam_t)
  153. kernel_read_kernel_sysctls(freshclam_t)
  154. kernel_read_network_state(freshclam_t)
  155. kernel_read_system_state(freshclam_t)
  156. corenet_all_recvfrom_unlabeled(freshclam_t)
  157. corenet_all_recvfrom_netlabel(freshclam_t)
  158. corenet_tcp_sendrecv_generic_if(freshclam_t)
  159. corenet_tcp_sendrecv_generic_node(freshclam_t)
  160. corenet_sendrecv_clamd_client_packets(freshclam_t)
  161. corenet_tcp_connect_clamd_port(freshclam_t)
  162. corenet_tcp_sendrecv_clamd_port(freshclam_t)
  163. corenet_sendrecv_http_client_packets(freshclam_t)
  164. corenet_tcp_connect_http_port(freshclam_t)
  165. corenet_tcp_sendrecv_http_port(freshclam_t)
  166. corenet_sendrecv_http_cache_client_packets(freshclam_t)
  167. corenet_tcp_connect_http_cache_port(freshclam_t)
  168. corenet_tcp_sendrecv_http_cache_port(freshclam_t)
  169. corenet_sendrecv_squid_client_packets(freshclam_t)
  170. corenet_tcp_connect_squid_port(freshclam_t)
  171. corenet_tcp_sendrecv_squid_port(freshclam_t)
  172. dev_read_rand(freshclam_t)
  173. dev_read_urand(freshclam_t)
  174. domain_use_interactive_fds(freshclam_t)
  175. files_read_etc_runtime_files(freshclam_t)
  176. files_search_var_lib(freshclam_t)
  177. auth_use_nsswitch(freshclam_t)
  178. logging_send_syslog_msg(freshclam_t)
  179. miscfiles_read_localization(freshclam_t)
  180. tunable_policy(`clamd_use_jit',`
  181. allow freshclam_t self:process execmem;
  182. ',`
  183. dontaudit freshclam_t self:process execmem;
  184. ')
  185. optional_policy(`
  186. amavis_manage_spool_files(freshclam_t)
  187. ')
  188. optional_policy(`
  189. cron_system_entry(freshclam_t, freshclam_exec_t)
  190. ')
  191. ########################################
  192. #
  193. # Clamscam local policy
  194. #
  195. allow clamscan_t self:capability { setgid setuid dac_override };
  196. allow clamscan_t self:fifo_file rw_fifo_file_perms;
  197. allow clamscan_t self:unix_stream_socket create_stream_socket_perms;
  198. allow clamscan_t self:unix_dgram_socket create_socket_perms;
  199. allow clamscan_t self:tcp_socket { accept listen };
  200. allow clamscan_t clamd_etc_t:dir list_dir_perms;
  201. read_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
  202. read_lnk_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
  203. manage_dirs_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
  204. manage_files_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
  205. files_tmp_filetrans(clamscan_t, clamscan_tmp_t, { dir file })
  206. allow clamscan_t clamd_var_lib_t:dir list_dir_perms;
  207. manage_files_pattern(clamscan_t, clamd_var_lib_t, clamd_var_lib_t)
  208. allow clamscan_t clamd_var_run_t:dir list_dir_perms;
  209. read_files_pattern(clamscan_t, clamd_var_run_t, clamd_var_run_t)
  210. stream_connect_pattern(clamscan_t, clamd_var_run_t, clamd_var_run_t, clamd_t)
  211. kernel_dontaudit_list_proc(clamscan_t)
  212. kernel_read_kernel_sysctls(clamscan_t)
  213. kernel_read_system_state(clamscan_t)
  214. corenet_all_recvfrom_unlabeled(clamscan_t)
  215. corenet_all_recvfrom_netlabel(clamscan_t)
  216. corenet_tcp_sendrecv_generic_if(clamscan_t)
  217. corenet_tcp_sendrecv_generic_node(clamscan_t)
  218. corenet_sendrecv_clamd_client_packets(clamscan_t)
  219. corenet_tcp_connect_clamd_port(clamscan_t)
  220. corenet_tcp_sendrecv_clamd_port(clamscan_t)
  221. corecmd_read_all_executables(clamscan_t)
  222. files_read_etc_files(clamscan_t)
  223. files_read_etc_runtime_files(clamscan_t)
  224. files_search_var_lib(clamscan_t)
  225. init_read_utmp(clamscan_t)
  226. init_dontaudit_write_utmp(clamscan_t)
  227. miscfiles_read_localization(clamscan_t)
  228. miscfiles_read_public_files(clamscan_t)
  229. sysnet_dns_name_resolve(clamscan_t)
  230. tunable_policy(`clamav_read_user_content_files_clamscan',`
  231. userdom_read_user_home_content_files(clamscan_t)
  232. userdom_dontaudit_read_user_home_content_files(clamscan_t)
  233. ')
  234. tunable_policy(`clamav_read_all_non_security_files_clamscan',`
  235. files_read_non_security_files(clamscan_t)
  236. files_getattr_all_pipes(clamscan_t)
  237. files_getattr_all_sockets(clamscan_t)
  238. ')
  239. optional_policy(`
  240. amavis_read_spool_files(clamscan_t)
  241. ')
  242. optional_policy(`
  243. apache_read_sys_content(clamscan_t)
  244. ')
  245. optional_policy(`
  246. mta_send_mail(clamscan_t)
  247. mta_read_queue(clamscan_t)
  248. ')