Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2948999pxb; Tue, 19 Jan 2021 09:45:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNZRfVkRygzRrvkjNq8KsoVPfLXQgPlvMnAED84JDzdkgS7YeN6G7pOk9bq5Twrktss8hI X-Received: by 2002:a17:906:3781:: with SMTP id n1mr3718511ejc.296.1611078331487; Tue, 19 Jan 2021 09:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611078331; cv=none; d=google.com; s=arc-20160816; b=a+mE78BN8FGiqSV13jjU+kk0nuKDW/SV9vFp42w+vpPJ9kmD1pls5xuXLxzsa2qTF1 VrWMYuuw8BJAmMdcQOSUmD9vbjdHsp7HDSpVGev2bhha5NE44do9Z1dIwQWyak4TaOGj hKmrQbElf3vVuje67+QoOX6eTr+m1iexVRGIZluQFmg3eRsVuhCp+biX+9uZ7fV6+Kms jg78TWKGFqju3RDfc8OnqNo8KHxBUOkEIiytvr+M1pzETTcW9caLX+N7nbBjEUZkpOWG sgc/U9gL4pQO6tIfYgqsdrr7ggma1BpuAKrFICQG/TDq0+6iIcuu6NAE7ykzAtc18YZq jX7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=3Qb80HyF4fbWk1QPF+/gNhvN/dEArkMxJn046rEHmC8=; b=knbaa1VyF/NFGniuzNNk7T1S3X4i/ZCACHTo0Zd0IRgYyBYVm1noLMh2O7i2mwfUSX SpWDWYBKVu2UOc4rCJf/XLFvqIIYeJWo1PBPnHg4n8ASV56qZLSIqgAaY83z9DY6p09b RIU1PP4lsmQpS2+jbCBF14elT4FP+uOSvdLylvmhHGN4sMRGIMiY5NYWwqW2X2+VlX2f I4axO1r6XYnnCpLio2gICeDxi8VuQFSgfOu1yOfyqi6klv3ciyjhHPT5v0iy5c/KyspF 2UXjWK75ejPzs6Dgjq9kNGRqbov5uHOe6oQGFrK+jNWERoiJZf3Vwjzdx3Vc0dwsmLYi M0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b="F/4Vz1IP"; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si5246239edn.453.2021.01.19.09.45.27; Tue, 19 Jan 2021 09:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b="F/4Vz1IP"; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389412AbhASPII (ORCPT + 18 others); Tue, 19 Jan 2021 10:08:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392097AbhASO4Z (ORCPT ); Tue, 19 Jan 2021 09:56:25 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3795EC0617A0 for ; Tue, 19 Jan 2021 06:54:42 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id v126so21998929qkd.11 for ; Tue, 19 Jan 2021 06:54:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=3Qb80HyF4fbWk1QPF+/gNhvN/dEArkMxJn046rEHmC8=; b=F/4Vz1IPoqT7yaBkDcBTmRVNv8afbtlAcA7WwJu9CoMC0uH+aAUapJ5vXeJCSs6kYK EUxYPfD0drU8NtsLSpXjJhTeAayJlCDGTDC6ScKOof7Gp78NBwJwANXd6fzy1v8uEJt/ XmlvqOytIN+h+y71zbogV0Z6E3H8HD3hlpdbI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3Qb80HyF4fbWk1QPF+/gNhvN/dEArkMxJn046rEHmC8=; b=Qoo1+0BgAY19mqweyL1aCde3jCcVE+qDb8pdzKwTQKtNrAzCjXIs4QCLer+di10db0 boGUR9yeKHMoMWnEq3AHVJY19Hy96itXeMIY9HynwgbZOMQcQQusfsgFa+NKDoomAegj xLObV6XyjQ7j33CSUpGT8t0KNfJPevpcmn90odY+uLwlFsOf2h4DnA7dpUM78wRIepd+ 0XxJzHagt/lVi3Fz8pvMqFrK4qubuq++XW5NnGIMqiy8V2x/y1qavIje1p5Ua2upQCox ZanPf9ZPErMOyjKOnsanzKWBSdGowasADG/LtO97lBt3OaSry4ZCkL/XYJHqt7zkW0wo 2aVg== X-Gm-Message-State: AOAM532GUgenmqcrNvc+9wbxdIumEcFOiUB7ZcxyXaHs/33o+AKJKSnW LDvdZEdCX7nZlXe4g9BziwftzlCS2C0K/g== X-Received: by 2002:a37:5a45:: with SMTP id o66mr4632031qkb.446.1611068081148; Tue, 19 Jan 2021 06:54:41 -0800 (PST) Received: from fedora.pebenito.net (pool-96-234-173-17.bltmmd.fios.verizon.net. [96.234.173.17]) by smtp.gmail.com with ESMTPSA id m21sm8039539qtq.52.2021.01.19.06.54.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Jan 2021 06:54:40 -0800 (PST) Subject: Re: [PATCH] latest iteration of certbot policy as patch To: Russell Coker , selinux-refpolicy@vger.kernel.org References: From: Chris PeBenito Message-ID: <5d48cdc6-6179-7d3c-2db0-9953afdfb62c@ieee.org> Date: Tue, 19 Jan 2021 09:02:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org On 1/14/21 6:39 PM, Russell Coker wrote: > Same .te as sent a few days ago, but as a patch and with the other > files needed. I think this is ready for inclusion. > > Signed-off-by: Russell Coker Merged. > Index: refpolicy-2.20210112/policy/modules/services/certbot.fc > =================================================================== > --- /dev/null > +++ refpolicy-2.20210112/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.20210112/policy/modules/services/certbot.if > =================================================================== > --- /dev/null > +++ refpolicy-2.20210112/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. > +## > +## > +## > +## Domain allowed to transition. > +## > +## > +## > +## > +## Role allowed access. > +## > +## > +# > +interface(`certbot_run',` > + gen_require(` > + type certbot_t; > + ') > + > + certbot_domtrans($1) > + role $2 types certbot_t; > +') > Index: refpolicy-2.20210112/policy/modules/services/certbot.te > =================================================================== > --- /dev/null > +++ refpolicy-2.20210112/policy/modules/services/certbot.te > @@ -0,0 +1,101 @@ > +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_runtime_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_dirs_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) > +manage_files_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) > +files_tmp_filetrans(certbot_t, certbot_tmp_t, { dir 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_runtime_filetrans(certbot_t, certbot_runtime_t, file) > + > +kernel_search_fs_sysctls(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) > +corenet_tcp_connect_dns_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) > +files_read_usr_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.20210112/policy/modules/system/miscfiles.if > =================================================================== > --- refpolicy-2.20210112.orig/policy/modules/system/miscfiles.if > +++ refpolicy-2.20210112/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. > ## > ## > Index: refpolicy-2.20210112/policy/modules/roles/sysadm.te > =================================================================== > --- refpolicy-2.20210112.orig/policy/modules/roles/sysadm.te > +++ refpolicy-2.20210112/policy/modules/roles/sysadm.te > @@ -246,6 +246,10 @@ optional_policy(` > ') > > optional_policy(` > + certbot_run(sysadm_t, sysadm_r) > +') > + > +optional_policy(` > certmaster_admin(sysadm_t, sysadm_r) > ') > > -- Chris PeBenito