Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1500084imm; Wed, 23 May 2018 17:57:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr95rkUFlmO9LC7j7noVUcLjOngQ/Q/KVRCBGS1Dw3dlc30uoh7sNI2eEick0QaclyBT0tk X-Received: by 2002:aa7:850f:: with SMTP id v15-v6mr4989087pfn.144.1527123420210; Wed, 23 May 2018 17:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527123420; cv=none; d=google.com; s=arc-20160816; b=lrYv6oH/C0A5z7XKVpSUX7aakxzU99afPB5iQg/AJYy2KUAqHri1oszlWSi2b93RLO QnuxwXO2C2KruCbmJvhXxDEI8Y2pZRcKXbizsFPPhLADBM8S7JSksVUXfOp6P0b0birj mTv7u+jCXymP0UFHBBq6t/71wklP3AuWe4AvpJGlUHVm8mapHTPQ/L3v4ReL5wvrWMHq dl6EVG4MNKRgViHSgX7VmkgZBri2wdgBivO+aLdYIAf09SNYsLTpx/QFNxNyEKfJYuKe W1zO0Cjtk9Mhk78lxVTlBGBitJCUBq7SRxSiarDJZK/1jZdWjf5QoFsEcj85t2eKe1Yn DI2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:arc-authentication-results; bh=FbImPLc6v2LEDPEIYgO04KFewopSGmhTRIkuelFVP8o=; b=Cyr9Hz/HvXNVyMWs1ly+gv1LE2Npqo88vW0t7fA5PY6KkSprXFzmOkflxyIIBMU8Ce Qn7nW8BcUXOaZgn7uGA6FyThZqH+2Or/WA4Drg2dT+5CrcIpjIbWxAQW+P/aqDXY/ZCz Q9vFuS3/Qv4n3re9U8aYWSTveuzMlbGOylH1AbqqAqZ+16duJMetq8PGkyFZAlFA1LIa PNtdN0t/2bv/Z1EwUD+G44OEUiv6cRiRk07I2MFJG1JqRaE9IouvNdXlqnV/cxk2r6kR 7tFYA/pc/Pg5MtjpnkKPZYrQw/aWuC8Y02HfaeXTm2dXnMT/KdD/3tkBUk18/mo9cDB+ 5fTw== ARC-Authentication-Results: i=1; mx.google.com; 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 a5-v6si19830445plh.340.2018.05.23.17.56.45; Wed, 23 May 2018 17:57:00 -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; 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 S935225AbeEXAtg (ORCPT + 99 others); Wed, 23 May 2018 20:49:36 -0400 Received: from ipmail07.adl2.internode.on.net ([150.101.137.131]:43723 "EHLO ipmail07.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935197AbeEXAtf (ORCPT ); Wed, 23 May 2018 20:49:35 -0400 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail07.adl2.internode.on.net with ESMTP; 24 May 2018 10:19:32 +0930 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1fLeRf-0000pD-5y; Thu, 24 May 2018 10:49:31 +1000 Date: Thu, 24 May 2018 10:49:31 +1000 From: Dave Chinner To: "Theodore Y. Ts'o" , Eric Sandeen , Eric Biggers , "Darrick J. Wong" , Brian Foster , linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: Bugs involving maliciously crafted file system Message-ID: <20180524004931.GB23861@dastard> References: <000000000000457b2d056cbb0044@google.com> <20180522123107.GC3751@bfoster.bfoster> <20180522222620.GW23861@dastard> <20180522225208.GB658@sol.localdomain> <20180523074425.GM14384@magnolia> <20180523162015.GA3684@sol.localdomain> <20180523234114.GA3434@thunk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180523234114.GA3434@thunk.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 07:41:15PM -0400, Theodore Y. Ts'o wrote: > On Wed, May 23, 2018 at 01:01:59PM -0500, Eric Sandeen wrote: > > > > What I'm personally hung up on are the bugs where the "exploit" involves merely > > mounting a crafted filesystem that in reality would never (until the heat death > > of the universe) corrupt itself into that state on its own; it's the "malicious > > image" case, which is quite different than exposing fundamental bugs like the > > SB_BORN race or or the user-exploitable ext4 flaw you mentioned in your reply. > > Those are more insidious and/or things which can be hit by real users in real life. > > Well, it *can* be hit in real life. If you have a system which auto > mounts USB sticks, then an attacker might be able to weaponize that > bug by creating a USB stick where mounted and the user opens a > particular file, the buffer overrun causes code to be executed that > grabs the user's credentials (e.g., ssh-agent keys, OATH creds, etc.) > and exfiltrates them to a collection server. We've learnt this lesson the hard way over and over again: don't parse untrusted input in privileged contexts. How many times do we have to make the same mistakes before people start to learn from them? User automounting of removable storage should be done via a privilege separation mechanism and hence avoid this whole class of security problems. We can get this separation by using FUSE in these situations, right? > Fedora and Chrome OS might be two such platforms where someone could > very easily create a weaponized exploit tool where you could insert a > file system buffer overrun bug, and "hey presto!" it becomes a serious > zero day vulnerability. There's little we can do to prevent people from exploiting flaws in the filesystem's on-disk format. No filesystem has robust, exhaustive verification of all it's metadata, nor is that something we can really check at runtime due to the complexity and overhead of runtime checking. And then when you consider all the avenues to data exposure and unprivileged runtime manipulation of on-disk metadata (e.g. intentionally cross linking critical metadata blocks into user data files), it's pretty obvious that untrusted filesystem images are not something that should *ever* be parsed in a privileged context. > (I recently suggested to a security researcher who was concerned that > file system developers weren't taking these sorts of things seriously > enough could do a service to the community by creating a demonstration > about how these sorts of bugs can be weaponized. And I suspect it > could be about just as easily on Chrome OS as Fedora, and that can be > one way that an argument could be made to management that more > resources should be applied to this problem. :-) There's "taking it seriously" and then there's "understanding that we can't stop new exploits from being developed because they exploit a flaw in the trust model". i.e. kernel filesystems are built on a directly connected trust model where the storage "guarantees" it will return exactly what the filesystem has stored in it. Hence our filesystems are not built around tamper-evident/tamper-proof structures and algorithms that are needed to robustly detect 3rd-party manipulation because their trust model says they don't need to defend against such attacks. As such, the most robust way I can see of defending *the kernel* against malicious/untrusted filesystem images is to move parsing of those images out of the kernel privilege context altogether. The parser can then be sandboxed appropriately as you suggested and we've avoided the problem of kernel level exploits from malicious filesystem images.... > Of course, not all bugs triggered by a maliciously crafted file system > are equally weaponizable. An errors=panic or a NULL derefrence are > probably not easily exploitable at all. Bugs don't have to be exploitable to be a "security issue". Detected filesystem corruptions on a errors=panic mount, or undetected problems that cause a x/NULL deref are still a user-triggerable kernel crash (i.e. a DOS) and therefore considered a security problem. > A buffer overrun (and I fixed > two in ext4 in the last two days while being stuck in a T13 standards > meeting, so I do feel your pain) might be a very different story. The fact you are currently finding and fixing buffer overuns in ext4 solidly demonstrates my point about existing filesystems being largely untrustable and unfixable. :/ Cheers, Dave. -- Dave Chinner david@fromorbit.com