Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp350499ybb; Fri, 10 Apr 2020 01:07:16 -0700 (PDT) X-Google-Smtp-Source: APiQypJH5ecptvoRSwGRBN8iMs2xt8HXa4Sh7YpT96oD7AOUEBT06UAYTzlhk8+l7sExAH8UERRQ X-Received: by 2002:ac8:36ab:: with SMTP id a40mr3244126qtc.309.1586506036727; Fri, 10 Apr 2020 01:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586506036; cv=none; d=google.com; s=arc-20160816; b=rOrRIoyFz/hcjWk3ryJzNrteLvn77I+uI01VClXvf9Nlp6vHc7ojtoay1LumVN6XNB DK0kiDy0N1TqvzT5zE7ObbAWA4r9uOc5CFnrPx/OnC/a62v+zwOE8/iNskugfXO9gFXZ wDhech94ENLz6B72TY+N+ZioaDEtK6/05qRQUZJVJ0rSjP2uxmMc1g2xowlBsJ0F8gE6 xghVfMG4IZBvo468426EbooUcwXA6AydZ6AEY35/NZVrTcQ1S1ADWRz0luMIx0+EaFHO /Es9z1eM687OcJ5qs4e+9unRMF7JNx82c5VcHq8EiKRNnmE0hOKNB4YpkPN6C/apTh+w Dykg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=AEvdty3CUB2yvWQFWhmfRDQ68CNiaEYNP2TN2NalHRk=; b=CdhqrqE1MknjDIwKW6qohwaOHmP0kGpsMmg81WwqOiUea0nPIEWbvMAGLBmN4khZ6N aXCjByIoMsIuTUOcjfLXpJbGBDpXX4e6M+/FmIT12h+Q7YJvBvtN5nKoWDxiw1r7yaEV kc+s10LmSwsMDcXEsv0nu7gJlH7XQy+RWQvruvgkrZaq642m3rI7edQopvTewiD2ARoV 1UPOx5TFz3BugXjIqTsrJuzGyb4fFhJhkXG8PB+Xz7xsSMbaTiPfykX8g481xjENFzEm Tg5ef56g3UEwrEZv5OipPJvU1N7IcaHyDFmSWYA1XT0/YNISSkgYG/1UnF81vDNX7HDh IQXg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si746146qtn.146.2020.04.10.01.07.14; Fri, 10 Apr 2020 01:07:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725839AbgDJIHJ (ORCPT + 13 others); Fri, 10 Apr 2020 04:07:09 -0400 Received: from agnus.defensec.nl ([80.100.19.56]:60890 "EHLO agnus.defensec.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgDJIHJ (ORCPT ); Fri, 10 Apr 2020 04:07:09 -0400 Received: from brutus (brutus.lan [IPv6:2001:985:d55d::438]) by agnus.defensec.nl (Postfix) with ESMTPSA id 2BA6C2A0DAC; Fri, 10 Apr 2020 10:07:05 +0200 (CEST) From: Dominick Grift To: Russell Coker Cc: selinux-refpolicy@vger.kernel.org Subject: Re: another certbot patch References: <20200410060231.GA35896@xev> Date: Fri, 10 Apr 2020 10:07:01 +0200 In-Reply-To: <20200410060231.GA35896@xev> (Russell Coker's message of "Fri, 10 Apr 2020 16:02:31 +1000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Russell Coker writes: > 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; might want to call this: certbot_run(sysadm_r, sysadm_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) I would have used certbot_state_t here so that "lib" can be used for private library types > + > +######################################## > +# > +# 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) redundant: exec implies mmap > + > +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. > ## > ## -- gpg --locate-keys dominick.grift@defensec.nl Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098 https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098 Dominick Grift