Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp661315pxb; Thu, 14 Jan 2021 15:40:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkX41cyRBm38RLrO8qoqNHPlizzjs3t1RB5h0wUkmxXrLCR8s3bTPuKud92zcf6Eu3VVcR X-Received: by 2002:a05:6402:4d6:: with SMTP id n22mr7767496edw.27.1610667607029; Thu, 14 Jan 2021 15:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610667607; cv=none; d=google.com; s=arc-20160816; b=pOJKvlo6D+6BM4rqO+BNq244N5eYeAY8bzrCGAd3kxOcQt8WmfOchyDHICTtLQ2J80 UgChb1L0FYp+u1XrO9Cw2fOVDawUBCtANzYb51kuKuXldNDIrFFKhti6pzfVDOOSL4KZ rxIylEKvxjUjdOL3fNlQ8VC0BM1hIpeZR+PsbrZ4BecLTc0fLlOks56cjFNa42gwdgOq czhtAWbe54bCPRynEad0TyGOh7RYak4i8XeEfmizDVdBNP3GFfuqJ6f/nmedfX8AcaMx 36w+xPS0i88hV5VFWnacOF40fXDQ3hhLp/i0muqWMe4gTIjOfoPj6/5N1vJSHxBRuA4B 7nEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=umuGw1IR3zMmoZaZBuEt1hWTdSXaf7s3w8aX2YTMzzA=; b=HDBMwf1EVqS+fJ3IepKreZ6XCZ/J1/uXK8aWoyCriXWl+UQvR6hTLTlXrrhXVim5ns 92VeE1axhsrdlpUUnDh29c4BOKOeNeBwQ3mYB6rkpE4zS+QFH3EvIXYLTcFRD0GNZ6o8 JaIwLrLIKMhvrliuIsEP1oflnYm2nD3aT3ElxNz3KjBPL8Q2i2WNZFvHTwRCxbSZ0S8n HD93Q65IrlN8coEzWf5X3ooF8OVh1vlKuviusJM/v0+gOg3sBbhoicryx11XNlh62Pg4 En1jPQf6IhmE4j3kIiA7H2jiP+89s8+SnxgsnNdrVsa2mjb/0tDKTRRd2/fEMMkt3OOX frEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=LdGYpjk3; 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=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fi14si3055158ejb.677.2021.01.14.15.40.02; Thu, 14 Jan 2021 15:40:07 -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=@coker.com.au header.s=2008 header.b=LdGYpjk3; 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=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730994AbhANXjx (ORCPT + 18 others); Thu, 14 Jan 2021 18:39:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbhANXjx (ORCPT ); Thu, 14 Jan 2021 18:39:53 -0500 Received: from smtp.sws.net.au (smtp.sws.net.au [IPv6:2a01:4f8:140:71f5::dada:cafe]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9960C061575 for ; Thu, 14 Jan 2021 15:39:10 -0800 (PST) Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id 1C302EC7C for ; Fri, 15 Jan 2021 10:39:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1610667547; bh=umuGw1IR3zMmoZaZBuEt1hWTdSXaf7s3w8aX2YTMzzA=; l=6656; h=Date:From:To:Subject:From; b=LdGYpjk32Bc1wt7PquTY7Xua4vyJhokZZZ3bl90qiotUjQNZ7KWe5kV3ms70Oi0BU 0Ef0a9a4VLPlf0RhLYog24z7PXt6bpovvAe6UhVgkiI8yw6lodIA+jBXb/eOjfeffN QriYHjH9ygzyJ7QRfeoXm/8wwCq6GO2J+c5eX4dU= Received: by xev.coker.com.au (Postfix, from userid 1001) id 6092812F97B0; Fri, 15 Jan 2021 10:39:01 +1100 (AEDT) Date: Fri, 15 Jan 2021 10:39:01 +1100 From: Russell Coker To: selinux-refpolicy@vger.kernel.org Subject: [PATCH] latest iteration of certbot policy as patch Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org 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 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) ')