Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp75481ybi; Tue, 16 Jul 2019 16:31:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnyalgJna0W14NqXeKSIa2qk72BUt047xsmulcAd9KZW2IxCkWdRJXCnQmghuSViK8OvXV X-Received: by 2002:a17:902:3341:: with SMTP id a59mr38231225plc.186.1563319866743; Tue, 16 Jul 2019 16:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563319866; cv=none; d=google.com; s=arc-20160816; b=iFno/4/6ra21sckDobqQ/PW3D3e3tXbm0t9sBVTkh/gquVs3widYGck4uBfOW8jwr1 W1tjkjHOMt7PyXJwCs2uvyKmmWWOvcwID/2DioFvUjUnUoJ1INOkPNc6jn/ygzBnM+u1 GBx0ODmD4z0w7XG8A6oiUNJE4bQpsMDSNU1Ugp960ZV5CEUHPEUew2s0YXqBV2IkfaDC o0E6+8WXJ7S0PkOYatpX5KhDrIFCXiQS/lQBNCAcw5lFqwLpFP/GNaF2nGu7cD1HpJo1 wUNlPPo3q+0FBT9ih3fZitIiFZElTTILX3m/QOMyeF1hr8jqq8AEbROjE7G4UFMrPBsG hkvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YWcpEc5FvGUxMrkeRiB0cnwgYS5TPs4Urt5+gPVZDh8=; b=yY44vQZjWSM6VfHJaol7ZRHSOTdcUAtdSP4jwM0HF3QC39Cia/5v4Hia28pyohxbs2 saKvPbIB8M+RYLKtFnFIhLq8jKTzuvE2PMDxdAeIHPULtal0JjOgxBRaZZGmTUNHuOXy OJALemo32aVjcWSkyF1KffXPHzsKSYyE299a8BQAfUqSU0APnS+mRSRq/ifxJptv8/uK 0PbV6QkEb6z3YZGlWxBwBfeBxKcHgQN09rqALJzQs2mVfv0q+ZE78FS21SXFYQvwXIiM 9n6n9+6d9MeIqvZLkMkI3+/0PcFg6PHiJ+RdYRWNZqlIsVHPZHRubEAXqfh32/XereJz M48g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=kfuVXg1G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 a11si20801216pgj.537.2019.07.16.16.30.49; Tue, 16 Jul 2019 16:31:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=kfuVXg1G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389148AbfGPXa3 (ORCPT + 99 others); Tue, 16 Jul 2019 19:30:29 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37138 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389115AbfGPXa3 (ORCPT ); Tue, 16 Jul 2019 19:30:29 -0400 Received: by mail-lf1-f68.google.com with SMTP id c9so14952353lfh.4 for ; Tue, 16 Jul 2019 16:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YWcpEc5FvGUxMrkeRiB0cnwgYS5TPs4Urt5+gPVZDh8=; b=kfuVXg1GBNwcOoznZPvryqh6/i2XrbBE6hkmVUMgSZi+LTGFCMeiia9P0u53fqR03S Db8ww5cz17ZFCZKlTuva1FUSo3Y2oMZofZ8fP/h1fLivURlC81chU7PWbmPju7Admx1Z 0vNl1Znw/JxnQbaEB3qodZy91u3UJcA/kBkF3/fop+D+uNxeIU9ClEdXjFRvVywlejx8 DnAqQwuvXO4VpPWfxjCThhbeKljqILhPjFnODqbpRq1N11o4FSdml1BI7L1b7dz9y+YP fYw1lfsvEQejaiRHp3kfd9vzzpXxhC6v4ipIrx4uMBDRiXoRA77MJ55m7j30qsm5olyc 8AKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YWcpEc5FvGUxMrkeRiB0cnwgYS5TPs4Urt5+gPVZDh8=; b=Cob2kiRlxZG7mGteiVNjPtnS89WPiGbUJnmsVbPOP5oEeVWZvnyjjVWSov+2jaELA9 nb+CxcMc0Usx7ifEyVJ6CcII1htkcIZcOAZm5PxKio9MPaRGTG+KJ7X7aePuE1/9WqNp nv6LRaGbvVmvKy+uM47BZsJ4yeihAp1cGjswj6D4LvBtNG47ar1He9gVMvJ3e5tjmcMI 7IwqaRKUXAJhovvtWfaMFu87v7JxdxDV9KjK/dvCkaxOBkU6/dk6FxbQ7UJrx/uGvcHs ThKQWqkJpPt8WbHkeYfODaZe2x001jJEDWakQrSAIXnvol1H1plhR8Skl9S3FVRtVrfJ 0pUA== X-Gm-Message-State: APjAAAVkD33bUAFNQfNONi5Mv+VZkke7er61Y8qJc1ErsVIe6SFt6OpP BnYEuiGBLPUEusNhAFez+v1f8qpxB7mtBfUp+g== X-Received: by 2002:ac2:4109:: with SMTP id b9mr14480083lfi.31.1563319826317; Tue, 16 Jul 2019 16:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20190529145742.GA8959@cisco> <20190529153427.GB8959@cisco> <20190529222835.GD8959@cisco> <20190530170913.GA16722@mail.hallyn.com> <20190708180558.5bar6ripag3sdadl@madcap2.tricolour.ca> <20190716220320.sotbfqplgdructg7@madcap2.tricolour.ca> In-Reply-To: <20190716220320.sotbfqplgdructg7@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 16 Jul 2019 19:30:15 -0400 Message-ID: Subject: Re: [PATCH ghak90 V6 02/10] audit: add container id To: Richard Guy Briggs Cc: "Serge E. Hallyn" , Tycho Andersen , containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , ebiederm@xmission.com, nhorman@tuxdriver.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 6:03 PM Richard Guy Briggs wrote: > On 2019-07-15 17:04, Paul Moore wrote: > > On Mon, Jul 8, 2019 at 2:06 PM Richard Guy Briggs wrote: ... > > > If we can't trust ns_capable() then why are we passing on > > > CAP_AUDIT_CONTROL? It is being passed down and not stripped purposely > > > by the orchestrator/engine. If ns_capable() isn't inherited how is it > > > gained otherwise? Can it be inserted by cotainer image? I think the > > > answer is "no". Either we trust ns_capable() or we have audit > > > namespaces (recommend based on user namespace) (or both). > > > > My thinking is that since ns_capable() checks the credentials with > > respect to the current user namespace we can't rely on it to control > > access since it would be possible for a privileged process running > > inside an unprivileged container to manipulate the audit container ID > > (containerized process has CAP_AUDIT_CONTROL, e.g. running as root in > > the container, while the container itself does not). > > What makes an unprivileged container unprivileged? "root", or "CAP_*"? My understanding is that when most people refer to an unprivileged container they are referring to a container run without capabilities or a container run by a user other than root. I'm sure there are better definitions out there, by folks much smarter than me on these things, but that's my working definition. > If CAP_AUDIT_CONTROL is granted, does "root" matter? Our discussions here have been about capabilities, not UIDs. The only reason root might matter is that it generally has the full capability set. > Does it matter what user namespace it is in? What likely matters is what check is called: capable() or ns_capable(). Those can yield very different results. > I understand that root is *gained* in an > unprivileged user namespace, but capabilities are inherited or permitted > and that process either has it or it doesn't and an unprivileged user > namespace can't gain a capability that has been rescinded. Different > subsystems use the userid or capabilities or both to determine > privileges. Once again, I believe the important thing to focus on here is capable() vs ns_capable(). We can't safely rely on ns_capable() for the audit container ID policy since that is easily met inside the container regardless of the process' creds which started the container. > In this case, is the userid relevant? We don't do UID checks, we do capability checks, so yes, the UID is irrelevant. > > > At this point I would say we are at an impasse unless we trust > > > ns_capable() or we implement audit namespaces. > > > > I'm not sure how we can trust ns_capable(), but if you can think of a > > way I would love to hear it. I'm also not sure how namespacing audit > > is helpful (see my above comments), but if you think it is please > > explain. > > So if we are not namespacing, why do we not trust capabilities? We can trust capable(CAP_AUDIT_CONTROL) for enforcing audit container ID policy, we can not trust ns_capable(CAP_AUDIT_CONTROL). -- paul moore www.paul-moore.com