[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/14] ui: validate NUL byte padding in SASL client data more stri
From: |
Daniel P . Berrangé |
Subject: |
[PULL 13/14] ui: validate NUL byte padding in SASL client data more strictly |
Date: |
Tue, 22 Oct 2024 16:24:14 +0100 |
When the SASL data is non-NULL, the SASL protocol spec requires that
it is padded with a trailing NUL byte. QEMU discards the trailing
byte, but does not currently validate that it was in fact a NUL.
Apply strict validation to better detect any broken clients.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
ui/vnc-auth-sasl.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index a04feeb429..3f4cfc471d 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -263,8 +263,14 @@ static int protocol_client_auth_sasl_step(VncState *vs,
uint8_t *data, size_t le
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (datalen) {
clientdata = (char*)data;
- clientdata[datalen-1] = '\0'; /* Wire includes '\0', but make sure */
- datalen--; /* Don't count NULL byte when passing to _start() */
+ if (clientdata[datalen - 1] != '\0') {
+ trace_vnc_auth_fail(vs, vs->auth, "Malformed SASL client data",
+ "Missing SASL NUL padding byte");
+ sasl_dispose(&vs->sasl.conn);
+ vs->sasl.conn = NULL;
+ goto authabort;
+ }
+ datalen--; /* Discard the extra NUL padding byte */
}
err = sasl_server_step(vs->sasl.conn,
@@ -385,8 +391,14 @@ static int protocol_client_auth_sasl_start(VncState *vs,
uint8_t *data, size_t l
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (datalen) {
clientdata = (char*)data;
- clientdata[datalen-1] = '\0'; /* Should be on wire, but make sure */
- datalen--; /* Don't count NULL byte when passing to _start() */
+ if (clientdata[datalen - 1] != '\0') {
+ trace_vnc_auth_fail(vs, vs->auth, "Malformed SASL client data",
+ "Missing SASL NUL padding byte");
+ sasl_dispose(&vs->sasl.conn);
+ vs->sasl.conn = NULL;
+ goto authabort;
+ }
+ datalen--; /* Discard the extra NUL padding byte */
}
err = sasl_server_start(vs->sasl.conn,
--
2.46.0
- [PULL 04/14] crypto/hash: avoid overwriting user supplied result pointer, (continued)
- [PULL 04/14] crypto/hash: avoid overwriting user supplied result pointer, Daniel P . Berrangé, 2024/10/22
- [PULL 05/14] tests: correctly validate result buffer in hash/hmac tests, Daniel P . Berrangé, 2024/10/22
- [PULL 06/14] include/crypto: clarify @result/@result_len for hash/hmac APIs, Daniel P . Berrangé, 2024/10/22
- [PULL 07/14] crypto/hash-afalg: Fix broken build, Daniel P . Berrangé, 2024/10/22
- [PULL 08/14] ui/vnc: don't return an empty SASL mechlist to the client, Daniel P . Berrangé, 2024/10/22
- [PULL 09/14] ui/vnc: don't raise error formatting socket address for non-inet, Daniel P . Berrangé, 2024/10/22
- [PULL 10/14] ui/vnc: fix skipping SASL SSF on UNIX sockets, Daniel P . Berrangé, 2024/10/22
- [PULL 11/14] ui/vnc: don't check for SSF after SASL authentication on UNIX sockets, Daniel P . Berrangé, 2024/10/22
- [PULL 12/14] ui: fix handling of NULL SASL server data, Daniel P . Berrangé, 2024/10/22
- [PULL 14/14] gitlab: enable afalg tests in fedora system test, Daniel P . Berrangé, 2024/10/22
- [PULL 13/14] ui: validate NUL byte padding in SASL client data more strictly,
Daniel P . Berrangé <=
- Re: [PULL 00/14] Misc fixes patches, Peter Maydell, 2024/10/24