Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F4EC43387 for ; Sun, 6 Jan 2019 19:27:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0F9720859 for ; Sun, 6 Jan 2019 19:27:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sxCg34Gj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbfAFT16 (ORCPT ); Sun, 6 Jan 2019 14:27:58 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37112 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbfAFT16 (ORCPT ); Sun, 6 Jan 2019 14:27:58 -0500 Received: by mail-ed1-f65.google.com with SMTP id h15so36045080edb.4 for ; Sun, 06 Jan 2019 11:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=tZTqTB4gna6ze4cvX8bgzY1ZmjmEqcaqut0D4KR1d/k=; b=sxCg34GjoFfj/UR6JidNftm4Yqgdlc6nlVOL2QFfgFlLlvOIoTZC9lY2shdIZlMlbP KSlEn38nvqZV4REKizByxY0edtjwmjyrkB8osdGhNCyzFlpnK73JLlbhK82sJxkWPTW/ qy19x3Y6kuFLaD+KLcliSqxOqtczc2/TkwvjUn4VC2W1sdoa/xjG/ph143G7Pdm4PFKH CxXY5Y4P2cIjWcBxKy2wLo8zm6zNt5vgU2Fq6GKtENz1EzAsUfyKURPl1hZhthtl3tFU r3NqPwQ2zgYsIYBW7DMjzuO7jkC6jWDIHuOO3MPwdk465uz7xD+NJaFhmY9fBLJtSX0s p87Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=tZTqTB4gna6ze4cvX8bgzY1ZmjmEqcaqut0D4KR1d/k=; b=m6YWxovb9DL8nizDPzxXiJcdxNbvarcT9rpgiOVmUzknB4RayyZUqs5QLk40kYKtjO nA+wt453LNw/7BHaf0GAwxSfPbgBD5CuQyZ7Ln0kQjLueMqRXgxjt1T2Lhiaod8vaJKH KBWdluGHIAEMJkai7HKSg+nEc4K5cvj4H2+v6P+ytto5sEWreNAYdvtfqHRUNyk2eVCa QV/9mwxV5xodkJNLJkfF0vgqAcZU83TneGJfb6lxLz7isYvIdpUi3pAiEQh11VgPAmAI 7DQAKsMztcN6HKcSnmwv32AYuPFdS2CUoLb7dyE5064L9i7QKchI73k3Pl5ujFYyR7CO 1cug== X-Gm-Message-State: AA+aEWYSKWH7zA7lxwcRsk0MGqq25sfmRPK8+qafsUZvLq+yzeu/kNOf RcHZ2rdL6etKIsfNGE8Sgw8SbhZ9yJE= X-Google-Smtp-Source: AFSGD/XtB4yF27LPHdLciU7NKxeiEqYO8NzGm7hNYhXwXTMl9cXv5hujY6xqgLIGPJbrTp0/WU3Oig== X-Received: by 2002:a50:f5af:: with SMTP id u44mr55093235edm.172.1546802876076; Sun, 06 Jan 2019 11:27:56 -0800 (PST) Received: from brutus ([2001:985:d55d::438]) by smtp.gmail.com with ESMTPSA id v11sm25164643edy.49.2019.01.06.11.27.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 06 Jan 2019 11:27:55 -0800 (PST) From: Dominick Grift To: Chris PeBenito Cc: Nicolas Iooss , selinux-refpolicy@vger.kernel.org Subject: Re: nss-systemd D-Bus call caused by getpwent References: <87lg3y8ckd.fsf@gmail.com> Date: Sun, 06 Jan 2019 20:27:54 +0100 In-Reply-To: (Chris PeBenito's message of "Sun, 6 Jan 2019 13:56:19 -0500") Message-ID: <87zhsd7fid.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (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 Chris PeBenito writes: > On 1/6/19 2:33 AM, Dominick Grift wrote: >> Nicolas Iooss writes: >> >>> Hi, >>> While testing the current master branch of refpolicy on Arch Linux, I >>> encountered the following denial: >>> >>> type=USER_AVC msg=audit(1546729287.319:440): pid=312 uid=81 >>> auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t >>> msg='avc: denied { send_msg } for msgtype=method_call >>> interface=org.freedesktop.systemd1.Manager member=GetDynamicUsers >>> dest=org.freedesktop.systemd1 spid=14828 tpid=1 >>> scontext=system_u:system_r:sshd_t tcontext=system_u:system_r:init_t >>> tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon" sauid=81 >>> hostname=? addr=? terminal=?' >>> >>> My OpenSSH server is calling GetDynamicUsers() exposed by systemd over >>> D-Bus. This call comes from systemd's NSSwitch module and occurs when >>> OpenSSH calls setpwent() to get information about a user >>> (https://github.com/systemd/systemd/blob/v240/src/nss-systemd/nss-systemd.c#L676). >>> How should this be handled by refpolicy? For example, would adding a >>> call to init_dbus_chat(nsswitch_domain) in a ifdef(`init_systemd') >>> block be acceptable? This would allow any callers of >>> auth_use_nsswitch() to be able to communicate with systemd's PID 1 >>> over D-Bus. >> >> FWIW I have this in my nss macro too, However I have two nss macros, one >> base macro and one superset that has this call amongst others >> (mymachines resolve etc) I only give nss base access to my confined >> users since they will never have access to any objects associated with >> userns uids/gids anyways so they shouldnt get into a position where they >> need to resolve them (except confined sysadm) > > I've been dissatisfied with what auth_use_nsswitch() and > auth_use_pam() have turned into, as I think they're too big. It's not > an easy thing to define due them being inherently extensible. What > you describe is one possible good direction to go towards. I was also > concerned about all of the network access that is allowed by it and > thought about splitting out the local accesses into a base interface. I agree, but it gets hard to maintain if you split all the individual nss modules. The solution i implemented in my policy also has its limitations and assumptions, and is pretty much all or almost nothing. Atleast you have the init_systemd tunable which atleast addresses the various nss_systemd modules to some degree. I only allow my confined unpriv users to read passwd and nss config, the drawback of this is that these shells cannot use /proc/net/"protocol" which is nice on the one hand for confined shells but it "breaks" bash Its a tough issue -- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift