Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1666217ybb; Thu, 9 Apr 2020 06:49:25 -0700 (PDT) X-Google-Smtp-Source: APiQypJV/LvHzV2ZtwNor6632Rj0gCerc756DeJfUI7S6O23XaNVGtDdhcFuBmZhy3/GYeKcNVHQ X-Received: by 2002:aed:2238:: with SMTP id n53mr12110821qtc.243.1586440164994; Thu, 09 Apr 2020 06:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586440164; cv=none; d=google.com; s=arc-20160816; b=Q3i6UHUtyF+wToTZGf9bRfAvOLEuR8N8ameoc03VsjZOXTAve1ZDqLDkUkpH7DRhpU SwbfWggM9aswPZnchkd/DWikpcasykecQJ1e0c/dROidaxcNPhS/VIts+poiMbK+888o /lNQlg+WmiSXu1IRoF+gmPzh4KblxWDARIPpsvoaL3/oz1sO0crZbiO3qk8Zw2ejSivx hwQ5GE4GG6uzota+paqTGn0LPZlyOvvTWpGw2pGFqqE+qV/pnIBb97F0msiTSP3MAfq8 MESGNa9ENiufNkPpczyNyIJ4KezXPFt/qGGXr+22R0PfkHCCnkcDUaxIrSFgRv9s281E 4Slw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=pWhhD9jnv5jUjoZvx4tDhUEvfjKtveFo75+1DWas0ps=; b=wc3pEZfyNCXuLdiN49YDNH5CEqa311+AeOqOzyWHpb2XBUfoX9WEfbdQ1fSqKqjVqk rlNgm46QscCSJ8as8sNSGkMjvOQKyM3PHUb08LQw0/e9Tu5sV8lkwccTFZpQ0CBw3llD 9wwE8C7BUsu/npoIZRLH134yjVi4DRcoGF67GhGQ2w4HLFoT9EwAU5knO3eqleFNsLu3 LwfU057SwTVwm2U5fg2gbkBlaC1V2A92xrb+JX0bRlNbK5MbFfvF4Rc87MZJUKwnRbQB +kyGVX69AxjooS5lZdgaId7QDhhjSBp8E+6toQqOSdXx7ul9/ivXz4J8Qx4rZ2FxAXap EYvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=OZnCI5dL; 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=NONE sp=NONE dis=NONE) header.from=ieee.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si5489586qtq.379.2020.04.09.06.49.21; Thu, 09 Apr 2020 06:49:24 -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=@ieee.org header.s=google header.b=OZnCI5dL; 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=NONE sp=NONE dis=NONE) header.from=ieee.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgDINtI (ORCPT + 13 others); Thu, 9 Apr 2020 09:49:08 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:37703 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgDINtI (ORCPT ); Thu, 9 Apr 2020 09:49:08 -0400 Received: by mail-qt1-f195.google.com with SMTP id n17so2737908qtv.4 for ; Thu, 09 Apr 2020 06:49:08 -0700 (PDT) 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=pWhhD9jnv5jUjoZvx4tDhUEvfjKtveFo75+1DWas0ps=; b=OZnCI5dLghUAwWGheQZU15qJipr1pj42e9xrqNcFWXOBvrCMSG3/VZP6HimonoqQAN HyDWMLh9yOoS9ifbXQQnkjiL0CyEIK+ojHIoRb2tjvu7gLytsiyAhU0KQIyyiwjtk+J1 GjXyJjvANvKfNHruO2pS+V8iLwlhP6zGljm8M= 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=pWhhD9jnv5jUjoZvx4tDhUEvfjKtveFo75+1DWas0ps=; b=tDAvbQbrMj6/ewCO1BFNOfN3JBQw3mzH/hXyteuK5DRITo+r06lGvOsx+a/kz/Du/r SMiV1BI9QPpe3ri4JRaigH81cSAiorEe4RbWVnnYuwH0ClhYDIvrXyihmCQRPt601Yj7 TjiZOq32+st8J5VX3waGINE0bGC+zaZmAGIJvALBr35m/Jq84j8w1Hr5wlgWUVW/QTWR JTACwiQgWxXXcUsdnbsabDHp7JKHlg7/z1v5rOrsmkiMrzTf0rlgBOZZtF5vFeC+vZKX 8KLtpUaeroHiq4raKwuoL+Kl83jaHKtgkvTdRb4f4hRIRbbWSmtrMpDNqaiYc9OSRucN XVeg== X-Gm-Message-State: AGi0PuYF13td3dygsDCWAozLG3OAhIP3hQ/+DKlDz8jF8OpSi6XwA/4p PSc1HpsAIVi1FIZc8vS20wXxXB/g9fo= X-Received: by 2002:ac8:6d3b:: with SMTP id r27mr4869129qtu.55.1586440147553; Thu, 09 Apr 2020 06:49:07 -0700 (PDT) Received: from fedora.pebenito.net (pool-108-15-23-247.bltmmd.fios.verizon.net. [108.15.23.247]) by smtp.gmail.com with ESMTPSA id i25sm21134604qtq.86.2020.04.09.06.49.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2020 06:49:07 -0700 (PDT) Subject: Re: new certbot patch To: Russell Coker , selinux-refpolicy@vger.kernel.org References: <20200405084141.GA177560@xev> From: Chris PeBenito Message-ID: <5b70567f-d551-ea5f-50e4-5febe2ad9a09@ieee.org> Date: Thu, 9 Apr 2020 09:23:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200405084141.GA177560@xev> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org On 4/5/20 4:41 AM, Russell Coker wrote: > Patch for certbot (Let's Encrypt client) against latest GIT. > > Signed-off-by: Russell Coker > > Index: refpolicy-2.20200219/policy/modules/services/certbot.fc > =================================================================== > --- /dev/null > +++ refpolicy-2.20200219/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.20200219/policy/modules/services/certbot.if > =================================================================== > --- /dev/null > +++ refpolicy-2.20200219/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.20200219/policy/modules/services/certbot.te > =================================================================== > --- /dev/null > +++ refpolicy-2.20200219/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 > +# > + Much of the below lines need ordering cleanup. > +allow certbot_t self:fifo_file { getattr ioctl read write }; > + > +allow certbot_t self:capability { chown dac_override sys_resource }; > + > +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 > +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; > + > +kernel_search_fs_sysctls(certbot_t) > + > +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; > +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) > + > +sysnet_read_config(certbot_t) > +files_read_etc_files(certbot_t) > + > +# for /usr/bin/x86_64-linux-gnu-gcc-8 why? > +corecmd_exec_bin(certbot_t) > +# for /usr/lib/gcc/x86_64-linux-gnu/8/collect2 > +libs_exec_lib_files(certbot_t) > + > +libs_exec_ldconfig(certbot_t) > + > +apache_search_config(certbot_t) Needs to go down in the optional with the other apache call. > + > +# for bin_t map > +corecmd_mmap_bin_files(certbot_t) > +corecmd_list_bin(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) Perhaps we should be moving towards having a specific label for these private keys instead. It seems logical that there would be multiple types of private keys. Then have a miscfiles_private_key() to declare one and have the type in this module to act on directly. > + > +manage_files_pattern(certbot_t, certbot_runtime_t, certbot_runtime_t) > +files_pid_filetrans(certbot_t, certbot_runtime_t, file) > + > +domain_use_interactive_fds(certbot_t) > +userdom_use_user_ptys(certbot_t) > +userdom_dontaudit_search_user_home_dirs(certbot_t) > + > +optional_policy(` > + # for writing to webroot > + apache_manage_sys_content(certbot_t) > +') > Index: refpolicy-2.20200219/policy/modules/system/miscfiles.if > =================================================================== > --- refpolicy-2.20200219.orig/policy/modules/system/miscfiles.if > +++ refpolicy-2.20200219/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. > ## > ## > -- Chris PeBenito