Received: by 10.223.185.116 with SMTP id b49csp1160362wrg; Wed, 14 Feb 2018 12:34:50 -0800 (PST) X-Google-Smtp-Source: AH8x225dvi3QCfzXHwfn95TiF0UKgFhcwIXm5XZNKaLnXOsYAqZQmYtckd5HjL2jFnRnzDwkX/o8 X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr233317pla.85.1518640490346; Wed, 14 Feb 2018 12:34:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518640490; cv=none; d=google.com; s=arc-20160816; b=x7FWsn/4f/GixhWzk2DpKAj4mGl9Yu5+ogWd8TqX4WwrC6Y/7PVBEf9NNJ0IeZ0VYE SXu//l3ImOuUerl3k0UbEisqau7o3TmiN+5xwroSvFVOFAIk9r0FlXv1ggMD6QfIn5/y k/9X1XAQ9STqtnVmJ8LHo0rIe10gR0Nuf1uFoTquEi5StN1xnHfzNJYzNFO0RbnrFmfM 7/+PtfmQijKcL1Z3fOjNg2zjlNkVyOqgjpzO+ZMV9D9LBDY54lY0La8wArWPw1k0Ssw3 Q4+sXOd6Vp2zg+8U1+J33MG8n15HZtDNERPzt5rDHqfO85ub2K6EIVg9lX11cBaGdNjG pJXA== 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:cc:to:subject:dkim-signature :arc-authentication-results; bh=6od1yJ4Yh2ZOmVuvitQZk/lqeB94XEXsKuaw6z1S87c=; b=llW9bZJMdahHrJcxLUnTBqcaC3Jj73ZjEdEKLMrRsa6BXuNgJG77flzJYplckGRGSO /ayYUEYX92GxdVXU47nFSmIyTuQOr2B++wClMpW8TJts/RqrJO5JroaX+5n1nGxoi5ZG nTCMcrjDdJ4GVkYmhVl2xvjeea77RC3I2Mjxyeaosf0hKdiO15ELKGJuqrOLGuh474BL MLVPsDlKNBXSU3csKuS/N8oaEnSNt7Se5zHeRiFG5LMbbu6utxGM2uene+VRHAVPmz9R bFKSpomfVSnQxLEZrWe1I5pkvMHfRoszZcJbujFp/n0EwA3hio2/2xUkG44tZRyLRxdD jDYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uCD4uuS/; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si334693pgb.190.2018.02.14.12.34.35; Wed, 14 Feb 2018 12:34:50 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=uCD4uuS/; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935149AbeBNUdu (ORCPT + 99 others); Wed, 14 Feb 2018 15:33:50 -0500 Received: from mail-io0-f181.google.com ([209.85.223.181]:35739 "EHLO mail-io0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752602AbeBNUds (ORCPT ); Wed, 14 Feb 2018 15:33:48 -0500 Received: by mail-io0-f181.google.com with SMTP id m11so26518029iob.2; Wed, 14 Feb 2018 12:33:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6od1yJ4Yh2ZOmVuvitQZk/lqeB94XEXsKuaw6z1S87c=; b=uCD4uuS/EbJrDhFWNAK1yPwSDmqsTfxZsEKzlvSc20/x5MGFyG3MomG2YoMIrHuR8w 9DIiyO34cagCxX9XIlnxQUE3HKvSUuTyVDzRJiSj5OSeZs0XuzT5jzcpr1Xro0gJthrO JFtDZ5+HpNlB1hcGHtuyX2xnF5edu7uRFy6M309LhCNz0UyLR3houMwEsWa56pwP6I46 iHtJ637V4CMAyW6EgmY6i0WBfSORM1Q9mOCCtD8y288pU2yAkRU0aTycOfeD8OaMYuL+ +334ABPbvtovhNKdx143DBUvt2fSBNpZBZ0B9vpmvQ3au/LvV1s5mVBveEicDa2Cf7SI wP/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6od1yJ4Yh2ZOmVuvitQZk/lqeB94XEXsKuaw6z1S87c=; b=DGaKOoICupL9+94x+j+V28m/zoFogb6NdWXsYs+ChVLx5HeQkSLc6PuEZ3L5AwyVgA 3XC+bKwZzkdL0iNyOw+Y1Uq/aGN/lqrW/z6K/0pLzN9GDI0tUzvuldEt1w99O1Qz2c4l 2v8GsqjoCM/nCyh8RIJYaJ8k/3oNo6Ry0Q0jWbvMPpRBz3XLka3VhztEx1YvbB+SDrcn YETP5u+9fc6gsHy0XxP619dFfhxtoTYQu4Lk4+2+bS/WLbHh77pD/ba3OkRUFM5AzuIM uTdjOn747z7CTt9E6okNWWGUiinV1JmEY7ZQ4Rxp5WgHy1HWSxSIjgF3OWyTQPP/k1S6 GoDw== X-Gm-Message-State: APf1xPDfpK0aAvX0B/aQ8axnvJ4NNCxNT36kKEKnm7BVILZAzSSI4Qdu +9dfbUpPx74zXZlIZvsLjEhuS3OM X-Received: by 10.107.131.218 with SMTP id n87mr641685ioi.268.1518640426672; Wed, 14 Feb 2018 12:33:46 -0800 (PST) Received: from [191.9.212.201] ([70.62.41.24]) by smtp.gmail.com with ESMTPSA id k204sm15039135iok.68.2018.02.14.12.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 12:33:45 -0800 (PST) Subject: Re: Read-protected UEFI variables To: Benjamin Drung Cc: Ard Biesheuvel , Matthew Garrett , Jeremy Kerr , Matt Fleming , linux-efi@vger.kernel.org, Linux Kernel Mailing List References: <1518612748.4749.29.camel@profitbricks.com> <1518614486.4749.33.camel@profitbricks.com> From: "Austin S. Hemmelgarn" Message-ID: Date: Wed, 14 Feb 2018 15:33:40 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1518614486.4749.33.camel@profitbricks.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-02-14 08:21, Benjamin Drung wrote: > Am Mittwoch, den 14.02.2018, 13:09 +0000 schrieb Ard Biesheuvel: >> On 14 February 2018 at 12:52, Benjamin Drung >> wrote: >>> Hi, >>> >>> I am exploring the possibility to store SSH and other keys in UEFI >>> variables for systems that do not have persistent storage. These >>> systems boot via network and need individual SSH keys which ideally >>> should not be distributed via network. >>> >>> The plan is to write a small daemon that starts at boot and gets >>> the >>> SSH keys from EFI variables to individualize the system with SSH >>> keys. >>> I plan to release the code as free software. Simple proof-of- >>> concept >>> code: >>> >>> mount -t efivarfs none /sys/firmware/efi/efivars >>> for key in ssh_host_dsa_key ssh_host_ecdsa_key ssh_host_rsa_key; do >>> dd ibs=1 skip=4 if=/sys/firmware/efi/efivars/${key}-89df11f4- >>> 38e6-473e-ab43-b4406b76fba9 of=/etc/ssh/$key >>> done >>> >>> I am not the first person having the idea to use UEFI variables to >>> store keys: >>> https://www.usenix.org/conference/srecon17asia/program/presentation >>> /korgachin >>> >>> There is one problem: The keys should be readable only by root. >>> When >>> mounting efivarfs, all variables have the permission 644 which >>> makes >>> them readable by all users. I have different ideas how to solve it: >>> >>> 1) Hard-code a list of GUIDs that should be only readable by root >>> in >>> the kernel module. These modules would also be not set to >>> immutable. >>> >>> 2) Instead of hard-coding GUIDs, add a kernel module parameter to >>> specify the GUIDs. Maybe have a default list in the kernel module. >>> >>> 3) Add a mount option to specify the protected GUIDs. >>> >>> Feedback is welcome. >>> >> >> I'd consider a patch that makes the permissions a mount option for >> efivarfs, applying to all variables. The reason is that these >> variables shouldn't have been world readable in the first place, and >> I >> am reluctant to make this overly complex. > > Having some variables (like the BootXXXX and BootOrder variables) world > readable is useful. This allows normal users to run 'efibootmgr' to > display the boot options. Some variables maybe (ISTR variables for things like the system time-zone or the firmware locale settings, which _might_ be useful), but I would say the boot variables are not on that list. The only practical application for a regular (non-root) user to read those variables is to gather info for an attack on the system. Anybody who legitimately needs to access them (either for debugging the boot process, or changing the boot options) should have administrative access to the system anyway, and even then they will usually not need to read them. In fact, most of the UEFI variables fall into the same category, but even more so, userspace has no legitimate reason to need to read them. You can get an absolutely insane amount of info out of them on some systems, most of which is a gold-mine for potential attackers. For the handful that may actually be useful to userspace, most would be needed only during system startup, and thus could safely be made readable by root only. > >> On the other hand, you should realize that UEFI was never designed to >> keep secrets, and so whether it is a good idea to put secrets in UEFI >> variables to begin with is dubious IMHO. > > If the UEFI is as secure as storing an unencrypted file on a hard > drive, I am satisfied. Or do you have a better idea where to store the > SSH keys for a diskless system that boots via network? > There really isn't any other option unless you're willing to put a small amount of flash storage in the system somehow (maybe a small USB flash drive connected directly to a USB header inside the system?). As far as the security of UEFI variables, the same limitations as storing the data on an unencrypted hard drive apply, with the addition that it's much easier to get at them through stuff like Intel's AMT or IPMI than it is to read data off of the hard drive.