From a8e08bb3b44c80b35c9e2d6039e41a7cfb3bc8a6 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze@samba.org>
Date: Fri, 8 May 2026 23:27:35 +0200
Subject: [PATCH 37/38] CVE-2026-4408: s3:testparm: warn about 'check password
 script' %u usage

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16034

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
---
 source3/utils/testparm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -276,6 +276,7 @@ static int do_global_checks(void)
 	const char *socket_options;
 	const struct loadparm_substitution *lp_sub =
 		loadparm_s3_global_substitution();
+	const char *check_pw_script = NULL;
 
 	fprintf(stderr, "\n");
 
@@ -697,6 +698,17 @@ static int do_global_checks(void)
 			"CVE-2022-37966\n\n");
 	}
 
+	check_pw_script = lp_check_password_script(talloc_tos(), lp_sub);
+	if (talloc_string_sub_mixed_quoting(check_pw_script, 'u')) {
+		fprintf(stderr,
+			"WARNING: You are using 'check password script' "
+			"with mixed quoting and %%u.\n"
+			"CVE-2026-4408 changed the way %%u substitution works. \n"
+			"You should use the SAMBA_CPS_ACCOUNT_NAME "
+			"environment variable exported to the script, or\n"
+			"at least use single quotes (directly) around '%%u'.\n\n");
+	}
+
 	return ret;
 }
 
