Re: [dtn] PKIX Extended Key Purpose recommendations

Brian Sipos <BSipos@rkf-eng.com> Thu, 03 December 2020 21:56 UTC

Return-Path: <BSipos@rkf-eng.com>
X-Original-To: dtn@ietfa.amsl.com
Delivered-To: dtn@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 646D43A0DAE for <dtn@ietfa.amsl.com>; Thu, 3 Dec 2020 13:56:57 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.1
X-Spam-Level:
X-Spam-Status: No, score=-2.1 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=rkf-eng.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EaoVrhlb46gl for <dtn@ietfa.amsl.com>; Thu, 3 Dec 2020 13:56:54 -0800 (PST)
Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 760F43A0EDB for <dtn@ietf.org>; Thu, 3 Dec 2020 13:56:34 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IofKKir0oFwZHPeDO0+Z1pvQqS5roHi39ym/Tr9v43j5VXf9u6LWXG66jDHoiUmqbBRBc9dx6pc14IU9NH62rD1UmpYVPoBd3YGVYwF++ceRwph0ZXKkhzlooVIHX491Giw9QPGDuLgX8xQE4NWi2A6j9vLbtyCVTv8fPd/6YXoL0TLVPWoVPLVuj4sievOM9Huk1EQhr21Q21YosQ8MZb/Ng77l+5Cm3/C7kEKbFqoQsW0RiYNvxc3Q6ZiiNs213nc1Ia6tEkT1yhZ+07HY9PHP4pXMj4qxLs5TJjAWm5X/xFxw4hjYacOCTXbYHFwA1UiPOYtFIRplG6wZwBpuOg==
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-SenderADCheck; bh=knyFIVsIT/ud6T2MUMhFBws+SPvfSHMU1k+xQlvMHXA=; b=ZkH8P/k0wWnpoI7ax2qzOXkz2YzB6UK3krLCRRDBxDASnVgokK9XjzpLi3gwbJMLWzLtUrtDbFlji+Rb1XKAOveMnjX61n1U0mTrd3wihiFJGocLaNMQTpdGupcjkx+4fOPQ/CdSbvtR9KzEdE9wNLpIP8P0euQpizLxIJPGYJWQUG03si0lhGpqxIom6pEop2Xcq0LxHLlT903NvlUX/6W3oVkdMrFitEDfs6p1ygC9ZojKc7vETRWktbF3alK5P5GiihODS1zovxaalmwA0PLBJi3oHxvsS8NdYNX2c5h/oWRsU12nkQeTQ9SGl63liigJHhHyNquT+7dk8+M34A==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=rkf-eng.com; dmarc=pass action=none header.from=rkf-eng.com; dkim=pass header.d=rkf-eng.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rkf-eng.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=knyFIVsIT/ud6T2MUMhFBws+SPvfSHMU1k+xQlvMHXA=; b=ISG9totvvhhTQD4Ff6qCe2y99XdQK4ye4Bx+72o825nqFnm6RJU2fwzIs+2lzo/TAe4DG53HYTaK0ZDrQw6ZWe8aBvPTGfdM6bnevTerFFQQ+MFyXJCLZPVEVQyTcQ2ZUib/H7Fee0hgyM/CNprc3LHo6EEvGWsMNtIby4PtE24=
Received: from MN2PR13MB3567.namprd13.prod.outlook.com (2603:10b6:208:168::10) by MN2PR13MB4335.namprd13.prod.outlook.com (2603:10b6:208:a6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.6; Thu, 3 Dec 2020 21:56:26 +0000
Received: from MN2PR13MB3567.namprd13.prod.outlook.com ([fe80::54f4:962e:10e5:a2e1]) by MN2PR13MB3567.namprd13.prod.outlook.com ([fe80::54f4:962e:10e5:a2e1%7]) with mapi id 15.20.3632.009; Thu, 3 Dec 2020 21:56:26 +0000
From: Brian Sipos <BSipos@rkf-eng.com>
To: Benjamin Kaduk <kaduk@mit.edu>
CC: Russ Housley <housley@vigilsec.com>, "dtn@ietf.org" <dtn@ietf.org>
Thread-Topic: PKIX Extended Key Purpose recommendations
Thread-Index: AQHWvv0sWy/YaK09E0Ki20F4+VZLK6nlDicAgACSlYQ=
Date: Thu, 03 Dec 2020 21:56:25 +0000
Message-ID: <MN2PR13MB35673E19D8EA0B269A74D4029FF20@MN2PR13MB3567.namprd13.prod.outlook.com>
References: <MN2PR13MB3567A71AA43D243A2ED6989F9FFF0@MN2PR13MB3567.namprd13.prod.outlook.com>, <20201203072942.GJ64351@kduck.mit.edu>
In-Reply-To: <20201203072942.GJ64351@kduck.mit.edu>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: mit.edu; dkim=none (message not signed) header.d=none;mit.edu; dmarc=none action=none header.from=rkf-eng.com;
x-originating-ip: [96.241.16.84]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: c71968aa-79df-4a54-2795-08d897d64823
x-ms-traffictypediagnostic: MN2PR13MB4335:
x-microsoft-antispam-prvs: <MN2PR13MB433520AC2F2003D4F4A5640D9FF20@MN2PR13MB4335.namprd13.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:7691;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: dJKFI551JTr+lsDt/nKF6TfwJ1XivanZWNLM8E7fQUzbmGcwSCKa+zvPQzC/L+sM+oYaeEXrblmZ2EdmT4sCHlSjtooRnADORGJNs6p07lvJUp4nLYi9zB3xklXxECqmECxXnK0yWhBw6fgzffSuj18tnvIaUbuFG4wMDeUny2gCV+djMnAfhatBTFkxCFB3PU5FzECYLxAoljX00BECshcl+0XRgfA3MYorxzxJheyOj1A88aHzfjeNMZBJBPcIdUb8dRBOIP71F2zwPPOpwarBJwDlj3eiYK5PgQQJ3p8ZE4HQhbX9dEy63RB9ZbnMDjBAbhlAdUpSNeqhl8cPFNaPrQjft4nwE+MzLgD8gK4kteXOrJZTR6mTg5k4fuvLnwTLczLjLpUE3Xclv7+agg==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR13MB3567.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39830400003)(366004)(346002)(376002)(166002)(86362001)(55016002)(4326008)(6506007)(53546011)(26005)(76116006)(64756008)(66946007)(66476007)(66446008)(7696005)(66556008)(45080400002)(6916009)(5660300002)(52536014)(8936002)(186003)(9686003)(8676002)(83380400001)(33656002)(2906002)(316002)(71200400001)(966005)(54906003)(478600001)(19627405001); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata: hMOcVSOkouPVH7WRlGmVEn1dJAeiwu59a88g5a3/w5TE8cqNUZH3MKXZhGCdWtlZdtF76CckE05R5SlIEieVymEOYBboUFToCuJ1aU6Z+A7hEgKItVTbrJebfCUsWreJDx0tLAuz5uasFTFjokYveE90B3fAxXVQCDSC4szPjVIP6k4ymjYcK2GNDjLKb/Lk78zQ/PpgAZSH/G0CDdjguVp4eRDeIaToTaQeeJt61sLmxau72wT5GUhCfVBRIRZTGuhvYLWnPGVxsfnaeKSDKAb3HA71CPzJPZBDrb2Vacf7JSDcZ8VPbE1wOxQ9fFzWgBEaKEhZ8aZWfilm0phopnXlZbqmMeUK27+s5aXo72pW8c846rDw4TmIIW0g6uSpw2Qdc5nzTqw8i7za63zr6KoMTjydzFbwVd8BTscxrn+etQ1NUqlW9gQmgHwdqPKM2pJJfuz02+YMTAV7QZvPoqnJfhett7mjsHstnRAfz+3BywgC/OXHnw5iVBsaJqnlzuoDfCZ/6HpKDPCTdUQPWlZEXliXacWYBGNeKsOfL1aRRMNk/LuyvlfHikMVz/43iB7bwP5EAaLJjS/CHAhoWpXl6ovhnlUc3kDSsz3sF0vEYrGNzq9A34RamuPlM/PoY4nBFneybG0EVGtqakK6X7rXRtRxREW2nBTfh8gkIjPrRvK7uf9vujqb6JnE+RJ+Bzln1ojB22iMBprtXhFjsr0wxlO0KPGD/PecVx/Rnyk4dlN94UR2Z2YwXFfgWlkiPE0NjGtNnJ2XZQQyFx6k4wCHfvLF9FLDkWS595dMnG38zhcZWiBn+rPf6AnvNrJJYWX3TYH2sJv8Vmya2a6lYmxI7LtDnMFjtb6vN3e76KTPcpZI1aLgpuUmcLV+McdiBeN9+qPIOHE/CiAwlOX6+GR5Fte+D9NvvytQskSaQxkN0uGlZp+I/0EzxUa920cAg/o/XOr87eE3CngJCtrm/ssSPmlsLML2d67feHJgFS0=
x-ms-exchange-transport-forked: True
Content-Type: multipart/alternative; boundary="_000_MN2PR13MB35673E19D8EA0B269A74D4029FF20MN2PR13MB3567namp_"
MIME-Version: 1.0
X-OriginatorOrg: rkf-eng.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: MN2PR13MB3567.namprd13.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: c71968aa-79df-4a54-2795-08d897d64823
X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2020 21:56:25.9965 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 4ed8b15b-911f-42bc-8524-d89148858535
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: cgM/nRU5cYHc2ZUfSczCffqU62+/wRVC/8AIQYtVlDguArArC2XGQ+Pe7Qt8kU58grxPC8/D5z40C5fmcdnT1A==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB4335
Archived-At: <https://mailarchive.ietf.org/arch/msg/dtn/30eZN9nEiaICxza17VlJQyeZOjs>
Subject: Re: [dtn] PKIX Extended Key Purpose recommendations
X-BeenThere: dtn@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Delay Tolerant Networking \(DTN\) discussion list at the IETF." <dtn.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dtn>, <mailto:dtn-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dtn/>
List-Post: <mailto:dtn@ietf.org>
List-Help: <mailto:dtn-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dtn>, <mailto:dtn-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 03 Dec 2020 21:56:57 -0000

