Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796161370; b=1FvBDhxrWMpCQSbUr6LQU4ZzpeSilpJRk70GWrJ4f+SkvtRMCdEmBkkXQpDnre6weL6K fDcZno9TYSeqYHvhpok1hLqHW6hbd1i1UCulYz1hu6PFB6W+yvt1ZKLv3k3+IqYj413YZ l7GOX1ljWRFXLo8NsHRD2QVK+MsqC+EuaT+HbY0FlQknDhg3mYh0NiqFxh5SkhS3uOTKq B0G5qKWUctXkeD+leHImR3WkqozcPlbGinqnwV2NjuyksDcPmm/pMyeTrMGx/m4w4joIf Qq86qj1/DCNdr7T5EAvHIrJXoKwmdvohsMZzg2lwFB6taAQ8CATXBDQJjwRT3YhSqqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796161370; h=Received:DKIM-Signature:From:To:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=24N7z8ziaBOdkSjLbktAM3wi6t6nwsUNDIVBZifqUAg=; b=2PmnB/gBIu/KSpMhLs+4K6lOhPjjXC0XK1lnjW65eH7wjQ3j0y3oo8QBKDd9L+fPuKJX xA1T18fKotTUEAFy+i0yxyS2k7Rvnie3/Tm2H/9XB84ZxU/sngTySqFE8+jMAwmECujNj AC5tXBz/CytBOd7YunwkxYNTW3bjxGg59FTIZmUNQ6gy0uX7izo5/8nuM2lFKJkc65Rkd WVYlAA7T91aQBmoA5Lpq2PRgjPl+JzgjUSkKKJxXtLTe0PUOfuYZ1o0ZYYZGJEUhgMpxC hKbnskzxwW0IiIOKt5EwugR7kurgmKyKMxvhNNEvIpmFhQUFkShJaC1cOe1XqS2Igqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ux2eg7Cc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81331606A325 for ; Tue, 1 Dec 2026 21:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ux2eg7Cc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 303251F00893 for ; Tue, 1 Dec 2026 21:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796161370; bh=24N7z8ziaBOdkSjLbktAM3wi6t6nwsUNDIVBZifqUAg=; h=From:To:Subject:Date:In-Reply-To:References; b=Ux2eg7CcWYtA7y435W0wOWhRE4KMBp9u7DzyUQXVmen84DVOizLGc/EaFAMi1AzuB 10DRR9F1Cp9s0QFzxEGbwpROANrivTcB26ptV+zI1EjnCbOutqIXbx4UXC1AOJBJA9 KJ//vms1z882VQUjHTwdKv4VLNhVP6OZ/JysQPVoaZbjAh+yc7thVN3r8RQuykSWJ0 4LJuRCiSgzUQx2ZODsnyU8CEJsOxuuU69A/gRCilXZzEYb7drQel9qfFYuaWnn6djy DTBUIwl0s8SG0X/F6mafEkD5cFO7jlNpDVHvV7LyDUTUw8Dh/ExlXk75Rykk9dI2+G thaPpZ1iya0IQ== From: Chuck Lever To: Subject: [PATCH v1 1/9] tlshd: Require the clientAuth key purpose on client certificates Date: Tue, 1 Dec 2026 16:42:40 -0500 Message-ID: <20261201214249.296675-2-cel@kernel.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201214249.296675-1-cel@kernel.org> References: <20261201214249.296675-1-cel@kernel.org> X-Mailing-List: kernel-tls-handshake@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tlshd_server_x509_verify_function() checks a client's certificate chain with gnutls_certificate_verify_peers3(). With a NULL hostname, that call hands GnuTLS no typed data at all, so GnuTLS does not check the extended key usage of the end-entity certificate. A certificate issued only for TLS server authentication passes, and tlshd reports the peer to the kernel as authenticated. When no server trust store is configured, the trust anchors are the system's public CAs, which now issue serverAuth-only certificates. Any holder of such a certificate is then accepted as an mTLS client by NFSD. Pass GNUTLS_KP_TLS_WWW_CLIENT to gnutls_certificate_verify_peers(). GnuTLS then rejects an end-entity certificate whose extended key usage extension omits clientAuth and anyPurpose. A certificate that carries no extended key usage extension is still accepted, as RFC 5280 Section 4.2.1.12 permits. Fixes: 9d1b6a30d57c ("tlshd: Basic support for ServerHello") Signed-off-by: Chuck Lever --- src/tlshd/server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tlshd/server.c b/src/tlshd/server.c index 10a63c2a6a63..4cb97b03c4a1 100644 --- a/src/tlshd/server.c +++ b/src/tlshd/server.c @@ -330,11 +330,15 @@ static int tlshd_server_get_truststore(gnutls_certificate_credentials_t cred) static int tlshd_server_x509_verify_function(gnutls_session_t session, struct tlshd_handshake_parms *parms) { + gnutls_typed_vdata_st data = { + .type = GNUTLS_DT_KEY_PURPOSE_OID, + .data = (void *)GNUTLS_KP_TLS_WWW_CLIENT, + }; const gnutls_datum_t *peercerts; unsigned int i, status, num_peercerts; int ret; - ret = gnutls_certificate_verify_peers3(session, NULL, &status); + ret = gnutls_certificate_verify_peers(session, &data, 1, &status); switch (ret) { case GNUTLS_E_SUCCESS: break; @@ -350,10 +354,6 @@ static int tlshd_server_x509_verify_function(gnutls_session_t session, goto certificate_error; } - /* To do: Examine extended key usage information here, if we want - * to get picky. Kernel would have to tell us what to look for - * via a netlink attribute. */ - peercerts = gnutls_certificate_get_peers(session, &num_peercerts); if (!peercerts || num_peercerts == 0) { tlshd_log_debug("The peer cert list is empty."); -- 2.56.0