All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: <kernel-tls-handshake@lists.linux.dev>
Subject: [PATCH 3/8] tlshd: Escape the client certificate description before logging it
Date: Sat,  5 Dec 2026 13:27:38 -0500	[thread overview]
Message-ID: <20261205182743.79220-4-cel@kernel.org> (raw)
In-Reply-To: <20261205182743.79220-1-cel@kernel.org>

When the debug loglevel is nonzero, tlshd_tls13_server_x509_handshake()
logs the one-line description of each certificate the client presented,
including certificates that failed verification. The subject and
issuer names in that description are chosen by whoever created the
certificate, and any network client can present a self-signed one. A
newline or terminal escape sequence in a name reaches the LOG_AUTH
facility unmodified, where it can look like a separate authentication
record.

Pass the description through g_strescape() before logging it. As a
side effect, non-ASCII characters in a name appear as octal escapes,
and the backslashes of RFC 4514 escaping appear doubled.

Fixes: 2f68c313c9a9 ("tlshd: Show ingress certificate on successful handshake")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
 src/tlshd/server.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/tlshd/server.c b/src/tlshd/server.c
index 34965b0b036b..19266054999c 100644
--- a/src/tlshd/server.c
+++ b/src/tlshd/server.c
@@ -480,7 +480,12 @@ static void tlshd_tls13_server_x509_handshake(struct tlshd_handshake_parms *parm
 					       GNUTLS_X509_FMT_DER);
 			if (gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_ONELINE,
 						  &cinfo) == 0) {
-				tlshd_log_debug("Peer certificate: %s", cinfo.data);
+				gchar *desc;
+
+				desc = g_strescape((const gchar *)cinfo.data,
+						   NULL);
+				tlshd_log_debug("Peer certificate: %s", desc);
+				g_free(desc);
 				gnutls_free(cinfo.data);
 			}
 			gnutls_x509_crt_deinit(cert);
-- 
2.56.0


  parent reply	other threads:[~2026-12-05 18:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 18:27 [PATCH 0/8] More security-related fixes Chuck Lever
2026-12-05 18:27 ` [PATCH 1/8] tlshd: Unlink keyrings that a reload removes from the configuration Chuck Lever
2026-12-05 18:27 ` [PATCH 2/8] tlshd: Escape client PSK identities before logging them Chuck Lever
2026-12-05 18:27 ` Chuck Lever [this message]
2026-12-05 18:27 ` [PATCH 4/8] tlshd: Limit the number of concurrent handshake processes Chuck Lever
2026-12-05 18:27 ` [PATCH 5/8] tlshd: Enforce the QUIC handshake timeout in the event loop Chuck Lever
2026-12-05 18:27 ` [PATCH 6/8] tlshd: Strip whitespace from keyring names Chuck Lever
2026-12-05 18:27 ` [PATCH 7/8] tlshd: Escape certificate names before logging tag filter results Chuck Lever
2026-12-05 18:27 ` [PATCH 8/8] tlshd: Skip the session ticket after a failed QUIC handshake Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205182743.79220-4-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=kernel-tls-handshake@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.