Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp272273ybb; Thu, 9 Apr 2020 23:02:42 -0700 (PDT) X-Google-Smtp-Source: APiQypIyp641hvlzAKU1kpTAWzvtIxppxdjJHeYyruDl9r9b7Y4jjWAD9HnqTR196qw8Vd1YH723 X-Received: by 2002:a0c:b893:: with SMTP id y19mr3741879qvf.223.1586498561964; Thu, 09 Apr 2020 23:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586498561; cv=none; d=google.com; s=arc-20160816; b=GTisIWjbEDZ8czR0ByDgVtDYq3h1KKSTuj8826IQtHBX+XZzPs/8eQ74B7m6FnpTgF HZ5BVxbh5E53Jkq4X5NduHNKw8KIPq69aedTbYbyx7Y8n+jTJra7nk2N0WJ0Osgy99zm 8MfSfkiyV50/1dRmswvp6rK2Rkv+5XFEjQAf27SspAlqQKnt2HUmjapZoLwTXypS82FN Qq4R5ALVrjEKDB3aWQ0+HapJou0GkydGI0wRsxkfVVAt+iBi3XDVSR2/017BUBqXu439 4r1gNbo8b+KSPgZx6np1RpJMcxchZ1RFBnh2P6pAFQjrN7M/ubJRjJkaxeVdD/dgp18L xl+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:to:from:date:dkim-signature; bh=XvoKvfAo8EcyMhYQVBaRDMzUGqEq2cGujNzwtTd0KnE=; b=QpVZggqJssVnc1p6wcf0vmd1eh+66NVj/8Bqd66iCfhHPX8D66qR2DIMdLtcFFT+DM FDkDQ0jFqHl1wG4LfKphtuy819P+ju/7/FSit9GFUBi4npnYfb258WsGtLqqnyOBP3oV bidMBysGy5OiGb36IzFsWIVCm++VqxxXEelh4cU0OeEb1BqTk3nXFjWgN1N5iji8suxY OK+Z0kjpa00hnMfD/BE3c29xI6XDbMUkXZoC9R+Nc3rMhDEUbvaugnWkuz4IVzn7RuGv vjhF1Wg0dUEyi3ZtHwd+b/CjYK7uFTTMB8L63SCTgZPBQo/bFHf48aSIVv6CeO0QwjPv KInA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=Zfny2gLo; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f137si823869qke.171.2020.04.09.23.02.39; Thu, 09 Apr 2020 23:02:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=Zfny2gLo; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725818AbgDJGCi (ORCPT + 13 others); Fri, 10 Apr 2020 02:02:38 -0400 Received: from smtp.sws.net.au ([46.4.88.250]:32824 "EHLO smtp.sws.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgDJGCi (ORCPT ); Fri, 10 Apr 2020 02:02:38 -0400 Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id 11EB3F6D3 for ; Fri, 10 Apr 2020 16:02:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1586498556; bh=XvoKvfAo8EcyMhYQVBaRDMzUGqEq2cGujNzwtTd0KnE=; l=6047; h=Date:From:To:Subject:From; b=Zfny2gLo39Bo+6f5WjfN/rbm13e+vPjubSMmIBaS9e6VyFaZ7HJl3tCK2WaYY+ijO u4KDjwde0x1opbC9gjUwl9lR9di8SY+PS9r/twj8D9+buwgiZxA3TTBi2PlDxgYOa9 h+OniCoq0a+Swa90QCqthkKwzl0AsFDcWycABLo8= Received: by xev.coker.com.au (Postfix, from userid 1001) id 52054FFC39E; Fri, 10 Apr 2020 16:02:31 +1000 (AEST) Date: Fri, 10 Apr 2020 16:02:31 +1000 From: Russell Coker To: selinux-refpolicy@vger.kernel.org Subject: another certbot patch Message-ID: <20200410060231.GA35896@xev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Signed-off-by: Russell Coker I think this addresses all the issues Chris raised. Index: refpolicy-2.20200410/policy/modules/services/certbot.fc =================================================================== --- /dev/null +++ refpolicy-2.20200410/policy/modules/services/certbot.fc @@ -0,0 +1,4 @@ +/usr/bin/certbot -- gen_context(system_u:object_r:certbot_exec_t,s0) +/usr/bin/letsencrypt -- gen_context(system_u:object_r:certbot_exec_t,s0) +/var/log/letsencrypt(/.*)? gen_context(system_u:object_r:certbot_log_t,s0) +/var/lib/letsencrypt(/.*)? gen_context(system_u:object_r:certbot_lib_t,s0) Index: refpolicy-2.20200410/policy/modules/services/certbot.if =================================================================== --- /dev/null +++ refpolicy-2.20200410/policy/modules/services/certbot.if @@ -0,0 +1,46 @@ +## SSL certificate requesting tool certbot AKA letsencrypt. + +######################################## +## +## Execute certbot/letsencrypt in the certbot +## domain. +## +## +## +## Domain allowed to transition. +## +## +# +interface(`certbot_domtrans',` + gen_require(` + type certbot_t, certbot_exec_t; + ') + + domtrans_pattern($1, certbot_exec_t, certbot_t) +') + +######################################## +## +## Execute certbot/letsencrypt in the certbot +## domain, and allow the specified role +## the firstboot domain. +## +## +## +## Role allowed access. +## +## +## +## +## Domain allowed to transition. +## +## +# +interface(`certbot_run',` + gen_require(` + type certbot_t; + ') + + certbot_domtrans($2) + role $1 types certbot_t; +') Index: refpolicy-2.20200410/policy/modules/services/certbot.te =================================================================== --- /dev/null +++ refpolicy-2.20200410/policy/modules/services/certbot.te @@ -0,0 +1,99 @@ +policy_module(certbot, 1.0.0) + +######################################## +# +# Declarations +# + +type certbot_t; +type certbot_exec_t; +init_daemon_domain(certbot_t, certbot_exec_t) + +type certbot_log_t; +logging_log_file(certbot_log_t) + +type certbot_runtime_t alias certbot_var_run_t; +files_pid_file(certbot_runtime_t) + +type certbot_tmp_t; +files_tmp_file(certbot_tmp_t) + +type certbot_tmpfs_t; +files_tmpfs_file(certbot_tmpfs_t) + +type certbot_lib_t alias certbot_var_lib_t; +files_type(certbot_lib_t) + +######################################## +# +# Local policy +# + +allow certbot_t self:fifo_file { getattr ioctl read write }; +allow certbot_t self:capability { chown dac_override sys_resource }; +allow certbot_t self:udp_socket all_udp_socket_perms; +allow certbot_t self:tcp_socket all_tcp_socket_perms; +allow certbot_t self:netlink_route_socket create_netlink_socket_perms; + +files_search_var_lib(certbot_t) +manage_dirs_pattern(certbot_t, certbot_lib_t, certbot_lib_t) +manage_files_pattern(certbot_t, certbot_lib_t, certbot_lib_t) + +manage_files_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) +files_tmp_filetrans(certbot_t, certbot_tmp_t, { file }) + +manage_files_pattern(certbot_t, certbot_tmpfs_t, certbot_tmpfs_t) +fs_tmpfs_filetrans(certbot_t, certbot_tmpfs_t, { file }) + +# this is for certbot to have write-exec memory, I know it is bad +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913544 +# the Debian bug report has background about python-acme and python3-openssl +allow certbot_t self:process execmem; +allow certbot_t certbot_tmp_t:file { map execute }; +allow certbot_t certbot_tmpfs_t:file { map execute }; +allow certbot_t certbot_runtime_t:file { map execute }; + +logging_search_logs(certbot_t) +allow certbot_t certbot_log_t:dir manage_dir_perms; +allow certbot_t certbot_log_t:file manage_file_perms; + +manage_files_pattern(certbot_t, certbot_runtime_t, certbot_runtime_t) +files_pid_filetrans(certbot_t, certbot_runtime_t, file) + +kernel_search_fs_sysctls(certbot_t) + +corecmd_exec_bin(certbot_t) +corecmd_list_bin(certbot_t) +corecmd_mmap_bin_files(certbot_t) + +corenet_tcp_bind_generic_node(certbot_t) +corenet_tcp_connect_http_port(certbot_t) + +# bind to http port for standalone mode +corenet_tcp_bind_http_port(certbot_t) + +domain_use_interactive_fds(certbot_t) +files_read_etc_files(certbot_t) + +libs_exec_ldconfig(certbot_t) +# for /usr/lib/gcc/x86_64-linux-gnu/8/collect2 +libs_exec_lib_files(certbot_t) + +miscfiles_read_localization(certbot_t) + +miscfiles_read_generic_certs(certbot_t) +miscfiles_manage_generic_tls_privkey_dirs(certbot_t) +miscfiles_manage_generic_tls_privkey_files(certbot_t) +miscfiles_manage_generic_tls_privkey_lnk_files(certbot_t) + +sysnet_read_config(certbot_t) + +userdom_dontaudit_search_user_home_dirs(certbot_t) +userdom_use_user_ptys(certbot_t) + +optional_policy(` + # for writing to webroot + apache_manage_sys_content(certbot_t) + + apache_search_config(certbot_t) +') Index: refpolicy-2.20200410/policy/modules/system/miscfiles.if =================================================================== --- refpolicy-2.20200410.orig/policy/modules/system/miscfiles.if +++ refpolicy-2.20200410/policy/modules/system/miscfiles.if @@ -254,6 +254,26 @@ interface(`miscfiles_manage_generic_tls_ ######################################## ## +## Manage generic SSL/TLS private +## keys. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`miscfiles_manage_generic_tls_privkey_lnk_files',` + gen_require(` + type tls_privkey_t; + ') + + manage_lnk_files_pattern($1, tls_privkey_t, tls_privkey_t) +') + +######################################## +## ## Read fonts. ## ##