Message ID | 20221214003401.4086781-1-eric.snowberg@oracle.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp447864wrn; Tue, 13 Dec 2022 16:35:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5h7UfVculeNpF4OgEdVGqdV+mFRacJBlxJC4msILB9czDJdUPAQQOrkN36LT8RKoMFJHA0 X-Received: by 2002:a05:6a20:6d8a:b0:ad:a0c2:53ee with SMTP id gl10-20020a056a206d8a00b000ada0c253eemr10633053pzb.12.1670978108186; Tue, 13 Dec 2022 16:35:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670978108; cv=pass; d=google.com; s=arc-20160816; b=yyt8Kwhuux/0qqUf7c9nqsiOyiv4/AizuLTw5oMKgNBguscF8BN5ibLLLmoe3tYDOh Lt+NWtuee1cwOckQPxIOXCIjBhCQD2eGeujHDiTUHIz8lzsi+e0rM8VikSgY8T5m0zQK o7xT6dpU/xAukiEVa9X8O2I7TUayILw9Gq9Vuftozhe1fE6Ylg9ktFYuE/Xy9cd8NBlw 5MQyApCDVm3gd9hav2i44jO3R92Nbjh3gPmsw4A9CpUGPekKDg+mUuQA909zLZzX7+3X gtWfE+bmvjmEVBrqaX2lPqHxEu2zIfwIJFT0d1fV5p1B82GPCFnyoMA/YQTh1APPoR4l C3jA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ns4doCMIogENs7dEUwwt3w44xeLE3Bdj20dPZT718Vk=; b=Zshe4CwUjFpJioNFfIIPctcczQArfIxQFllpMmnwFoHezCpCoxaMYptMIlxwenAviq steQ8+Up1m02teaY+omUUWIFxfjaaJ1NtGrKKvhnuALQnVSGA2FEgaU+Biiu52VjHgFY pBjtePYN2CLDi4y9U4IUnsdmD0aEpzpKYAhrLli59r2mikXv67CXAbXI34z5GnRzVoGD g/fQAF1zAxlrPGoAeGT18WciqNn1bH4EKKKY33U5olE9yp1p1dwuvzWkyr2tCV6tJVxs dV0TbbQispfcZiAqJjfO6mSjh/+lpyHPc9sN7So50vvc7FsYfixwUHTRQWKUYRPIY1Z+ v96g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=EjkKYQFo; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GbtvxOZJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r21-20020a170902c7d500b00189c83914a8si1079722pla.416.2022.12.13.16.34.54; Tue, 13 Dec 2022 16:35:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=EjkKYQFo; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GbtvxOZJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237811AbiLNAem (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Tue, 13 Dec 2022 19:34:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237744AbiLNAec (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Dec 2022 19:34:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C3EB1DA79; Tue, 13 Dec 2022 16:34:31 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDLOCPo017259; Wed, 14 Dec 2022 00:34:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=ns4doCMIogENs7dEUwwt3w44xeLE3Bdj20dPZT718Vk=; b=EjkKYQFozoCyw2NjraJ1wZMFwxB7/1PXo0O2wY44mPbLQOi3LmGgId0oh5EpsrpkI07w Qqrt4r0/R20KFBsACEXGaJfdMkQbUaa4rVxNGQn9g2chAb7tFGIK84KIn89z5NJgo+yA CH3mJsFhYa6oBJ5PQ2cZwpTGanstjm9JKpLHSIkV1myJ2d70nhmmfyvOPB9q5vGm/pAq WMtzFJM8SL5qqH0dD1eiabCjyTLk/3HzxPT5i+ItG9Yf1xQb9jw02ICo3Xd7/v6KY3oT BnEV5QtWPCfdcuYoYpfwgDqLlVKAUWHgSY6y17XSnpHQUWIiWr5lkfZAugdB/vBQGwiR /g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3meyex0p16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 00:34:03 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BE00YSR012219; Wed, 14 Dec 2022 00:34:01 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3meyev4sed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 00:34:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eCJvsqhOG8oBAavESYlYCHGvsGbTvRunPbZFqgFcQPjbQ9pdnA81bLPipDlxOR/H7pQ5Xn+N6Gqd0AqE3ELMPpAS0oLUOch0EDquDTs3PGjMObJogoATKatLyQLCt+BzPgIoo/6HP65Dwz0oa7h9DD7+dxx9rSrIQP90iu7f4bh9Z4npa9qB+0cDT0vhCwz2t3USKWckbxqVTlgCxrnIBHUKNPr4W5SJ143qqdQxTQSQaz3Rg7eeKm4+4fdBxfADbx6mqMIrn0f9t0TpwGx7acsYsLAVNmva5EPAUTzjL2EB2GmsVs3VBrkeX7v6f0ongAd2l4JIBFgV2fqdVrqZ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ns4doCMIogENs7dEUwwt3w44xeLE3Bdj20dPZT718Vk=; b=gtbl9Z1v7aBHwVaDAiWxT9QlZ9KOmIgAOCNhWW9lBHx4pNzn+h2YR6dHPf8CG0GN9mtHl+U+c0g2laFVhtVI4FzOA2+G1NBFO0mUCH+FBzGJGN/fNbDFuMgmDEvMk/8DMQXcVO1EUnxzENHBueQrlwOFO2xjvMszV+jEoKFXcGmRLIZ/lproYd9y1heRXO96V0D3VLCXvGnnQNW9wa6am/ZBJkkHI/q8X2JGofRNV7apKlA+9Vm7syNJ38eizF6davzeRAFExWHnsIR1MToFurpaeAOlbel0wfwI0w0lU45dbnOJPETSaS0/inPV7esMCTAHLdGq0jBJabIXMdvAhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ns4doCMIogENs7dEUwwt3w44xeLE3Bdj20dPZT718Vk=; b=GbtvxOZJ15rEsiHe2vjixQoMWybHsHfxziCNl35IHO61Hpkmmije2x1RbaFgWg9VkbzjkA1wbpKWoD+rN5L2O2RwU03PUXpmTClbWQDxD170h7U2uqwlmZhx3yTEYpAvGDI2zGMHKlH3eXHwjYY5EqDplRBtYwH2nUSMe3j3jRk= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by BN0PR10MB5223.namprd10.prod.outlook.com (2603:10b6:408:12a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 00:33:59 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::f006:f411:9056:63a4]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::f006:f411:9056:63a4%4]) with mapi id 15.20.5880.019; Wed, 14 Dec 2022 00:33:59 +0000 From: Eric Snowberg <eric.snowberg@oracle.com> To: jarkko@kernel.org, zohar@linux.ibm.com Cc: dhowells@redhat.com, dwmw2@infradead.org, herbert@gondor.apana.org.au, davem@davemloft.net, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, pvorel@suse.cz, noodles@fb.com, tiwai@suse.de, eric.snowberg@oracle.com, kanth.ghatraju@oracle.com, konrad.wilk@oracle.com, erpalmer@linux.vnet.ibm.com, coxu@redhat.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v3 00/10] Add CA enforcement keyring restrictions Date: Tue, 13 Dec 2022 19:33:51 -0500 Message-Id: <20221214003401.4086781-1-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.27.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM6PR03CA0013.namprd03.prod.outlook.com (2603:10b6:5:40::26) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4150:EE_|BN0PR10MB5223:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a628d2b-e67a-4536-cd6a-08dadd6ae463 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vqh7/05/KlV8lJvBK7P6eVyFUw1GYpnbTVT0jWTOFAdHDVyt3kSYtKBk77DR5MRtgDL3MEJ8O31M+14/TwIyzppSUTY/Tp1FI0aRZSvjmN6PrJ5fSZMEeJ+/8bFqmykC0vCJ+Aq9E9UyjrjHXXvTqHzvxqpzeF7K+e0A5G2AWUrldJJQIrEDLdW+/ftC8tQwURkabaPVNiQehdtKI6wIMCSJrWQNvVyShKHH6eHw4OtkHl3imnoyfiYYMfKm3WhPJsbV7L5KfZrRsbNjF2ncDsYq3y+PPTmGajdyOQDHNwfEtJLumsmhkEoVhKxytoK3NgqOsUCesMIFhc1g1DwDLn8TT7Y40dRmF+m3dGoYL5Xmwd1iaHY8v2bwCs2ddvnPk9ZRjxPvs12K//a5okaUZCdSmI0tRXJGlRkOoYwLK/3RKbdz9FtAKpzK7xDQGfd6a9Gy13rMqrlzz36503fCnwFZO4upuF7sIjX1yKwOdr1KyNVIXBBsshgxhYtIkWhCXbrQi5TiwtwcHB+rBMBHnwbcMlDneDbhDr6LIHOfjF5VZd7Sjv91ibDdiuT0uxFupyHP1GlhunENOdcuEB75x2kgmGJI6mO6aBiCO13H2eTSIK52NWK19eX/raUA0XEn9Bu92WKkXiYQFNPQb4jLDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR10MB4150.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(346002)(376002)(366004)(136003)(451199015)(41300700001)(38100700002)(86362001)(6486002)(8936002)(478600001)(6666004)(4326008)(66946007)(8676002)(316002)(66556008)(186003)(2906002)(83380400001)(6512007)(66476007)(6506007)(7416002)(1076003)(44832011)(2616005)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iRpxKAgVKpdoAAsCUIPZeMYifC2WKfhS4YlmiUtZHGi+Morp1qMZHuOzGQyqvmjqKyPGNBju4o5sFuMBB6POQCNBTmgD9BGyMWNvX+a57lh83UgcyxwJEPkpykzbOTloxd5HWT9WREfxLxuGlN+dj5HC7FuOeFJrTC6th40EGSs37LMHGLmLe3fzfYqxpV5AeMfL0MJ2vCqX4gPZJMf5YS0s2N/dMVB4rouaXvp0ltd9env+DQJ3NXDqL6S4O0absQtkKEMcpSJU3PN8pKJ+fZrJpvbravWf3XQzTjQt+TNQ03EJYDMCmnHGLsTxL5/r3NMAE3NkT/Q+/CHFsAYwq/PGwjqi5UxHPCLgSmC3M2xzegaVps/6jgDtvrn3at43qcuBnMwxEGHGWLizff746nE3exykoT3h1w9S+5GTaSUG1ogTdRb+h4CFrSctBHG1+YSkxj4XzIZZhd2yy9jW8ZQzf51kiTH6EqG7BiFmFnoyOzAb/Q0DrteqYwWNgP7HUJFQ73cgSUiuM08jqqeJZytGXN/k4zy9wrWU8a1BIoKDoQvVgfSpYxLHEUhcS6oajNI85ka0B9TW6bx6lCSZT4SZeqX1dQsTtFaCE2DlPTvwvO9ZyY5G87Gl4P/72oAvH/h9W9woAAZzTAHr8ejz7vYGPqJCa6DRM7sR/gIuxWEJpdHmjTm4s/7SPVqAc+vl39OddPKyEGmH9M1mBSFfFtRQRPUjgfwF6qIIytz40z1Rplt+6fR87SzEgYE34rJ+1lHCpJlPt2Bqc1dg8lZGgcMLj5s0YQedog21/HR/EyRQ9QAnF5uHFms4/mHMMOHD7xFsAhpbjLy/JZJGiNgCgbJVfuNdjyj4EikKeXgQOuqyVixz3bWAE9WmcLzQi/MJ8C89CQYDh69/M54b6x2bBMgXoGMO4VYlZz+5NPRAGwzS1G4xmg33FYleMbxz4tpEYsRZ2/qqVEk59tiA1clIPXiUAVWoZkAwd/t3dM2kTizllfl3sCJGea90ZzbiO6BzjQnFi6xq37j6kq4NyypIoWIZogj2/0zy/9G16wcBl3Gjh8iZfzJ4tBZMpSb3eV3CT+PGPqlFeapi7P+uEUYD7N4jwbYob3fCx5iWPVMpUw/UW8AAzBAjifGzpbZq2M6rVCIXSps/MTc1BRR52JyUKmyal0H7cr2YHVzBGkHQD+8Appm2XfK2kFNdb/DjsVfCl0ZkmQ6b4woD+9xEpHi0Z0puyph/rsH+W72yCCgfgDD+XSMVkHPQu0ePuuhuGdMY+azUxxXX9hZmax0sQmidBD3rNyR7Xm5I3qxJHH+gulWk2s5AA1ibl4R8u3VbKjsrbTTivoYqsWtkesInCZHXZcyYZ0U/F22es+l4+TbYAg13FQTfNwqQnLr2Jz6IiEl6LgBq3CW0NQxv7DaUbxva5PmsKSdaOycHMJ1nn7mydIkvCPMRB92r3ES+9Ihp5MeVHC+l93Ir/Xx+HA+TlLMyHKB0na0ljBaDA0ZBJdc229cTQR0XU9PzwVO/bR9J4zlr4rSw7U3yI4w7vejGI8iO3CqhZEXG8IblNwPb5w8xqiWhfiWYdJtPgR+M62wTr/jKUua4IgWvcLf+2AXUroQSbzBTJugFO6ITNtXF9ChWkXg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a628d2b-e67a-4536-cd6a-08dadd6ae463 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 00:33:59.6238 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9VPKc+QhG2SO+OKuALfjS0E840QQ7mjGOKcv//GwGvDXlzdia/GPVVaemDcAed+hrRodLCYqdazU9xRpjgQkBMisMNbr40rDwT61sHZMQhw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5223 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140002 X-Proofpoint-GUID: xohwN_5B8emlLZaMXl0SMBwlX6UjqXIE X-Proofpoint-ORIG-GUID: xohwN_5B8emlLZaMXl0SMBwlX6UjqXIE X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752147540605074190?= X-GMAIL-MSGID: =?utf-8?q?1752147540605074190?= |
Series |
Add CA enforcement keyring restrictions
|
|
Message
Eric Snowberg
Dec. 14, 2022, 12:33 a.m. UTC
Prior to the introduction of the machine keyring, most distros simply allowed all keys contained within the platform keyring to be used for both kernel and module verification. This was done by an out of tree patch. Some distros took it even further and loaded all these keys into the secondary trusted keyring. This also allowed the system owner to add their own key for IMA usage. Each distro contains similar documentation on how to sign kernel modules and enroll the key into the MOK. The process is fairly straightforward. With the introduction of the machine keyring, the process remains basically the same, without the need for any out of tree patches. The machine keyring allowed distros to eliminate the out of tree patches for kernel module signing. However, it falls short in allowing the end user to add their own keys for IMA. Currently the machine keyring can not be used as another trust anchor for adding keys to the ima keyring, since CA enforcement does not currently exist. This would expand the current integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY Kconfig states that keys may be added to the ima keyrings if the key is validly signed by a CA cert in the system built-in or secondary trusted keyring. Currently there is not code that enforces the contents of a CA cert. Any key in the builtin or secondary keyring can be used. To allow IMA to be enabled with the machine keyring, this series introduces enforcement of key usage in the certificate. This series also applies this enforcement across all kernel keyrings. The machine keyring shares similarities with both the builtin and secondary keyrings. Similar to the builtin, no keys may be added to the machine keyring following boot. The secondary keyring allows user provided keys to be added following boot; however, a previously enrolled kernel key must vouch for the key before it may be included. The system owner may include their own keys into the machine keyring prior to boot. If the end-user is not the system owner, they may not add their own keys to the machine keyring. The machine keyring is only populated when Secure Boot is enabled. A system owner has the ability to control the entire Secure Boot keychain (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. With this control, they may use insert-sys-cert to include their own key and re-sign their kernel and have it boot. The system owner also has control to include or exclude MOK keys. This series does not try to interpret how a system owner has configured their machine. If the system owner has taken the steps to add their own MOK keys, they will be included in the machine keyring and used for verification, exactly the same way as keys contained in the builtin and secondary keyrings. Since the system owner has the ability to add keys before booting to either the machine or builtin keyrings, it is viewed as inconsequential if the key originated from one or the other. This series introduces two different ways to configure the machine keyring. By default, nothing changes and all MOK keys are loaded into it. Whenever a CA cert is found within the machine, builtin, or secondary, a flag indicating this is stored in the public key struct. The other option is if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs will be loaded into the machine keyring. All remaining MOK keys will be loaded into the platform keyring. A CA cert shall be defined as any X509 certificate that contains the keyCertSign key usage and has the CA bit set to true. With this series applied, CA enforcement is in place whenever IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY is enabled. Meaning, before any key can be included into the ima keyring, it must be vouched for by a CA key contained within the builtin, secondary, or machine keyrings. IMA allows userspace applications to be signed. The enduser may sign their own application, however they may also want to use an application provided by a 3rd party. The entity building the kernel, may not be the same entity building the userspace program. The system owner may also be a third entity. If the system owner trusts the entity building the userspace program, they will include their public key within the MOK. This key would be used to sign the key added to the ima keyring. Not all 3rd party userspace providers have the capability to properly manage a root CA. Some may outsource to a different code signing provider. Many code signing providers use Intermediate CA certificates. Therefore, this series also includes support for Intermediate CA certificates. This series could be broken up into 3 different parts. The first two patches could be taken now. They solve current issues that will be triggered by the build robots. Patches 3-8 add CA enforcement for the ima keyring. Patches 9-10 restrict the machine keyring to only load CA certs into it. Patches 9-10 require all the previous patches. Changelog: v3: - Allow Intermediate CA certs to be enrolled through the MOK. The Intermediate CA cert must contain keyCertSign key usage and have the CA bit set to true. This was done by removing the self signed requirement. Eric Snowberg (10): KEYS: Create static version of public_key_verify_signature KEYS: Add missing function documentation KEYS: X.509: Parse Basic Constraints for CA KEYS: X.509: Parse Key Usage KEYS: Introduce a CA endorsed flag KEYS: Introduce keyring restriction that validates ca trust KEYS: X.509: Flag Intermediate CA certs as endorsed integrity: Use root of trust signature restriction KEYS: CA link restriction integrity: restrict INTEGRITY_KEYRING_MACHINE to restrict_link_by_ca certs/system_keyring.c | 32 +++++++++- crypto/asymmetric_keys/restrict.c | 76 +++++++++++++++++++++++ crypto/asymmetric_keys/x509_cert_parser.c | 31 +++++++++ crypto/asymmetric_keys/x509_parser.h | 2 + crypto/asymmetric_keys/x509_public_key.c | 16 +++++ include/crypto/public_key.h | 30 +++++++++ include/keys/system_keyring.h | 12 +++- include/linux/ima.h | 11 ++++ include/linux/key-type.h | 3 + include/linux/key.h | 2 + security/integrity/Kconfig | 11 +++- security/integrity/digsig.c | 12 ++-- security/integrity/ima/Kconfig | 6 +- security/keys/key.c | 13 ++++ 14 files changed, 245 insertions(+), 12 deletions(-) base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476
Comments
On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: > Prior to the introduction of the machine keyring, most distros simply > allowed all keys contained within the platform keyring to be used > for both kernel and module verification. This was done by an out of > tree patch. Some distros took it even further and loaded all these keys > into the secondary trusted keyring. This also allowed the system owner > to add their own key for IMA usage. > > Each distro contains similar documentation on how to sign kernel modules > and enroll the key into the MOK. The process is fairly straightforward. > With the introduction of the machine keyring, the process remains > basically the same, without the need for any out of tree patches. > > The machine keyring allowed distros to eliminate the out of tree patches > for kernel module signing. However, it falls short in allowing the end > user to add their own keys for IMA. Currently the machine keyring can not > be used as another trust anchor for adding keys to the ima keyring, since > CA enforcement does not currently exist. This would expand the current > integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY > Kconfig states that keys may be added to the ima keyrings if the key is > validly signed by a CA cert in the system built-in or secondary trusted > keyring. Currently there is not code that enforces the contents of a > CA cert. Any key in the builtin or secondary keyring can be used. > > To allow IMA to be enabled with the machine keyring, this series introduces > enforcement of key usage in the certificate. This series also applies > this enforcement across all kernel keyrings. > > The machine keyring shares similarities with both the builtin and > secondary keyrings. Similar to the builtin, no keys may be added to the > machine keyring following boot. The secondary keyring allows user > provided keys to be added following boot; however, a previously enrolled > kernel key must vouch for the key before it may be included. The system > owner may include their own keys into the machine keyring prior to boot. > If the end-user is not the system owner, they may not add their own keys > to the machine keyring. > > The machine keyring is only populated when Secure Boot is enabled. A > system owner has the ability to control the entire Secure Boot keychain > (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. > With this control, they may use insert-sys-cert to include their own key > and re-sign their kernel and have it boot. The system owner also has > control to include or exclude MOK keys. This series does not try to > interpret how a system owner has configured their machine. If the system > owner has taken the steps to add their own MOK keys, they will be > included in the machine keyring and used for verification, exactly > the same way as keys contained in the builtin and secondary keyrings. > Since the system owner has the ability to add keys before booting to > either the machine or builtin keyrings, it is viewed as inconsequential > if the key originated from one or the other. > > This series introduces two different ways to configure the machine keyring. > By default, nothing changes and all MOK keys are loaded into it. Whenever > a CA cert is found within the machine, builtin, or secondary, a flag > indicating this is stored in the public key struct. The other option is > if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs > will be loaded into the machine keyring. All remaining MOK keys will be > loaded into the platform keyring. > > A CA cert shall be defined as any X509 certificate that contains the > keyCertSign key usage and has the CA bit set to true. Hi Eric, Allowing CA certificates with the digitalSignature key usage flag enabled defeats the purpose of the new Kconfig. Please update the above definition to exclude the digitalSignature key usage flag and modify the code accordingly. thanks, Mimi > With this series applied, CA enforcement is in place whenever > IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY is enabled. Meaning, > before any key can be included into the ima keyring, it must be > vouched for by a CA key contained within the builtin, secondary, or > machine keyrings. > > IMA allows userspace applications to be signed. The enduser may sign > their own application, however they may also want to use an application > provided by a 3rd party. The entity building the kernel, may not be the > same entity building the userspace program. The system owner may also > be a third entity. If the system owner trusts the entity building the > userspace program, they will include their public key within the MOK. > This key would be used to sign the key added to the ima keyring. Not all > 3rd party userspace providers have the capability to properly manage a > root CA. Some may outsource to a different code signing provider. Many > code signing providers use Intermediate CA certificates. Therefore, this > series also includes support for Intermediate CA certificates. > > This series could be broken up into 3 different parts. The first two > patches could be taken now. They solve current issues that will be > triggered by the build robots. Patches 3-8 add CA enforcement for the > ima keyring. Patches 9-10 restrict the machine keyring to only load CA > certs into it. Patches 9-10 require all the previous patches. > > Changelog: > > v3: > - Allow Intermediate CA certs to be enrolled through the MOK. The > Intermediate CA cert must contain keyCertSign key usage and have the > CA bit set to true. This was done by removing the self signed > requirement. > > > Eric Snowberg (10): > KEYS: Create static version of public_key_verify_signature > KEYS: Add missing function documentation > KEYS: X.509: Parse Basic Constraints for CA > KEYS: X.509: Parse Key Usage > KEYS: Introduce a CA endorsed flag > KEYS: Introduce keyring restriction that validates ca trust > KEYS: X.509: Flag Intermediate CA certs as endorsed > integrity: Use root of trust signature restriction > KEYS: CA link restriction > integrity: restrict INTEGRITY_KEYRING_MACHINE to restrict_link_by_ca > > certs/system_keyring.c | 32 +++++++++- > crypto/asymmetric_keys/restrict.c | 76 +++++++++++++++++++++++ > crypto/asymmetric_keys/x509_cert_parser.c | 31 +++++++++ > crypto/asymmetric_keys/x509_parser.h | 2 + > crypto/asymmetric_keys/x509_public_key.c | 16 +++++ > include/crypto/public_key.h | 30 +++++++++ > include/keys/system_keyring.h | 12 +++- > include/linux/ima.h | 11 ++++ > include/linux/key-type.h | 3 + > include/linux/key.h | 2 + > security/integrity/Kconfig | 11 +++- > security/integrity/digsig.c | 12 ++-- > security/integrity/ima/Kconfig | 6 +- > security/keys/key.c | 13 ++++ > 14 files changed, 245 insertions(+), 12 deletions(-) > > > base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476
> On Dec 15, 2022, at 3:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: >> Prior to the introduction of the machine keyring, most distros simply >> allowed all keys contained within the platform keyring to be used >> for both kernel and module verification. This was done by an out of >> tree patch. Some distros took it even further and loaded all these keys >> into the secondary trusted keyring. This also allowed the system owner >> to add their own key for IMA usage. >> >> Each distro contains similar documentation on how to sign kernel modules >> and enroll the key into the MOK. The process is fairly straightforward. >> With the introduction of the machine keyring, the process remains >> basically the same, without the need for any out of tree patches. >> >> The machine keyring allowed distros to eliminate the out of tree patches >> for kernel module signing. However, it falls short in allowing the end >> user to add their own keys for IMA. Currently the machine keyring can not >> be used as another trust anchor for adding keys to the ima keyring, since >> CA enforcement does not currently exist. This would expand the current >> integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY >> Kconfig states that keys may be added to the ima keyrings if the key is >> validly signed by a CA cert in the system built-in or secondary trusted >> keyring. Currently there is not code that enforces the contents of a >> CA cert. Any key in the builtin or secondary keyring can be used. >> >> To allow IMA to be enabled with the machine keyring, this series introduces >> enforcement of key usage in the certificate. This series also applies >> this enforcement across all kernel keyrings. >> >> The machine keyring shares similarities with both the builtin and >> secondary keyrings. Similar to the builtin, no keys may be added to the >> machine keyring following boot. The secondary keyring allows user >> provided keys to be added following boot; however, a previously enrolled >> kernel key must vouch for the key before it may be included. The system >> owner may include their own keys into the machine keyring prior to boot. >> If the end-user is not the system owner, they may not add their own keys >> to the machine keyring. >> >> The machine keyring is only populated when Secure Boot is enabled. A >> system owner has the ability to control the entire Secure Boot keychain >> (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. >> With this control, they may use insert-sys-cert to include their own key >> and re-sign their kernel and have it boot. The system owner also has >> control to include or exclude MOK keys. This series does not try to >> interpret how a system owner has configured their machine. If the system >> owner has taken the steps to add their own MOK keys, they will be >> included in the machine keyring and used for verification, exactly >> the same way as keys contained in the builtin and secondary keyrings. >> Since the system owner has the ability to add keys before booting to >> either the machine or builtin keyrings, it is viewed as inconsequential >> if the key originated from one or the other. >> >> This series introduces two different ways to configure the machine keyring. >> By default, nothing changes and all MOK keys are loaded into it. Whenever >> a CA cert is found within the machine, builtin, or secondary, a flag >> indicating this is stored in the public key struct. The other option is >> if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs >> will be loaded into the machine keyring. All remaining MOK keys will be >> loaded into the platform keyring. >> >> A CA cert shall be defined as any X509 certificate that contains the >> keyCertSign key usage and has the CA bit set to true. > > Hi Eric, > > Allowing CA certificates with the digitalSignature key usage flag > enabled defeats the purpose of the new Kconfig. Please update the > above definition to exclude the digitalSignature key usage flag and > modify the code accordingly. Within v2, the request was made to allow Intermediate CA certificates to be loaded directly. The Intermediate CA referenced was the one used by kernel.org. This Intermediate CA contains both digitalSignature and keyCertSign. If the code is changed to exclude this certificate, now the root CA has to be loaded again. Is that the intent?
On Thu, 2022-12-15 at 16:26 +0000, Eric Snowberg wrote: > > > On Dec 15, 2022, at 3:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > > > On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: > >> Prior to the introduction of the machine keyring, most distros simply > >> allowed all keys contained within the platform keyring to be used > >> for both kernel and module verification. This was done by an out of > >> tree patch. Some distros took it even further and loaded all these keys > >> into the secondary trusted keyring. This also allowed the system owner > >> to add their own key for IMA usage. > >> > >> Each distro contains similar documentation on how to sign kernel modules > >> and enroll the key into the MOK. The process is fairly straightforward. > >> With the introduction of the machine keyring, the process remains > >> basically the same, without the need for any out of tree patches. > >> > >> The machine keyring allowed distros to eliminate the out of tree patches > >> for kernel module signing. However, it falls short in allowing the end > >> user to add their own keys for IMA. Currently the machine keyring can not > >> be used as another trust anchor for adding keys to the ima keyring, since > >> CA enforcement does not currently exist. This would expand the current > >> integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY > >> Kconfig states that keys may be added to the ima keyrings if the key is > >> validly signed by a CA cert in the system built-in or secondary trusted > >> keyring. Currently there is not code that enforces the contents of a > >> CA cert. Any key in the builtin or secondary keyring can be used. > >> > >> To allow IMA to be enabled with the machine keyring, this series introduces > >> enforcement of key usage in the certificate. This series also applies > >> this enforcement across all kernel keyrings. > >> > >> The machine keyring shares similarities with both the builtin and > >> secondary keyrings. Similar to the builtin, no keys may be added to the > >> machine keyring following boot. The secondary keyring allows user > >> provided keys to be added following boot; however, a previously enrolled > >> kernel key must vouch for the key before it may be included. The system > >> owner may include their own keys into the machine keyring prior to boot. > >> If the end-user is not the system owner, they may not add their own keys > >> to the machine keyring. > >> > >> The machine keyring is only populated when Secure Boot is enabled. A > >> system owner has the ability to control the entire Secure Boot keychain > >> (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. > >> With this control, they may use insert-sys-cert to include their own key > >> and re-sign their kernel and have it boot. The system owner also has > >> control to include or exclude MOK keys. This series does not try to > >> interpret how a system owner has configured their machine. If the system > >> owner has taken the steps to add their own MOK keys, they will be > >> included in the machine keyring and used for verification, exactly > >> the same way as keys contained in the builtin and secondary keyrings. > >> Since the system owner has the ability to add keys before booting to > >> either the machine or builtin keyrings, it is viewed as inconsequential > >> if the key originated from one or the other. > >> > >> This series introduces two different ways to configure the machine keyring. > >> By default, nothing changes and all MOK keys are loaded into it. Whenever > >> a CA cert is found within the machine, builtin, or secondary, a flag > >> indicating this is stored in the public key struct. The other option is > >> if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs > >> will be loaded into the machine keyring. All remaining MOK keys will be > >> loaded into the platform keyring. > >> > >> A CA cert shall be defined as any X509 certificate that contains the > >> keyCertSign key usage and has the CA bit set to true. > > > > Hi Eric, > > > > Allowing CA certificates with the digitalSignature key usage flag > > enabled defeats the purpose of the new Kconfig. Please update the > > above definition to exclude the digitalSignature key usage flag and > > modify the code accordingly. > > Within v2, the request was made to allow Intermediate CA certificates to be > loaded directly. The Intermediate CA referenced was the one used by kernel.org. > This Intermediate CA contains both digitalSignature and keyCertSign. If the code > is changed to exclude this certificate, now the root CA has to be loaded again. Is that > the intent? That definitely was not the intent. Nor would it address the issue of a particular intermediate CA certificate having both keyCertSign and digitalSignature. thanks, Mimi
> On Dec 15, 2022, at 12:58 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Thu, 2022-12-15 at 16:26 +0000, Eric Snowberg wrote: >> >>> On Dec 15, 2022, at 3:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>> >>> On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: >>>> Prior to the introduction of the machine keyring, most distros simply >>>> allowed all keys contained within the platform keyring to be used >>>> for both kernel and module verification. This was done by an out of >>>> tree patch. Some distros took it even further and loaded all these keys >>>> into the secondary trusted keyring. This also allowed the system owner >>>> to add their own key for IMA usage. >>>> >>>> Each distro contains similar documentation on how to sign kernel modules >>>> and enroll the key into the MOK. The process is fairly straightforward. >>>> With the introduction of the machine keyring, the process remains >>>> basically the same, without the need for any out of tree patches. >>>> >>>> The machine keyring allowed distros to eliminate the out of tree patches >>>> for kernel module signing. However, it falls short in allowing the end >>>> user to add their own keys for IMA. Currently the machine keyring can not >>>> be used as another trust anchor for adding keys to the ima keyring, since >>>> CA enforcement does not currently exist. This would expand the current >>>> integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY >>>> Kconfig states that keys may be added to the ima keyrings if the key is >>>> validly signed by a CA cert in the system built-in or secondary trusted >>>> keyring. Currently there is not code that enforces the contents of a >>>> CA cert. Any key in the builtin or secondary keyring can be used. >>>> >>>> To allow IMA to be enabled with the machine keyring, this series introduces >>>> enforcement of key usage in the certificate. This series also applies >>>> this enforcement across all kernel keyrings. >>>> >>>> The machine keyring shares similarities with both the builtin and >>>> secondary keyrings. Similar to the builtin, no keys may be added to the >>>> machine keyring following boot. The secondary keyring allows user >>>> provided keys to be added following boot; however, a previously enrolled >>>> kernel key must vouch for the key before it may be included. The system >>>> owner may include their own keys into the machine keyring prior to boot. >>>> If the end-user is not the system owner, they may not add their own keys >>>> to the machine keyring. >>>> >>>> The machine keyring is only populated when Secure Boot is enabled. A >>>> system owner has the ability to control the entire Secure Boot keychain >>>> (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. >>>> With this control, they may use insert-sys-cert to include their own key >>>> and re-sign their kernel and have it boot. The system owner also has >>>> control to include or exclude MOK keys. This series does not try to >>>> interpret how a system owner has configured their machine. If the system >>>> owner has taken the steps to add their own MOK keys, they will be >>>> included in the machine keyring and used for verification, exactly >>>> the same way as keys contained in the builtin and secondary keyrings. >>>> Since the system owner has the ability to add keys before booting to >>>> either the machine or builtin keyrings, it is viewed as inconsequential >>>> if the key originated from one or the other. >>>> >>>> This series introduces two different ways to configure the machine keyring. >>>> By default, nothing changes and all MOK keys are loaded into it. Whenever >>>> a CA cert is found within the machine, builtin, or secondary, a flag >>>> indicating this is stored in the public key struct. The other option is >>>> if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs >>>> will be loaded into the machine keyring. All remaining MOK keys will be >>>> loaded into the platform keyring. >>>> >>>> A CA cert shall be defined as any X509 certificate that contains the >>>> keyCertSign key usage and has the CA bit set to true. >>> >>> Hi Eric, >>> >>> Allowing CA certificates with the digitalSignature key usage flag >>> enabled defeats the purpose of the new Kconfig. Please update the >>> above definition to exclude the digitalSignature key usage flag and >>> modify the code accordingly. >> >> Within v2, the request was made to allow Intermediate CA certificates to be >> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >> the intent? > > That definitely was not the intent. Nor would it address the issue of > a particular intermediate CA certificate having both keyCertSign and > digitalSignature. Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate CA cert like the one used on kernel.org?
On Thu, 2022-12-15 at 20:28 +0000, Eric Snowberg wrote: > > > On Dec 15, 2022, at 12:58 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > > > On Thu, 2022-12-15 at 16:26 +0000, Eric Snowberg wrote: > >> > >>> On Dec 15, 2022, at 3:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > >>> > >>> On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: > >>>> Prior to the introduction of the machine keyring, most distros simply > >>>> allowed all keys contained within the platform keyring to be used > >>>> for both kernel and module verification. This was done by an out of > >>>> tree patch. Some distros took it even further and loaded all these keys > >>>> into the secondary trusted keyring. This also allowed the system owner > >>>> to add their own key for IMA usage. > >>>> > >>>> Each distro contains similar documentation on how to sign kernel modules > >>>> and enroll the key into the MOK. The process is fairly straightforward. > >>>> With the introduction of the machine keyring, the process remains > >>>> basically the same, without the need for any out of tree patches. > >>>> > >>>> The machine keyring allowed distros to eliminate the out of tree patches > >>>> for kernel module signing. However, it falls short in allowing the end > >>>> user to add their own keys for IMA. Currently the machine keyring can not > >>>> be used as another trust anchor for adding keys to the ima keyring, since > >>>> CA enforcement does not currently exist. This would expand the current > >>>> integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY > >>>> Kconfig states that keys may be added to the ima keyrings if the key is > >>>> validly signed by a CA cert in the system built-in or secondary trusted > >>>> keyring. Currently there is not code that enforces the contents of a > >>>> CA cert. Any key in the builtin or secondary keyring can be used. > >>>> > >>>> To allow IMA to be enabled with the machine keyring, this series introduces > >>>> enforcement of key usage in the certificate. This series also applies > >>>> this enforcement across all kernel keyrings. > >>>> > >>>> The machine keyring shares similarities with both the builtin and > >>>> secondary keyrings. Similar to the builtin, no keys may be added to the > >>>> machine keyring following boot. The secondary keyring allows user > >>>> provided keys to be added following boot; however, a previously enrolled > >>>> kernel key must vouch for the key before it may be included. The system > >>>> owner may include their own keys into the machine keyring prior to boot. > >>>> If the end-user is not the system owner, they may not add their own keys > >>>> to the machine keyring. > >>>> > >>>> The machine keyring is only populated when Secure Boot is enabled. A > >>>> system owner has the ability to control the entire Secure Boot keychain > >>>> (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. > >>>> With this control, they may use insert-sys-cert to include their own key > >>>> and re-sign their kernel and have it boot. The system owner also has > >>>> control to include or exclude MOK keys. This series does not try to > >>>> interpret how a system owner has configured their machine. If the system > >>>> owner has taken the steps to add their own MOK keys, they will be > >>>> included in the machine keyring and used for verification, exactly > >>>> the same way as keys contained in the builtin and secondary keyrings. > >>>> Since the system owner has the ability to add keys before booting to > >>>> either the machine or builtin keyrings, it is viewed as inconsequential > >>>> if the key originated from one or the other. > >>>> > >>>> This series introduces two different ways to configure the machine keyring. > >>>> By default, nothing changes and all MOK keys are loaded into it. Whenever > >>>> a CA cert is found within the machine, builtin, or secondary, a flag > >>>> indicating this is stored in the public key struct. The other option is > >>>> if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs > >>>> will be loaded into the machine keyring. All remaining MOK keys will be > >>>> loaded into the platform keyring. > >>>> > >>>> A CA cert shall be defined as any X509 certificate that contains the > >>>> keyCertSign key usage and has the CA bit set to true. > >>> > >>> Hi Eric, > >>> > >>> Allowing CA certificates with the digitalSignature key usage flag > >>> enabled defeats the purpose of the new Kconfig. Please update the > >>> above definition to exclude the digitalSignature key usage flag and > >>> modify the code accordingly. > >> > >> Within v2, the request was made to allow Intermediate CA certificates to be > >> loaded directly. The Intermediate CA referenced was the one used by kernel.org. > >> This Intermediate CA contains both digitalSignature and keyCertSign. If the code > >> is changed to exclude this certificate, now the root CA has to be loaded again. Is that > >> the intent? > > > > That definitely was not the intent. Nor would it address the issue of > > a particular intermediate CA certificate having both keyCertSign and > > digitalSignature. > > Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains > both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate > CA cert like the one used on kernel.org? I must be missing something. Isn't the purpose of "keyUsage" to minimize how a certificate may be used? Why would we want the same certificate to be used for both certificate signing and code signing? thanks, Mimi
> On Dec 15, 2022, at 2:03 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Thu, 2022-12-15 at 20:28 +0000, Eric Snowberg wrote: >> >>> On Dec 15, 2022, at 12:58 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>> >>> On Thu, 2022-12-15 at 16:26 +0000, Eric Snowberg wrote: >>>> >>>>> On Dec 15, 2022, at 3:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>>>> >>>>> On Tue, 2022-12-13 at 19:33 -0500, Eric Snowberg wrote: >>>>>> Prior to the introduction of the machine keyring, most distros simply >>>>>> allowed all keys contained within the platform keyring to be used >>>>>> for both kernel and module verification. This was done by an out of >>>>>> tree patch. Some distros took it even further and loaded all these keys >>>>>> into the secondary trusted keyring. This also allowed the system owner >>>>>> to add their own key for IMA usage. >>>>>> >>>>>> Each distro contains similar documentation on how to sign kernel modules >>>>>> and enroll the key into the MOK. The process is fairly straightforward. >>>>>> With the introduction of the machine keyring, the process remains >>>>>> basically the same, without the need for any out of tree patches. >>>>>> >>>>>> The machine keyring allowed distros to eliminate the out of tree patches >>>>>> for kernel module signing. However, it falls short in allowing the end >>>>>> user to add their own keys for IMA. Currently the machine keyring can not >>>>>> be used as another trust anchor for adding keys to the ima keyring, since >>>>>> CA enforcement does not currently exist. This would expand the current >>>>>> integrity gap. The IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY >>>>>> Kconfig states that keys may be added to the ima keyrings if the key is >>>>>> validly signed by a CA cert in the system built-in or secondary trusted >>>>>> keyring. Currently there is not code that enforces the contents of a >>>>>> CA cert. Any key in the builtin or secondary keyring can be used. >>>>>> >>>>>> To allow IMA to be enabled with the machine keyring, this series introduces >>>>>> enforcement of key usage in the certificate. This series also applies >>>>>> this enforcement across all kernel keyrings. >>>>>> >>>>>> The machine keyring shares similarities with both the builtin and >>>>>> secondary keyrings. Similar to the builtin, no keys may be added to the >>>>>> machine keyring following boot. The secondary keyring allows user >>>>>> provided keys to be added following boot; however, a previously enrolled >>>>>> kernel key must vouch for the key before it may be included. The system >>>>>> owner may include their own keys into the machine keyring prior to boot. >>>>>> If the end-user is not the system owner, they may not add their own keys >>>>>> to the machine keyring. >>>>>> >>>>>> The machine keyring is only populated when Secure Boot is enabled. A >>>>>> system owner has the ability to control the entire Secure Boot keychain >>>>>> (PK, KEK, DB, and DBX). The system owner can also turn Secure Boot off. >>>>>> With this control, they may use insert-sys-cert to include their own key >>>>>> and re-sign their kernel and have it boot. The system owner also has >>>>>> control to include or exclude MOK keys. This series does not try to >>>>>> interpret how a system owner has configured their machine. If the system >>>>>> owner has taken the steps to add their own MOK keys, they will be >>>>>> included in the machine keyring and used for verification, exactly >>>>>> the same way as keys contained in the builtin and secondary keyrings. >>>>>> Since the system owner has the ability to add keys before booting to >>>>>> either the machine or builtin keyrings, it is viewed as inconsequential >>>>>> if the key originated from one or the other. >>>>>> >>>>>> This series introduces two different ways to configure the machine keyring. >>>>>> By default, nothing changes and all MOK keys are loaded into it. Whenever >>>>>> a CA cert is found within the machine, builtin, or secondary, a flag >>>>>> indicating this is stored in the public key struct. The other option is >>>>>> if the new Kconfig INTEGRITY_CA_MACHINE_KEYRING is enabled, only CA certs >>>>>> will be loaded into the machine keyring. All remaining MOK keys will be >>>>>> loaded into the platform keyring. >>>>>> >>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>> keyCertSign key usage and has the CA bit set to true. >>>>> >>>>> Hi Eric, >>>>> >>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>> above definition to exclude the digitalSignature key usage flag and >>>>> modify the code accordingly. >>>> >>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>> the intent? >>> >>> That definitely was not the intent. Nor would it address the issue of >>> a particular intermediate CA certificate having both keyCertSign and >>> digitalSignature. >> >> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >> CA cert like the one used on kernel.org? > > I must be missing something. Isn't the purpose of "keyUsage" to > minimize how a certificate may be used? Why would we want the same > certificate to be used for both certificate signing and code signing? Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be challenging and will severely limit usage.
Hi Eric and Mimi, On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: > > >>>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>>> keyCertSign key usage and has the CA bit set to true. >>>>>> >>>>>> Hi Eric, >>>>>> >>>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>>> above definition to exclude the digitalSignature key usage flag and >>>>>> modify the code accordingly. >>>>> >>>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>>> the intent? >>>> >>>> That definitely was not the intent. Nor would it address the issue of >>>> a particular intermediate CA certificate having both keyCertSign and >>>> digitalSignature. >>> >>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >>> CA cert like the one used on kernel.org? >> >> I must be missing something. Isn't the purpose of "keyUsage" to >> minimize how a certificate may be used? Why would we want the same >> certificate to be used for both certificate signing and code signing? > >Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. >Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature >set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be >challenging and will severely limit usage. How about allowing both keyCertSign and digitalSignature asserted but issuing a warning for this case? Here's my rationale for this proposal. I assume we should conform to some X.509 specifications. So I checked "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) [2]. [1] states in 4.2.1.3. Key Usage, "If the keyUsage extension is present, then the subject public key MUST NOT be used to verify signatures on certificates or CRLs unless the corresponding keyCertSign or cRLSign bit is set. If the subject public key is only to be used for verifying signatures on certificates and/or CRLs, then the digitalSignature and nonRepudiation bits SHOULD NOT be set. However, the digitalSignature and/or nonRepudiation bits MAY be set in addition to the keyCertSign and/or cRLSign bits if the subject public key is to be used to verify signatures on certificates and/or CRLs as well as other objects." and [2] states in 8.2.2.3 Key usage extension that, "More than one bit may be set in an instance of the keyUsage extension. The setting of multiple bits shall not change the meaning of each individual bit but shall indicate that the certificate may be used for all of the purposes indicated by the set bits. There may be risks incurred when setting multiple bits. A review of those risks is documented in Annex I." I interpret the above texts as we should allow both keyCertSign and digitalSignature. However [2] warns about the risks of setting multiple bits. Quoting Annex I, "Combining the contentCommitment bit in the keyUsage certificate extension with other keyUsage bits may have security implications depending on the security environment in which the certificate is to be used. If the subject's environment can be fully controlled and trusted, then there are no specific security implications. For example, in cases where the subject is fully confident about exactly which data is signed or cases where the subject is fully confident about the security characteristics of the authentication protocol being used. If the subject's environment is not fully controlled or not fully trusted, then unintentional signing of commitments is possible. Examples include the use of badly formed authentication exchanges and the use of a rogue software component. If untrusted environments are used by a subject, these security implications can be limited through use of the following measures: – to not combine the contentCommitment key usage setting in certificates with any other key usage setting and to use the corresponding private key only with this certificate; – to limit the use of private keys associated with certificates that have the contentCommitment key usage bit set, to environments which are considered adequately controlled and trustworthy" So maybe it's useful to add a warning if both keyCertSign and digitalSignature are asserted.
On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: > Hi Eric and Mimi, > > On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: > > > > > >>>>>>> A CA cert shall be defined as any X509 certificate that contains the > >>>>>>> keyCertSign key usage and has the CA bit set to true. > >>>>>> > >>>>>> Hi Eric, > >>>>>> > >>>>>> Allowing CA certificates with the digitalSignature key usage flag > >>>>>> enabled defeats the purpose of the new Kconfig. Please update the > >>>>>> above definition to exclude the digitalSignature key usage flag and > >>>>>> modify the code accordingly. > >>>>> > >>>>> Within v2, the request was made to allow Intermediate CA certificates to be > >>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. > >>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code > >>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that > >>>>> the intent? > >>>> > >>>> That definitely was not the intent. Nor would it address the issue of > >>>> a particular intermediate CA certificate having both keyCertSign and > >>>> digitalSignature. > >>> > >>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains > >>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate > >>> CA cert like the one used on kernel.org? > >> > >> I must be missing something. Isn't the purpose of "keyUsage" to > >> minimize how a certificate may be used? Why would we want the same > >> certificate to be used for both certificate signing and code signing? > > > >Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. > >Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature > >set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be > >challenging and will severely limit usage. > > How about allowing both keyCertSign and digitalSignature asserted but > issuing a warning for this case? > > Here's my rationale for this proposal. > > I assume we should conform to some X.509 specifications. So I checked > "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and > Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) > [2]. > > [1] states in 4.2.1.3. Key Usage, > "If the keyUsage extension is present, then the subject public key > MUST NOT be used to verify signatures on certificates or CRLs unless > the corresponding keyCertSign or cRLSign bit is set. If the subject > public key is only to be used for verifying signatures on > certificates and/or CRLs, then the digitalSignature and > nonRepudiation bits SHOULD NOT be set. However, the digitalSignature > and/or nonRepudiation bits MAY be set in addition to the keyCertSign > and/or cRLSign bits if the subject public key is to be used to verify > signatures on certificates and/or CRLs as well as other objects." > > and [2] states in 8.2.2.3 Key usage extension that, > "More than one bit may be set in an instance of the keyUsage extension. > The setting of multiple bits shall not change the meaning of each > individual bit but shall indicate that the certificate may be used for > all of the purposes indicated by the set bits. There may be risks > incurred when setting multiple bits. A review of those risks is > documented in Annex I." > > I interpret the above texts as we should allow both keyCertSign and > digitalSignature. However [2] warns about the risks of setting multiple > bits. Quoting Annex I, > > "Combining the contentCommitment bit in the keyUsage certificate > extension with other keyUsage bits may have security implications > depending on the security environment in which the certificate is to be > used. If the subject's environment can be fully controlled and trusted, > then there are no specific security implications. For example, in cases > where the subject is fully confident about exactly which data is signed > or cases where the subject is fully confident about the security > characteristics of the authentication protocol being used. If the > subject's environment is not fully controlled or not fully trusted, then > unintentional signing of commitments is possible. Examples include the > use of badly formed authentication exchanges and the use of a rogue > software component. If untrusted environments are used by a subject, > these security implications can be limited through use of the following > measures: > – to not combine the contentCommitment key usage setting in > certificates with any other key usage setting and to use the > corresponding private key only with this certificate; > > – to limit the use of private keys associated with certificates that > have the contentCommitment key usage bit set, to environments which > are considered adequately controlled and trustworthy" > > So maybe it's useful to add a warning if both keyCertSign and > digitalSignature are asserted. Coiby, thank you for adding these details. I was hoping others would chime in as well. I agree at minimum there should be a warning. Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the more restrictive certificate use case requirements: all certificates, CA certificate signing and digital signature, only CA certificate signing.
> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: >> Hi Eric and Mimi, >> >> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: >>> >>> >>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>>>>> keyCertSign key usage and has the CA bit set to true. >>>>>>>> >>>>>>>> Hi Eric, >>>>>>>> >>>>>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>>>>> above definition to exclude the digitalSignature key usage flag and >>>>>>>> modify the code accordingly. >>>>>>> >>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>>>>> the intent? >>>>>> >>>>>> That definitely was not the intent. Nor would it address the issue of >>>>>> a particular intermediate CA certificate having both keyCertSign and >>>>>> digitalSignature. >>>>> >>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >>>>> CA cert like the one used on kernel.org? >>>> >>>> I must be missing something. Isn't the purpose of "keyUsage" to >>>> minimize how a certificate may be used? Why would we want the same >>>> certificate to be used for both certificate signing and code signing? >>> >>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. >>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature >>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be >>> challenging and will severely limit usage. >> >> How about allowing both keyCertSign and digitalSignature asserted but >> issuing a warning for this case? >> >> Here's my rationale for this proposal. >> >> I assume we should conform to some X.509 specifications. So I checked >> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and >> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) >> [2]. >> >> [1] states in 4.2.1.3. Key Usage, >> "If the keyUsage extension is present, then the subject public key >> MUST NOT be used to verify signatures on certificates or CRLs unless >> the corresponding keyCertSign or cRLSign bit is set. If the subject >> public key is only to be used for verifying signatures on >> certificates and/or CRLs, then the digitalSignature and >> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature >> and/or nonRepudiation bits MAY be set in addition to the keyCertSign >> and/or cRLSign bits if the subject public key is to be used to verify >> signatures on certificates and/or CRLs as well as other objects." >> >> and [2] states in 8.2.2.3 Key usage extension that, >> "More than one bit may be set in an instance of the keyUsage extension. >> The setting of multiple bits shall not change the meaning of each >> individual bit but shall indicate that the certificate may be used for >> all of the purposes indicated by the set bits. There may be risks >> incurred when setting multiple bits. A review of those risks is >> documented in Annex I." >> >> I interpret the above texts as we should allow both keyCertSign and >> digitalSignature. However [2] warns about the risks of setting multiple >> bits. Quoting Annex I, >> >> "Combining the contentCommitment bit in the keyUsage certificate >> extension with other keyUsage bits may have security implications >> depending on the security environment in which the certificate is to be >> used. If the subject's environment can be fully controlled and trusted, >> then there are no specific security implications. For example, in cases >> where the subject is fully confident about exactly which data is signed >> or cases where the subject is fully confident about the security >> characteristics of the authentication protocol being used. If the >> subject's environment is not fully controlled or not fully trusted, then >> unintentional signing of commitments is possible. Examples include the >> use of badly formed authentication exchanges and the use of a rogue >> software component. If untrusted environments are used by a subject, >> these security implications can be limited through use of the following >> measures: >> – to not combine the contentCommitment key usage setting in >> certificates with any other key usage setting and to use the >> corresponding private key only with this certificate; >> >> – to limit the use of private keys associated with certificates that >> have the contentCommitment key usage bit set, to environments which >> are considered adequately controlled and trustworthy" >> >> So maybe it's useful to add a warning if both keyCertSign and >> digitalSignature are asserted. > > Coiby, thank you for adding these details. I was hoping others would > chime in as well. I agree at minimum there should be a warning. A warning could be added. > Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on > INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the > more restrictive certificate use case requirements: all certificates, > CA certificate signing and digital signature, only CA certificate > signing. As could support for additional restrictions. Would these additions be required within this series? What is missing from this discussion is why would these additions be necessary? Why should the kernel enforce a restriction that is beyond the scope of the X.509 spec? If a warning was to be added, what would be the justification for adding this additional code? From my research every single 3rd party code signing intermediate CA would be flagged with the warning. Isn’t this just going to cause confusion? Or is there a benefit that I am missing that needs to be stated?
On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: > > > On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > > > On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: > >> Hi Eric and Mimi, > >> > >> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: > >>> > >>> > >>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the > >>>>>>>>> keyCertSign key usage and has the CA bit set to true. > >>>>>>>> > >>>>>>>> Hi Eric, > >>>>>>>> > >>>>>>>> Allowing CA certificates with the digitalSignature key usage flag > >>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the > >>>>>>>> above definition to exclude the digitalSignature key usage flag and > >>>>>>>> modify the code accordingly. > >>>>>>> > >>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be > >>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. > >>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code > >>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that > >>>>>>> the intent? > >>>>>> > >>>>>> That definitely was not the intent. Nor would it address the issue of > >>>>>> a particular intermediate CA certificate having both keyCertSign and > >>>>>> digitalSignature. > >>>>> > >>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains > >>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate > >>>>> CA cert like the one used on kernel.org? > >>>> > >>>> I must be missing something. Isn't the purpose of "keyUsage" to > >>>> minimize how a certificate may be used? Why would we want the same > >>>> certificate to be used for both certificate signing and code signing? > >>> > >>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. > >>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature > >>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be > >>> challenging and will severely limit usage. > >> > >> How about allowing both keyCertSign and digitalSignature asserted but > >> issuing a warning for this case? > >> > >> Here's my rationale for this proposal. > >> > >> I assume we should conform to some X.509 specifications. So I checked > >> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and > >> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) > >> [2]. > >> > >> [1] states in 4.2.1.3. Key Usage, > >> "If the keyUsage extension is present, then the subject public key > >> MUST NOT be used to verify signatures on certificates or CRLs unless > >> the corresponding keyCertSign or cRLSign bit is set. If the subject > >> public key is only to be used for verifying signatures on > >> certificates and/or CRLs, then the digitalSignature and > >> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature > >> and/or nonRepudiation bits MAY be set in addition to the keyCertSign > >> and/or cRLSign bits if the subject public key is to be used to verify > >> signatures on certificates and/or CRLs as well as other objects." > >> > >> and [2] states in 8.2.2.3 Key usage extension that, > >> "More than one bit may be set in an instance of the keyUsage extension. > >> The setting of multiple bits shall not change the meaning of each > >> individual bit but shall indicate that the certificate may be used for > >> all of the purposes indicated by the set bits. There may be risks > >> incurred when setting multiple bits. A review of those risks is > >> documented in Annex I." > >> > >> I interpret the above texts as we should allow both keyCertSign and > >> digitalSignature. However [2] warns about the risks of setting multiple > >> bits. Quoting Annex I, > >> > >> "Combining the contentCommitment bit in the keyUsage certificate > >> extension with other keyUsage bits may have security implications > >> depending on the security environment in which the certificate is to be > >> used. If the subject's environment can be fully controlled and trusted, > >> then there are no specific security implications. For example, in cases > >> where the subject is fully confident about exactly which data is signed > >> or cases where the subject is fully confident about the security > >> characteristics of the authentication protocol being used. If the > >> subject's environment is not fully controlled or not fully trusted, then > >> unintentional signing of commitments is possible. Examples include the > >> use of badly formed authentication exchanges and the use of a rogue > >> software component. If untrusted environments are used by a subject, > >> these security implications can be limited through use of the following > >> measures: > >> – to not combine the contentCommitment key usage setting in > >> certificates with any other key usage setting and to use the > >> corresponding private key only with this certificate; > >> > >> – to limit the use of private keys associated with certificates that > >> have the contentCommitment key usage bit set, to environments which > >> are considered adequately controlled and trustworthy" > >> > >> So maybe it's useful to add a warning if both keyCertSign and > >> digitalSignature are asserted. > > > > Coiby, thank you for adding these details. I was hoping others would > > chime in as well. I agree at minimum there should be a warning. > > A warning could be added. > > > Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on > > INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the > > more restrictive certificate use case requirements: all certificates, > > CA certificate signing and digital signature, only CA certificate > > signing. > > As could support for additional restrictions. > > Would these additions be required within this series? What is missing from this > discussion is why would these additions be necessary? Why should the kernel > enforce a restriction that is beyond the scope of the X.509 spec? If a warning was > to be added, what would be the justification for adding this additional code? From > my research every single 3rd party code signing intermediate CA would be flagged > with the warning. Isn’t this just going to cause confusion? Or is there a benefit that > I am missing that needs to be stated? You're focusing on third party kernel modules and forgetting about the simple use case of allowing an end user (or business) to sign their own code. True they could use the less restrictive CA certificates, but it is unnecessary.
> On Dec 21, 2022, at 12:01 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: >> >>> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>> >>> On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: >>>> Hi Eric and Mimi, >>>> >>>> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: >>>>> >>>>> >>>>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>>>>>>> keyCertSign key usage and has the CA bit set to true. >>>>>>>>>> >>>>>>>>>> Hi Eric, >>>>>>>>>> >>>>>>>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>>>>>>> above definition to exclude the digitalSignature key usage flag and >>>>>>>>>> modify the code accordingly. >>>>>>>>> >>>>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>>>>>>> the intent? >>>>>>>> >>>>>>>> That definitely was not the intent. Nor would it address the issue of >>>>>>>> a particular intermediate CA certificate having both keyCertSign and >>>>>>>> digitalSignature. >>>>>>> >>>>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >>>>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >>>>>>> CA cert like the one used on kernel.org? >>>>>> >>>>>> I must be missing something. Isn't the purpose of "keyUsage" to >>>>>> minimize how a certificate may be used? Why would we want the same >>>>>> certificate to be used for both certificate signing and code signing? >>>>> >>>>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. >>>>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature >>>>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be >>>>> challenging and will severely limit usage. >>>> >>>> How about allowing both keyCertSign and digitalSignature asserted but >>>> issuing a warning for this case? >>>> >>>> Here's my rationale for this proposal. >>>> >>>> I assume we should conform to some X.509 specifications. So I checked >>>> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and >>>> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) >>>> [2]. >>>> >>>> [1] states in 4.2.1.3. Key Usage, >>>> "If the keyUsage extension is present, then the subject public key >>>> MUST NOT be used to verify signatures on certificates or CRLs unless >>>> the corresponding keyCertSign or cRLSign bit is set. If the subject >>>> public key is only to be used for verifying signatures on >>>> certificates and/or CRLs, then the digitalSignature and >>>> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature >>>> and/or nonRepudiation bits MAY be set in addition to the keyCertSign >>>> and/or cRLSign bits if the subject public key is to be used to verify >>>> signatures on certificates and/or CRLs as well as other objects." >>>> >>>> and [2] states in 8.2.2.3 Key usage extension that, >>>> "More than one bit may be set in an instance of the keyUsage extension. >>>> The setting of multiple bits shall not change the meaning of each >>>> individual bit but shall indicate that the certificate may be used for >>>> all of the purposes indicated by the set bits. There may be risks >>>> incurred when setting multiple bits. A review of those risks is >>>> documented in Annex I." >>>> >>>> I interpret the above texts as we should allow both keyCertSign and >>>> digitalSignature. However [2] warns about the risks of setting multiple >>>> bits. Quoting Annex I, >>>> >>>> "Combining the contentCommitment bit in the keyUsage certificate >>>> extension with other keyUsage bits may have security implications >>>> depending on the security environment in which the certificate is to be >>>> used. If the subject's environment can be fully controlled and trusted, >>>> then there are no specific security implications. For example, in cases >>>> where the subject is fully confident about exactly which data is signed >>>> or cases where the subject is fully confident about the security >>>> characteristics of the authentication protocol being used. If the >>>> subject's environment is not fully controlled or not fully trusted, then >>>> unintentional signing of commitments is possible. Examples include the >>>> use of badly formed authentication exchanges and the use of a rogue >>>> software component. If untrusted environments are used by a subject, >>>> these security implications can be limited through use of the following >>>> measures: >>>> – to not combine the contentCommitment key usage setting in >>>> certificates with any other key usage setting and to use the >>>> corresponding private key only with this certificate; >>>> >>>> – to limit the use of private keys associated with certificates that >>>> have the contentCommitment key usage bit set, to environments which >>>> are considered adequately controlled and trustworthy" >>>> >>>> So maybe it's useful to add a warning if both keyCertSign and >>>> digitalSignature are asserted. >>> >>> Coiby, thank you for adding these details. I was hoping others would >>> chime in as well. I agree at minimum there should be a warning. >> >> A warning could be added. >> >>> Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on >>> INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the >>> more restrictive certificate use case requirements: all certificates, >>> CA certificate signing and digital signature, only CA certificate >>> signing. >> >> As could support for additional restrictions. >> >> Would these additions be required within this series? What is missing from this >> discussion is why would these additions be necessary? Why should the kernel >> enforce a restriction that is beyond the scope of the X.509 spec? If a warning was >> to be added, what would be the justification for adding this additional code? From >> my research every single 3rd party code signing intermediate CA would be flagged >> with the warning. Isn’t this just going to cause confusion? Or is there a benefit that >> I am missing that needs to be stated? > > You're focusing on third party kernel modules and forgetting about the > simple use case of allowing an end user (or business) to sign their own > code. True they could use the less restrictive CA certificates, but it > is unnecessary. My focus is on signing user-space applications, as outlined in the cover letter. This series has nothing to do with kernel modules. Most end-users and businesses rely on a third party to deal with code signing. All third party code signing services I have found use an intermediate CA containing more than just the keyCertSign usage set. It seems to be an industry accepted practice that does not violate the spec. Before writing new code to either warn or exclude a third party intermediate CA, I would like to understand the motivation behind this request.
On Thu, 2022-12-22 at 15:15 +0000, Eric Snowberg wrote: > > > On Dec 21, 2022, at 12:01 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > > > On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: > >> > >>> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > >>> > >>> On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: > >>>> Hi Eric and Mimi, > >>>> > >>>> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: > >>>>> > >>>>> > >>>>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the > >>>>>>>>>>> keyCertSign key usage and has the CA bit set to true. > >>>>>>>>>> > >>>>>>>>>> Hi Eric, > >>>>>>>>>> > >>>>>>>>>> Allowing CA certificates with the digitalSignature key usage flag > >>>>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the > >>>>>>>>>> above definition to exclude the digitalSignature key usage flag and > >>>>>>>>>> modify the code accordingly. > >>>>>>>>> > >>>>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be > >>>>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. > >>>>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code > >>>>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that > >>>>>>>>> the intent? > >>>>>>>> > >>>>>>>> That definitely was not the intent. Nor would it address the issue of > >>>>>>>> a particular intermediate CA certificate having both keyCertSign and > >>>>>>>> digitalSignature. > >>>>>>> > >>>>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains > >>>>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate > >>>>>>> CA cert like the one used on kernel.org? > >>>>>> > >>>>>> I must be missing something. Isn't the purpose of "keyUsage" to > >>>>>> minimize how a certificate may be used? Why would we want the same > >>>>>> certificate to be used for both certificate signing and code signing? > >>>>> > >>>>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. > >>>>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature > >>>>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be > >>>>> challenging and will severely limit usage. > >>>> > >>>> How about allowing both keyCertSign and digitalSignature asserted but > >>>> issuing a warning for this case? > >>>> > >>>> Here's my rationale for this proposal. > >>>> > >>>> I assume we should conform to some X.509 specifications. So I checked > >>>> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and > >>>> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) > >>>> [2]. > >>>> > >>>> [1] states in 4.2.1.3. Key Usage, > >>>> "If the keyUsage extension is present, then the subject public key > >>>> MUST NOT be used to verify signatures on certificates or CRLs unless > >>>> the corresponding keyCertSign or cRLSign bit is set. If the subject > >>>> public key is only to be used for verifying signatures on > >>>> certificates and/or CRLs, then the digitalSignature and > >>>> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature > >>>> and/or nonRepudiation bits MAY be set in addition to the keyCertSign > >>>> and/or cRLSign bits if the subject public key is to be used to verify > >>>> signatures on certificates and/or CRLs as well as other objects." > >>>> > >>>> and [2] states in 8.2.2.3 Key usage extension that, > >>>> "More than one bit may be set in an instance of the keyUsage extension. > >>>> The setting of multiple bits shall not change the meaning of each > >>>> individual bit but shall indicate that the certificate may be used for > >>>> all of the purposes indicated by the set bits. There may be risks > >>>> incurred when setting multiple bits. A review of those risks is > >>>> documented in Annex I." > >>>> > >>>> I interpret the above texts as we should allow both keyCertSign and > >>>> digitalSignature. However [2] warns about the risks of setting multiple > >>>> bits. Quoting Annex I, > >>>> > >>>> "Combining the contentCommitment bit in the keyUsage certificate > >>>> extension with other keyUsage bits may have security implications > >>>> depending on the security environment in which the certificate is to be > >>>> used. If the subject's environment can be fully controlled and trusted, > >>>> then there are no specific security implications. For example, in cases > >>>> where the subject is fully confident about exactly which data is signed > >>>> or cases where the subject is fully confident about the security > >>>> characteristics of the authentication protocol being used. If the > >>>> subject's environment is not fully controlled or not fully trusted, then > >>>> unintentional signing of commitments is possible. Examples include the > >>>> use of badly formed authentication exchanges and the use of a rogue > >>>> software component. If untrusted environments are used by a subject, > >>>> these security implications can be limited through use of the following > >>>> measures: > >>>> – to not combine the contentCommitment key usage setting in > >>>> certificates with any other key usage setting and to use the > >>>> corresponding private key only with this certificate; > >>>> > >>>> – to limit the use of private keys associated with certificates that > >>>> have the contentCommitment key usage bit set, to environments which > >>>> are considered adequately controlled and trustworthy" > >>>> > >>>> So maybe it's useful to add a warning if both keyCertSign and > >>>> digitalSignature are asserted. > >>> > >>> Coiby, thank you for adding these details. I was hoping others would > >>> chime in as well. I agree at minimum there should be a warning. > >> > >> A warning could be added. > >> > >>> Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on > >>> INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the > >>> more restrictive certificate use case requirements: all certificates, > >>> CA certificate signing and digital signature, only CA certificate > >>> signing. > >> > >> As could support for additional restrictions. > >> > >> Would these additions be required within this series? What is missing from this > >> discussion is why would these additions be necessary? Why should the kernel > >> enforce a restriction that is beyond the scope of the X.509 spec? If a warning was > >> to be added, what would be the justification for adding this additional code? From > >> my research every single 3rd party code signing intermediate CA would be flagged > >> with the warning. Isn’t this just going to cause confusion? Or is there a benefit that > >> I am missing that needs to be stated? > > > > You're focusing on third party kernel modules and forgetting about the > > simple use case of allowing an end user (or business) to sign their own > > code. True they could use the less restrictive CA certificates, but it > > is unnecessary. > > My focus is on signing user-space applications, as outlined in the cover letter. This > series has nothing to do with kernel modules. Most end-users and businesses rely on > a third party to deal with code signing. All third party code signing services I have > found use an intermediate CA containing more than just the keyCertSign usage set. > It seems to be an industry accepted practice that does not violate the spec. Before writing > new code to either warn or exclude a third party intermediate CA, I would like to understand > the motivation behind this request. In older discussions there are comments like, "Any CA certificate, no matter if it's a root or an intermediate, must have the keyCertSign extension. If you want to sign a revocation list (CRL) with the CA certificate as well (you usually do want that), than you have to add cRLSign as well. Any other keyUsages can and should be avoided for CA certificates." The question as to "why" this changed to include "digitalSignature" was posed here [2] with the response being for "OCSP". It also includes a link to Entrusts root and intermediate CAs with just keyCertSign and cRLSign keyUsages. The matchine keyring is a means of establishing a new root of trust. The motivation for further restricting CA certificates to just keyCertSign and cRLSign keyUsages is to limit how the CA certificates may be used. They should not be used for code signing. thanks, Mimi [1] https://superuser.com/questions/738612/openssl-ca-keyusage-extension [2] https://security.stackexchange.com/questions/231133/keyusage-extensions-on-a-certificate-authority
> On Dec 22, 2022, at 8:41 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Thu, 2022-12-22 at 15:15 +0000, Eric Snowberg wrote: >> >>> On Dec 21, 2022, at 12:01 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>> >>> On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: >>>> >>>>> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>>>> >>>>> On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: >>>>>> Hi Eric and Mimi, >>>>>> >>>>>> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: >>>>>>> >>>>>>> >>>>>>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>>>>>>>>> keyCertSign key usage and has the CA bit set to true. >>>>>>>>>>>> >>>>>>>>>>>> Hi Eric, >>>>>>>>>>>> >>>>>>>>>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>>>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>>>>>>>>> above definition to exclude the digitalSignature key usage flag and >>>>>>>>>>>> modify the code accordingly. >>>>>>>>>>> >>>>>>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>>>>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>>>>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>>>>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>>>>>>>>> the intent? >>>>>>>>>> >>>>>>>>>> That definitely was not the intent. Nor would it address the issue of >>>>>>>>>> a particular intermediate CA certificate having both keyCertSign and >>>>>>>>>> digitalSignature. >>>>>>>>> >>>>>>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >>>>>>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >>>>>>>>> CA cert like the one used on kernel.org? >>>>>>>> >>>>>>>> I must be missing something. Isn't the purpose of "keyUsage" to >>>>>>>> minimize how a certificate may be used? Why would we want the same >>>>>>>> certificate to be used for both certificate signing and code signing? >>>>>>> >>>>>>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. >>>>>>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature >>>>>>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be >>>>>>> challenging and will severely limit usage. >>>>>> >>>>>> How about allowing both keyCertSign and digitalSignature asserted but >>>>>> issuing a warning for this case? >>>>>> >>>>>> Here's my rationale for this proposal. >>>>>> >>>>>> I assume we should conform to some X.509 specifications. So I checked >>>>>> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and >>>>>> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) >>>>>> [2]. >>>>>> >>>>>> [1] states in 4.2.1.3. Key Usage, >>>>>> "If the keyUsage extension is present, then the subject public key >>>>>> MUST NOT be used to verify signatures on certificates or CRLs unless >>>>>> the corresponding keyCertSign or cRLSign bit is set. If the subject >>>>>> public key is only to be used for verifying signatures on >>>>>> certificates and/or CRLs, then the digitalSignature and >>>>>> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature >>>>>> and/or nonRepudiation bits MAY be set in addition to the keyCertSign >>>>>> and/or cRLSign bits if the subject public key is to be used to verify >>>>>> signatures on certificates and/or CRLs as well as other objects." >>>>>> >>>>>> and [2] states in 8.2.2.3 Key usage extension that, >>>>>> "More than one bit may be set in an instance of the keyUsage extension. >>>>>> The setting of multiple bits shall not change the meaning of each >>>>>> individual bit but shall indicate that the certificate may be used for >>>>>> all of the purposes indicated by the set bits. There may be risks >>>>>> incurred when setting multiple bits. A review of those risks is >>>>>> documented in Annex I." >>>>>> >>>>>> I interpret the above texts as we should allow both keyCertSign and >>>>>> digitalSignature. However [2] warns about the risks of setting multiple >>>>>> bits. Quoting Annex I, >>>>>> >>>>>> "Combining the contentCommitment bit in the keyUsage certificate >>>>>> extension with other keyUsage bits may have security implications >>>>>> depending on the security environment in which the certificate is to be >>>>>> used. If the subject's environment can be fully controlled and trusted, >>>>>> then there are no specific security implications. For example, in cases >>>>>> where the subject is fully confident about exactly which data is signed >>>>>> or cases where the subject is fully confident about the security >>>>>> characteristics of the authentication protocol being used. If the >>>>>> subject's environment is not fully controlled or not fully trusted, then >>>>>> unintentional signing of commitments is possible. Examples include the >>>>>> use of badly formed authentication exchanges and the use of a rogue >>>>>> software component. If untrusted environments are used by a subject, >>>>>> these security implications can be limited through use of the following >>>>>> measures: >>>>>> – to not combine the contentCommitment key usage setting in >>>>>> certificates with any other key usage setting and to use the >>>>>> corresponding private key only with this certificate; >>>>>> >>>>>> – to limit the use of private keys associated with certificates that >>>>>> have the contentCommitment key usage bit set, to environments which >>>>>> are considered adequately controlled and trustworthy" >>>>>> >>>>>> So maybe it's useful to add a warning if both keyCertSign and >>>>>> digitalSignature are asserted. >>>>> >>>>> Coiby, thank you for adding these details. I was hoping others would >>>>> chime in as well. I agree at minimum there should be a warning. >>>> >>>> A warning could be added. >>>> >>>>> Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on >>>>> INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the >>>>> more restrictive certificate use case requirements: all certificates, >>>>> CA certificate signing and digital signature, only CA certificate >>>>> signing. >>>> >>>> As could support for additional restrictions. >>>> >>>> Would these additions be required within this series? What is missing from this >>>> discussion is why would these additions be necessary? Why should the kernel >>>> enforce a restriction that is beyond the scope of the X.509 spec? If a warning was >>>> to be added, what would be the justification for adding this additional code? From >>>> my research every single 3rd party code signing intermediate CA would be flagged >>>> with the warning. Isn’t this just going to cause confusion? Or is there a benefit that >>>> I am missing that needs to be stated? >>> >>> You're focusing on third party kernel modules and forgetting about the >>> simple use case of allowing an end user (or business) to sign their own >>> code. True they could use the less restrictive CA certificates, but it >>> is unnecessary. >> >> My focus is on signing user-space applications, as outlined in the cover letter. This >> series has nothing to do with kernel modules. Most end-users and businesses rely on >> a third party to deal with code signing. All third party code signing services I have >> found use an intermediate CA containing more than just the keyCertSign usage set. >> It seems to be an industry accepted practice that does not violate the spec. Before writing >> new code to either warn or exclude a third party intermediate CA, I would like to understand >> the motivation behind this request. > > In older discussions there are comments like, "Any CA certificate, no > matter if it's a root or an intermediate, must have the keyCertSign > extension. If you want to sign a revocation list (CRL) with the CA > certificate as well (you usually do want that), than you have to add > cRLSign as well. Any other keyUsages can and should be avoided for CA > certificates." > > The question as to "why" this changed to include "digitalSignature" was > posed here [2] with the response being for "OCSP". It also includes a > link to Entrusts root and intermediate CAs with just keyCertSign and > cRLSign keyUsages. > > The matchine keyring is a means of establishing a new root of trust. > The motivation for further restricting CA certificates to just > keyCertSign and cRLSign keyUsages is to limit how the CA certificates > may be used. They should not be used for code signing. Fair enough. If this will be viewed as justification for adding the additional code, I can work on adding it. Above you mentioned a warning would be needed at a minimum and a restriction could be placed behind a Kconfig. How about for the default case I add the warning and when compiling with INTEGRITY_CA_MACHINE_KEYRING the restriction will be enforced.
On Fri, 2022-12-23 at 16:13 +0000, Eric Snowberg wrote: > > > On Dec 22, 2022, at 8:41 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > > > On Thu, 2022-12-22 at 15:15 +0000, Eric Snowberg wrote: > >> > >>> On Dec 21, 2022, at 12:01 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: > >>> > >>> On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: > >>>> > >>>>> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > >>>>> > >>>>> On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: > >>>>>> Hi Eric and Mimi, > >>>>>> > >>>>>> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: > >>>>>>> > >>>>>>> > >>>>>>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the > >>>>>>>>>>>>> keyCertSign key usage and has the CA bit set to true. > >>>>>>>>>>>> > >>>>>>>>>>>> Hi Eric, > >>>>>>>>>>>> > >>>>>>>>>>>> Allowing CA certificates with the digitalSignature key usage flag > >>>>>>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the > >>>>>>>>>>>> above definition to exclude the digitalSignature key usage flag and > >>>>>>>>>>>> modify the code accordingly. > >>>>>>>>>>> > >>>>>>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be > >>>>>>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. > >>>>>>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code > >>>>>>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that > >>>>>>>>>>> the intent? > >>>>>>>>>> > >>>>>>>>>> That definitely was not the intent. Nor would it address the issue of > >>>>>>>>>> a particular intermediate CA certificate having both keyCertSign and > >>>>>>>>>> digitalSignature. > >>>>>>>>> > >>>>>>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains > >>>>>>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate > >>>>>>>>> CA cert like the one used on kernel.org? > >>>>>>>> > >>>>>>>> I must be missing something. Isn't the purpose of "keyUsage" to > >>>>>>>> minimize how a certificate may be used? Why would we want the same > >>>>>>>> certificate to be used for both certificate signing and code signing? > >>>>>>> > >>>>>>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. > >>>>>>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature > >>>>>>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be > >>>>>>> challenging and will severely limit usage. > >>>>>> > >>>>>> How about allowing both keyCertSign and digitalSignature asserted but > >>>>>> issuing a warning for this case? > >>>>>> > >>>>>> Here's my rationale for this proposal. > >>>>>> > >>>>>> I assume we should conform to some X.509 specifications. So I checked > >>>>>> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and > >>>>>> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) > >>>>>> [2]. > >>>>>> > >>>>>> [1] states in 4.2.1.3. Key Usage, > >>>>>> "If the keyUsage extension is present, then the subject public key > >>>>>> MUST NOT be used to verify signatures on certificates or CRLs unless > >>>>>> the corresponding keyCertSign or cRLSign bit is set. If the subject > >>>>>> public key is only to be used for verifying signatures on > >>>>>> certificates and/or CRLs, then the digitalSignature and > >>>>>> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature > >>>>>> and/or nonRepudiation bits MAY be set in addition to the keyCertSign > >>>>>> and/or cRLSign bits if the subject public key is to be used to verify > >>>>>> signatures on certificates and/or CRLs as well as other objects." > >>>>>> > >>>>>> and [2] states in 8.2.2.3 Key usage extension that, > >>>>>> "More than one bit may be set in an instance of the keyUsage extension. > >>>>>> The setting of multiple bits shall not change the meaning of each > >>>>>> individual bit but shall indicate that the certificate may be used for > >>>>>> all of the purposes indicated by the set bits. There may be risks > >>>>>> incurred when setting multiple bits. A review of those risks is > >>>>>> documented in Annex I." > >>>>>> > >>>>>> I interpret the above texts as we should allow both keyCertSign and > >>>>>> digitalSignature. However [2] warns about the risks of setting multiple > >>>>>> bits. Quoting Annex I, > >>>>>> > >>>>>> "Combining the contentCommitment bit in the keyUsage certificate > >>>>>> extension with other keyUsage bits may have security implications > >>>>>> depending on the security environment in which the certificate is to be > >>>>>> used. If the subject's environment can be fully controlled and trusted, > >>>>>> then there are no specific security implications. For example, in cases > >>>>>> where the subject is fully confident about exactly which data is signed > >>>>>> or cases where the subject is fully confident about the security > >>>>>> characteristics of the authentication protocol being used. If the > >>>>>> subject's environment is not fully controlled or not fully trusted, then > >>>>>> unintentional signing of commitments is possible. Examples include the > >>>>>> use of badly formed authentication exchanges and the use of a rogue > >>>>>> software component. If untrusted environments are used by a subject, > >>>>>> these security implications can be limited through use of the following > >>>>>> measures: > >>>>>> – to not combine the contentCommitment key usage setting in > >>>>>> certificates with any other key usage setting and to use the > >>>>>> corresponding private key only with this certificate; > >>>>>> > >>>>>> – to limit the use of private keys associated with certificates that > >>>>>> have the contentCommitment key usage bit set, to environments which > >>>>>> are considered adequately controlled and trustworthy" > >>>>>> > >>>>>> So maybe it's useful to add a warning if both keyCertSign and > >>>>>> digitalSignature are asserted. > >>>>> > >>>>> Coiby, thank you for adding these details. I was hoping others would > >>>>> chime in as well. I agree at minimum there should be a warning. > >>>> > >>>> A warning could be added. > >>>> > >>>>> Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on > >>>>> INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the > >>>>> more restrictive certificate use case requirements: all certificates, > >>>>> CA certificate signing and digital signature, only CA certificate > >>>>> signing. > >>>> > >>>> As could support for additional restrictions. > >>>> > >>>> Would these additions be required within this series? What is missing from this > >>>> discussion is why would these additions be necessary? Why should the kernel > >>>> enforce a restriction that is beyond the scope of the X.509 spec? If a warning was > >>>> to be added, what would be the justification for adding this additional code? From > >>>> my research every single 3rd party code signing intermediate CA would be flagged > >>>> with the warning. Isn’t this just going to cause confusion? Or is there a benefit that > >>>> I am missing that needs to be stated? > >>> > >>> You're focusing on third party kernel modules and forgetting about the > >>> simple use case of allowing an end user (or business) to sign their own > >>> code. True they could use the less restrictive CA certificates, but it > >>> is unnecessary. > >> > >> My focus is on signing user-space applications, as outlined in the cover letter. This > >> series has nothing to do with kernel modules. Most end-users and businesses rely on > >> a third party to deal with code signing. All third party code signing services I have > >> found use an intermediate CA containing more than just the keyCertSign usage set. > >> It seems to be an industry accepted practice that does not violate the spec. Before writing > >> new code to either warn or exclude a third party intermediate CA, I would like to understand > >> the motivation behind this request. > > > > In older discussions there are comments like, "Any CA certificate, no > > matter if it's a root or an intermediate, must have the keyCertSign > > extension. If you want to sign a revocation list (CRL) with the CA > > certificate as well (you usually do want that), than you have to add > > cRLSign as well. Any other keyUsages can and should be avoided for CA > > certificates." > > > > The question as to "why" this changed to include "digitalSignature" was > > posed here [2] with the response being for "OCSP". It also includes a > > link to Entrusts root and intermediate CAs with just keyCertSign and > > cRLSign keyUsages. > > > > The matchine keyring is a means of establishing a new root of trust. > > The motivation for further restricting CA certificates to just > > keyCertSign and cRLSign keyUsages is to limit how the CA certificates > > may be used. They should not be used for code signing. > > Fair enough. If this will be viewed as justification for adding the additional > code, I can work on adding it. Above you mentioned a warning would be needed > at a minimum and a restriction could be placed behind a Kconfig. How about for > the default case I add the warning and when compiling with > INTEGRITY_CA_MACHINE_KEYRING the restriction will be enforced. Sounds good to me. To avoid misunderstandings, will there be a Kconfig menu with 3 options? There were a couple of other comments having to do with variable names. Will you address them as well?
> On Dec 23, 2022, at 9:34 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: > > On Fri, 2022-12-23 at 16:13 +0000, Eric Snowberg wrote: >> >>> On Dec 22, 2022, at 8:41 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>> >>> On Thu, 2022-12-22 at 15:15 +0000, Eric Snowberg wrote: >>>> >>>>> On Dec 21, 2022, at 12:01 PM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>>>> >>>>> On Wed, 2022-12-21 at 18:27 +0000, Eric Snowberg wrote: >>>>>> >>>>>>> On Dec 18, 2022, at 5:21 AM, Mimi Zohar <zohar@linux.ibm.com> wrote: >>>>>>> >>>>>>> On Fri, 2022-12-16 at 22:06 +0800, Coiby Xu wrote: >>>>>>>> Hi Eric and Mimi, >>>>>>>> >>>>>>>> On Thu, Dec 15, 2022 at 09:45:37PM +0000, Eric Snowberg wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>>>>>>>> A CA cert shall be defined as any X509 certificate that contains the >>>>>>>>>>>>>>> keyCertSign key usage and has the CA bit set to true. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Eric, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Allowing CA certificates with the digitalSignature key usage flag >>>>>>>>>>>>>> enabled defeats the purpose of the new Kconfig. Please update the >>>>>>>>>>>>>> above definition to exclude the digitalSignature key usage flag and >>>>>>>>>>>>>> modify the code accordingly. >>>>>>>>>>>>> >>>>>>>>>>>>> Within v2, the request was made to allow Intermediate CA certificates to be >>>>>>>>>>>>> loaded directly. The Intermediate CA referenced was the one used by kernel.org. >>>>>>>>>>>>> This Intermediate CA contains both digitalSignature and keyCertSign. If the code >>>>>>>>>>>>> is changed to exclude this certificate, now the root CA has to be loaded again. Is that >>>>>>>>>>>>> the intent? >>>>>>>>>>>> >>>>>>>>>>>> That definitely was not the intent. Nor would it address the issue of >>>>>>>>>>>> a particular intermediate CA certificate having both keyCertSign and >>>>>>>>>>>> digitalSignature. >>>>>>>>>>> >>>>>>>>>>> Sorry, I’m not following. Why is it an issue that an intermediate CA certificate contains >>>>>>>>>>> both keyCertSign and digitalSignature? Why would we want to exclude an Intermediate >>>>>>>>>>> CA cert like the one used on kernel.org? >>>>>>>>>> >>>>>>>>>> I must be missing something. Isn't the purpose of "keyUsage" to >>>>>>>>>> minimize how a certificate may be used? Why would we want the same >>>>>>>>>> certificate to be used for both certificate signing and code signing? >>>>>>>>> >>>>>>>>> Every 3rd party intermediate CA I have looked at so far contains both set. Most have CRLSign set. >>>>>>>>> Typically the root CA contains keyCertSign and CRLSign, but some also have digitalSignature >>>>>>>>> set. Finding a 3rd party Intermediate CA without digitalSignature set is probably going to be >>>>>>>>> challenging and will severely limit usage. >>>>>>>> >>>>>>>> How about allowing both keyCertSign and digitalSignature asserted but >>>>>>>> issuing a warning for this case? >>>>>>>> >>>>>>>> Here's my rationale for this proposal. >>>>>>>> >>>>>>>> I assume we should conform to some X.509 specifications. So I checked >>>>>>>> "RFC 5280: Internet X.509 Public Key Infrastructure Certificate and >>>>>>>> Certificate Revocation List (CRL) Profile" [1] and ITU-T X.509 (2012-10) >>>>>>>> [2]. >>>>>>>> >>>>>>>> [1] states in 4.2.1.3. Key Usage, >>>>>>>> "If the keyUsage extension is present, then the subject public key >>>>>>>> MUST NOT be used to verify signatures on certificates or CRLs unless >>>>>>>> the corresponding keyCertSign or cRLSign bit is set. If the subject >>>>>>>> public key is only to be used for verifying signatures on >>>>>>>> certificates and/or CRLs, then the digitalSignature and >>>>>>>> nonRepudiation bits SHOULD NOT be set. However, the digitalSignature >>>>>>>> and/or nonRepudiation bits MAY be set in addition to the keyCertSign >>>>>>>> and/or cRLSign bits if the subject public key is to be used to verify >>>>>>>> signatures on certificates and/or CRLs as well as other objects." >>>>>>>> >>>>>>>> and [2] states in 8.2.2.3 Key usage extension that, >>>>>>>> "More than one bit may be set in an instance of the keyUsage extension. >>>>>>>> The setting of multiple bits shall not change the meaning of each >>>>>>>> individual bit but shall indicate that the certificate may be used for >>>>>>>> all of the purposes indicated by the set bits. There may be risks >>>>>>>> incurred when setting multiple bits. A review of those risks is >>>>>>>> documented in Annex I." >>>>>>>> >>>>>>>> I interpret the above texts as we should allow both keyCertSign and >>>>>>>> digitalSignature. However [2] warns about the risks of setting multiple >>>>>>>> bits. Quoting Annex I, >>>>>>>> >>>>>>>> "Combining the contentCommitment bit in the keyUsage certificate >>>>>>>> extension with other keyUsage bits may have security implications >>>>>>>> depending on the security environment in which the certificate is to be >>>>>>>> used. If the subject's environment can be fully controlled and trusted, >>>>>>>> then there are no specific security implications. For example, in cases >>>>>>>> where the subject is fully confident about exactly which data is signed >>>>>>>> or cases where the subject is fully confident about the security >>>>>>>> characteristics of the authentication protocol being used. If the >>>>>>>> subject's environment is not fully controlled or not fully trusted, then >>>>>>>> unintentional signing of commitments is possible. Examples include the >>>>>>>> use of badly formed authentication exchanges and the use of a rogue >>>>>>>> software component. If untrusted environments are used by a subject, >>>>>>>> these security implications can be limited through use of the following >>>>>>>> measures: >>>>>>>> – to not combine the contentCommitment key usage setting in >>>>>>>> certificates with any other key usage setting and to use the >>>>>>>> corresponding private key only with this certificate; >>>>>>>> >>>>>>>> – to limit the use of private keys associated with certificates that >>>>>>>> have the contentCommitment key usage bit set, to environments which >>>>>>>> are considered adequately controlled and trustworthy" >>>>>>>> >>>>>>>> So maybe it's useful to add a warning if both keyCertSign and >>>>>>>> digitalSignature are asserted. >>>>>>> >>>>>>> Coiby, thank you for adding these details. I was hoping others would >>>>>>> chime in as well. I agree at minimum there should be a warning. >>>>>> >>>>>> A warning could be added. >>>>>> >>>>>>> Perhaps instead of making INTEGRITY_CA_MACHINE_KEYRING dependent on >>>>>>> INTEGRITY_MACHINE_KEYRING, make them a Kconfig "choice" to support the >>>>>>> more restrictive certificate use case requirements: all certificates, >>>>>>> CA certificate signing and digital signature, only CA certificate >>>>>>> signing. >>>>>> >>>>>> As could support for additional restrictions. >>>>>> >>>>>> Would these additions be required within this series? What is missing from this >>>>>> discussion is why would these additions be necessary? Why should the kernel >>>>>> enforce a restriction that is beyond the scope of the X.509 spec? If a warning was >>>>>> to be added, what would be the justification for adding this additional code? From >>>>>> my research every single 3rd party code signing intermediate CA would be flagged >>>>>> with the warning. Isn’t this just going to cause confusion? Or is there a benefit that >>>>>> I am missing that needs to be stated? >>>>> >>>>> You're focusing on third party kernel modules and forgetting about the >>>>> simple use case of allowing an end user (or business) to sign their own >>>>> code. True they could use the less restrictive CA certificates, but it >>>>> is unnecessary. >>>> >>>> My focus is on signing user-space applications, as outlined in the cover letter. This >>>> series has nothing to do with kernel modules. Most end-users and businesses rely on >>>> a third party to deal with code signing. All third party code signing services I have >>>> found use an intermediate CA containing more than just the keyCertSign usage set. >>>> It seems to be an industry accepted practice that does not violate the spec. Before writing >>>> new code to either warn or exclude a third party intermediate CA, I would like to understand >>>> the motivation behind this request. >>> >>> In older discussions there are comments like, "Any CA certificate, no >>> matter if it's a root or an intermediate, must have the keyCertSign >>> extension. If you want to sign a revocation list (CRL) with the CA >>> certificate as well (you usually do want that), than you have to add >>> cRLSign as well. Any other keyUsages can and should be avoided for CA >>> certificates." >>> >>> The question as to "why" this changed to include "digitalSignature" was >>> posed here [2] with the response being for "OCSP". It also includes a >>> link to Entrusts root and intermediate CAs with just keyCertSign and >>> cRLSign keyUsages. >>> >>> The matchine keyring is a means of establishing a new root of trust. >>> The motivation for further restricting CA certificates to just >>> keyCertSign and cRLSign keyUsages is to limit how the CA certificates >>> may be used. They should not be used for code signing. >> >> Fair enough. If this will be viewed as justification for adding the additional >> code, I can work on adding it. Above you mentioned a warning would be needed >> at a minimum and a restriction could be placed behind a Kconfig. How about for >> the default case I add the warning and when compiling with >> INTEGRITY_CA_MACHINE_KEYRING the restriction will be enforced. > > Sounds good to me. To avoid misunderstandings, will there be a Kconfig > menu with 3 options? I will add the three options in the next round. > There were a couple of other comments having to > do with variable names. Will you address them as well? And take care of the variable name changes. I won’t get back to this until January.
On Fri, 2022-12-23 at 18:17 +0000, Eric Snowberg wrote: > >> Fair enough. If this will be viewed as justification for adding the additional > >> code, I can work on adding it. Above you mentioned a warning would be needed > >> at a minimum and a restriction could be placed behind a Kconfig. How about for > >> the default case I add the warning and when compiling with > >> INTEGRITY_CA_MACHINE_KEYRING the restriction will be enforced. > > > > Sounds good to me. To avoid misunderstandings, will there be a Kconfig > > menu with 3 options? > > I will add the three options in the next round. > > > There were a couple of other comments having to > > do with variable names. Will you address them as well? > > And take care of the variable name changes. I won’t get back to this until January. Enjoy your vacation and the holidays. Looking forward to the next version.