Ben,
Thanks for this detailed explanation. It's still a bit confusing how interpretations of the EKU value labeled "TLS Web server authentication" sometimes take it to mean "any TLS server use" and specs for LDAP/TLS, IMAP/TLS, and SNMP/TLS don't mention EKU at all. I am tempted to mention it as non-normative interoperability note, because it's a big gotcha that bit me.

After looking through these kinds of implementation details, and also observing that the active TCPCL entity (TLS client) requires authentication but can only use NODE-ID or IPADDR-ID (not DNS-ID), I think the best specification-level logic is to:

  1.   Leave the procedures for how and when to do DNS-ID and IPADDR-ID validation in place, in some environments this is the only choice.
  2.  Make the recommended security policy to require mutual authentication based on NODE-ID validation alone and allow lower-level claims to be absent. This means to allow the "absent" result (cert just doesn't have DNS-ID or IPADDR-ID), but an earlier suggestion of yours was to allow a "failed" result (cert has other claims but we ignore them). Do you still believe that allowing lower-level failure is a good policy?
  3.  Add a specific requirement that the received peer Node ID should not be used for discovery/routing decisions if it is not validated by TLS. This is catch-all to just avoid the peer node impersonation threat.
  4.  Add an extended key purpose for "bundleSecurity" (which can mirror existing concepts for "emailSecurity") but don't mandate its use.

This recommended policy is strict, but users are free to adjust to whatever fits their needs. Also, when TLS authentication was originally discussed, there was no concept of a NODE-ID claim at all and no mechanism for a CA to verify such a claim (the original behavior was based on web PKI). Both such mechanisms are now proposed so achieving this stricter policy seems reasonable (though aspirational).
________________________________
From: Benjamin Kaduk <kaduk@mit.edu>
Sent: Thursday, December 3, 2020 02:29
To: Brian Sipos <BSipos@rkf-eng.com>
Cc: Russ Housley <housley@vigilsec.com>; dtn@ietf.org <dtn@ietf.org>
Subject: Re: PKIX Extended Key Purpose recommendations

Hi Brian,

Replying just on the OpenSSL front for now, since I am not sure how much
longer I will still be awake...

On Fri, Nov 20, 2020 at 05:34:50PM +0000, Brian Sipos wrote:
>
>
> The good news for rationale and understanding of these uses are that they are very similar to SMTP/TLS [1] and S/MIME [2] respectively. Although it appears that the id-kp-emailProtection OID was only ever specified for S/MIME and not for email transport between MTAs. I don't know what kinds of policies SMTP MTAs have with regard to PKIX certificates, even recent MTA-STS spec [3] doesn't define or reference a more detailed PKIX profile and doesn't mention any X.509 extensions at all.
>
> The bad news is that in some very simple testing of adding a new purpose OID I see that OpenSSL, which is used by both of my reference libraries Qt5 and python "ssl" package, appears to assume [4] that when I want "TLS on a socket" what I mean is "TLS for Web client/server purposes" and requires either id-kp-serverAuth or id-kp-clientAuth. There also appear to be quite a number of other implicit uses of the Web purposes in OpenSSL and no real access via higher-level APIs to affect this. The other key purposes seem to be usable only through different APIs unrelated to TLS.

It ends up not actually being too hard to get OpenSSL to behave differently
in this regard, though it is very much one of those "the answer is simple
only once you already know it" situations, and is further complicated by
the cornucopia of similarly named API functions.  (Neither of these is
unusual for OpenSSL, sadly, nor will they get fixed anytime soon, due to
the API stability promise.)

It is perhaps easiest to explain by reference to the libssl code that
surrounds the behavior in question;
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenssl%2Fopenssl%2Fblob%2Fmaster%2Fssl%2Fssl_cert.c%23L413-L430&amp;data=04%7C01%7CBSipos%40rkf-eng.com%7C8d446895452541f18cef08d8975d38e4%7C4ed8b15b911f42bc8524d89148858535%7C1%7C0%7C637425773935215065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=GmxDfBiUBCGBkAmQvLmCRmeJO%2FmMwhSEAfBSJjxMYCw%3D&amp;reserved=0 :

<BEGIN CODE>
     * We need to inherit the verify parameters. These can be determined by
     * the context: if its a server it will verify SSL client certificates
     * or
     * vice versa.
     */

    X509_STORE_CTX_set_default(ctx, s->server ? "ssl_client" : "ssl_server");
    /*
     * Anything non-default in "s->param" should overwrite anything in the
     * ctx.
     */
    X509_VERIFY_PARAM_set1(param, s->param);

    if (s->verify_callback)
        X509_STORE_CTX_set_verify_cb(ctx, s->verify_callback);

    if (s->ctx->app_verify_callback != NULL)
        i = s->ctx->app_verify_callback(ctx, s->ctx->app_verify_arg);
    else
        i = X509_verify_cert(ctx);
<END CODE>

The X509_STORE_CTX_set_default() call is what ends up causing the X.509
implementation to look for the id-kp-serverAuth/id-kp-clientAuth EKU value,
when X509_verify_cert() is called.  However, it is also clear from the last
quoted part that the "app_verify_callback" can take the form of a thin
wrapper around X509_verify_cert() that applies the needed configuration
changes to the X509_STORE_CTX configuration.  (Note that there is also the
verify_callback that can be used to override verification decisions at a
very fine-grained level but is also much more sensitive to implement
safely.  The man page at least does have a prominent disclaimer to not
confuse the two...) However, the the table of standard purpose values that
openssl natively supports (static X509_PURPOSE xstandard[] in v3_purp.c) is
pretty limited, and so in practice when using other EKUs we end up using
the "Any Purpose" entry and making the application code do the rest.

The X509_PURPOSE_add() API does to let the application add one at runtime,
but that involves getting a "NID" (OpenSSL-internal integer shorthand for
an ASN.1 object identifier), which involves OBJ_create() at runtime, as
well as specifying a function to do the actual checking.  If it's only
going to be used at one place in the application, that's a lot of overhead
when it can just be coded inline in the app verify callback!  (The relevant
checks that are done by default for the ssl_client/ssl_cerver uses are in
check_purpose_ssl_client() and check_purpose_ssl_server(), also in
v3_purp.c.  The xku_reject() macro they use is not helpful, since openssl
doesn't have a defined flag for the new EKU type, so this would entail the
loop over the X509_get_ext_d2i(., NID_ext_key_usage, ...) results and
looking for the new OID.)

I would like to write some code and have a bit more of an example for you,
but am wary about promising too much...


In short, there are no higher-level APIs because the OpenSSL implementation
requires too much knowledge in the library to make it easy to provide such
a high-level API.  But there is a hook to let application code run in
exactly the right place to take over the bits of X509 verification that are
affected, so the application can do what it needs to with only a relatively
small amount of low-level code.

-Ben