From: Chuck Lever <cel@kernel.org>
To: <kernel-tls-handshake@lists.linux.dev>
Subject: [PATCH 7/8] tlshd: Escape certificate names before logging tag filter results
Date: Sat, 5 Dec 2026 13:27:42 -0500 [thread overview]
Message-ID: <20261205182743.79220-8-cel@kernel.org> (raw)
In-Reply-To: <20261205182743.79220-1-cel@kernel.org>
When the debug loglevel is nonzero, the x.509 issuer and subject tag
filters log the issuer or subject DN of the peer's certificate.
Whoever created the certificate chose the names in both DNs.
gnutls_x509_crt_get_dn3() and gnutls_x509_crt_get_issuer_dn3() can
return a DN that contains a raw newline or escape character, and such
a DN passes the UTF-8 check. A newline logged this way can make part
of a name look like a separate log record.
Pass each DN through g_strescape() before logging it. The filters
still match against the unescaped DN. Non-ASCII characters in a logged
name now appear as octal escapes, and the backslashes of RFC 4514
escaping appear doubled.
Fixes: f11519ab4a45 ("tlshd: Match ingress certificates with defined TLS session tags")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
src/tlshd/tags.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/tlshd/tags.c b/src/tlshd/tags.c
index 1863f4b34510..ed83062433b1 100644
--- a/src/tlshd/tags.c
+++ b/src/tlshd/tags.c
@@ -1505,6 +1505,7 @@ tlshd_tags_filter_type_match_x509_tbs_issuer(struct tlshd_tags_filter *filter,
gnutls_x509_crt_t peercert;
gnutls_datum_t dn;
bool res = false;
+ gchar *desc;
int ret;
if (!tlshd_tags_get_peer_x509_cert(session, &peercert))
@@ -1530,10 +1531,12 @@ tlshd_tags_filter_type_match_x509_tbs_issuer(struct tlshd_tags_filter *filter,
(const gchar *)dn.data, NULL);
#endif
+ desc = g_strescape((const gchar *)dn.data, NULL);
tlshd_log_debug("Filter '%s' %s issuer '%s'",
filter->fi_name,
res ? "matched" : "did not match",
- dn.data);
+ desc);
+ g_free(desc);
gnutls_free(dn.data);
deinit:
gnutls_x509_crt_deinit(peercert);
@@ -1627,6 +1630,7 @@ tlshd_tags_filter_type_match_x509_tbs_subject(struct tlshd_tags_filter *filter,
gnutls_x509_crt_t peercert;
gnutls_datum_t dn;
bool res = false;
+ gchar *desc;
int ret;
if (!tlshd_tags_get_peer_x509_cert(session, &peercert))
@@ -1652,10 +1656,12 @@ tlshd_tags_filter_type_match_x509_tbs_subject(struct tlshd_tags_filter *filter,
(const gchar *)dn.data, NULL);
#endif
+ desc = g_strescape((const gchar *)dn.data, NULL);
tlshd_log_debug("Filter '%s' %s subject '%s'",
filter->fi_name,
res ? "matched" : "did not match",
- dn.data);
+ desc);
+ g_free(desc);
gnutls_free(dn.data);
deinit:
gnutls_x509_crt_deinit(peercert);
--
2.56.0
next prev 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 ` [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 ` Chuck Lever [this message]
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-8-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.