From b939182137c4f044572de070d2ffba182acc683d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 18 Mar 2026 12:24:47 +0100 Subject: [PATCH] CVE-2026-4408: samr-server: Deny usernames with shell meta-chars in validatepassword We pass this on to the check password script, prevent remote command execution. Bug: https://bugzilla.samba.org/show_bug.cgi?id=16034 Signed-off-by: Volker Lendecke --- source3/rpc_server/samr/srv_samr_chgpasswd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source3/rpc_server/samr/srv_samr_chgpasswd.c b/source3/rpc_server/samr/srv_samr_chgpasswd.c index 6c0c0da0cfc..d13bc70a5d4 100644 --- a/source3/rpc_server/samr/srv_samr_chgpasswd.c +++ b/source3/rpc_server/samr/srv_samr_chgpasswd.c @@ -1025,6 +1025,24 @@ NTSTATUS check_password_complexity(const char *username, return NT_STATUS_OK; } + { + char *escaped = NULL; + bool same; + + escaped = escape_shell_string(username); + if (escaped == NULL) { + return NT_STATUS_NO_MEMORY; + } + + same = (strcmp(username, escaped) == 0); + + SAFE_FREE(escaped); + + if (!same) { + return NT_STATUS_INVALID_USER_PRINCIPAL_NAME; + } + } + cmd = talloc_string_sub(tosctx, lp_check_password_script(tosctx, lp_sub), "%u", username); if (!cmd) { -- 2.34.1