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 2/8] tlshd: Escape client PSK identities before logging them
Date: Sat,  5 Dec 2026 13:27:37 -0500	[thread overview]
Message-ID: <20261205182743.79220-3-cel@kernel.org> (raw)
In-Reply-To: <20261205182743.79220-1-cel@kernel.org>

The PSK identity in a ClientHello is chosen by the remote client and
arrives before any authentication. When no key matches it, both
server PSK callbacks pass the identity unmodified to syslog at
LOG_ERR in the LOG_AUTH facility. A client can embed newlines or
terminal escape sequences in the identity to add what look like
separate records to the authentication log, or to disturb a terminal
that displays the log.

Pass the identity through g_strescape() before logging it.

Fixes: 4632eb9bba64 ("tlshd: improve error logging for tlshd_server_psk_cb()")
Fixes: 43a15fed2f33 ("tlshd: add support for quic handshake")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
 src/tlshd/server.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/tlshd/server.c b/src/tlshd/server.c
index 206fb9a45401..34965b0b036b 100644
--- a/src/tlshd/server.c
+++ b/src/tlshd/server.c
@@ -543,8 +543,11 @@ static int tlshd_server_psk_cb(gnutls_session_t session,
 
 	ret = tlshd_server_psk_search(TLS_DEFAULT_PSK_TYPE, username);
 	if (ret < 0) {
+		gchar *identity = g_strescape(username, NULL);
+
 		tlshd_log_error("failed to search '%s' key '%s'",
-				TLS_DEFAULT_PSK_TYPE, username);
+				TLS_DEFAULT_PSK_TYPE, identity);
+		g_free(identity);
 		return -1;
 	}
 
@@ -731,7 +734,11 @@ static int tlshd_quic_server_psk_cb(gnutls_session_t session, const char *userna
 
 	ret = tlshd_server_psk_search(TLS_DEFAULT_PSK_TYPE, username);
 	if (ret < 0) {
-		tlshd_log_error("key search error %d %s", errno, username);
+		int err = errno;
+		gchar *identity = g_strescape(username, NULL);
+
+		tlshd_log_error("key search error %d %s", err, identity);
+		g_free(identity);
 		return -1;
 	}
 
-- 
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 ` Chuck Lever [this message]
2026-12-05 18:27 ` [PATCH 3/8] tlshd: Escape the client certificate description before logging it Chuck Lever
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-3-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.