public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/cifs-utils] f43: Fix local privilege boundary bypass through credential-file
@ 2026-10-16 21:39 Paulo Alcantara
  0 siblings, 0 replies; only message in thread
From: Paulo Alcantara @ 2026-10-16 21:39 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/cifs-utils
            Branch : f43
            Commit : 9f3749293bd831e1246278b1791ccae36b1e7b8e
            Author : Paulo Alcantara <paalcant@redhat.com>
            Date   : 2026-10-16T18:25:25-03:00
            Stats  : +151/-0 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/cifs-utils/c/9f3749293bd831e1246278b1791ccae36b1e7b8e?branch=f43

            Log:
            Fix local privilege boundary bypass through credential-file

 - Resolves: CVE-2026-104715

Signed-off-by: Paulo Alcantara <paalcant@redhat.com>

---
diff --git a/cifs-utils.spec b/cifs-utils.spec
index b2a84c5..c0e5f03 100644
--- a/cifs-utils.spec
+++ b/cifs-utils.spec
@@ -23,6 +23,8 @@ Recommends: %{name}-info%{?_isa} = %{version}-%{release}
 Source0:         https://download.samba.org/pub/linux-cifs/cifs-utils/%{name}-%{version}.tar.bz2
 
 Patch0: cifs.upcall-fix-krb5-regression-with-trust-dns.patch
+Patch1: mount.cifs-reject-option-delimiters-in-username-and-.patch
+Patch2: mount.cifs-validate-username-derived-from-the-passwd.patch
 
 %description
 The SMB/CIFS protocol is a standard file sharing protocol widely deployed

diff --git a/mount.cifs-reject-option-delimiters-in-username-and-.patch b/mount.cifs-reject-option-delimiters-in-username-and-.patch
new file mode 100644
index 0000000..822d361
--- /dev/null
+++ b/mount.cifs-reject-option-delimiters-in-username-and-.patch
@@ -0,0 +1,95 @@
+From d561eb914a389f6f2f009f13f0d09df0887bae72 Mon Sep 17 00:00:00 2001
+From: Paulo Alcantara <pc@manguebit.org>
+Date: Thu, 17 Sep 2026 14:08:50 -0300
+Subject: [PATCH] mount.cifs: reject option delimiters in username and domain
+
+The username= and domain= values from a credentials file, and the USER
+environment variable, are copied verbatim into the kernel mount option
+string as user=<value>/domain=<value>.  The kernel option parser is
+comma separated and last-write-wins, so a value like
+
+  username=smbuser,uid=0,forceuid,noperm
+
+injects further options past mount.cifs's uid=/gid= sanitizer, yielding
+a root-owned mount with permission checks disabled.  A caller that can
+control the credentials file (e.g. pam_mount) thus gains local root.
+
+Reject username and domain values containing an option delimiter (comma,
+equals, CR or LF) at the two untokenized inputs.  Command-line
+-o user=/domain= is already split on commas, and passwords are left
+alone as they may legitimately contain these characters.
+
+Reported-by: Johnathan Benge <jcbenge@amazon.com>
+Fixes: c610039ef674 ("mount.cifs: add username and domain fields to parsed_mount_info")
+Reviewed-by: Bharath SM <bharathsm@microsoft.com>
+Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
+Tested-by: Johnathan Benge <jcbenge@amazon.com>
+Signed-off-by: Paulo Alcantara <pc@manguebit.org>
+---
+ mount.cifs.c | 25 +++++++++++++++++++++++--
+ 1 file changed, 23 insertions(+), 2 deletions(-)
+
+diff --git a/mount.cifs.c b/mount.cifs.c
+index f0e9bc7beae2..72beae874209 100644
+--- a/mount.cifs.c
++++ b/mount.cifs.c
+@@ -588,6 +588,11 @@ parsing_err:
+ 	return CRED_UNPARSEABLE;
+ }
+ 
++static int check_creds_field(const char *v)
++{
++	return strpbrk(v, ",=\r\n") != NULL;
++}
++
+ static int open_cred_file(char *file_name,
+ 			struct parsed_mount_info *parsed_info)
+ {
+@@ -638,6 +643,11 @@ static int open_cred_file(char *file_name,
+ 		/* parse next token */
+ 		switch (parse_cred_line(line_buf + i, &temp_val)) {
+ 		case CRED_USER:
++			if (check_creds_field(temp_val)) {
++				fprintf(stderr, "Invalid username in credentials file\n");
++				i = EX_USAGE;
++				goto return_i;
++			}
+ 			strlcpy(parsed_info->username, temp_val,
+ 				sizeof(parsed_info->username));
+ 			parsed_info->got_user = 1;
+@@ -653,6 +663,11 @@ static int open_cred_file(char *file_name,
+ 				goto return_i;
+ 			break;
+ 		case CRED_DOM:
++			if (check_creds_field(temp_val)) {
++				fprintf(stderr, "Invalid domain in credentials file\n");
++				i = EX_USAGE;
++				goto return_i;
++			}
+ 			strlcpy(parsed_info->domain, temp_val,
+ 				sizeof(parsed_info->domain));
+ 			break;
+@@ -2006,12 +2021,18 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info,
+ 		 * USER env variable (ie user%password form) as there is
+ 		 * already a PASSWD environment varaible
+ 		 */
+-		if (getenv("USER"))
++		if (getenv("USER")) {
++			if (check_creds_field(getenv("USER"))) {
++				fprintf(stderr, "Invalid username in USER environment variable\n");
++				rc = EX_USAGE;
++				goto assemble_exit;
++			}
+ 			strlcpy(parsed_info->username, getenv("USER"),
+ 				sizeof(parsed_info->username));
+-		else
++		} else {
+ 			strlcpy(parsed_info->username, getusername(getuid()),
+ 				sizeof(parsed_info->username));
++		}
+ 		parsed_info->got_user = 1;
+ 	}
+ 
+-- 
+2.56.0
+

diff --git a/mount.cifs-validate-username-derived-from-the-passwd.patch b/mount.cifs-validate-username-derived-from-the-passwd.patch
new file mode 100644
index 0000000..6a1d291
--- /dev/null
+++ b/mount.cifs-validate-username-derived-from-the-passwd.patch
@@ -0,0 +1,54 @@
+From fa0ba5a155ef925bb7547cb4cdc36425a2f5b8f9 Mon Sep 17 00:00:00 2001
+From: Paulo Alcantara <pc@manguebit.org>
+Date: Thu, 17 Sep 2026 14:49:39 -0300
+Subject: [PATCH] mount.cifs: validate username derived from the passwd
+ database
+
+When neither the credentials file nor the USER environment variable
+supplies a username, assemble_mountinfo() falls back to the caller's
+passwd login name via getusername(getuid()) and copies it verbatim into
+the "user=" mount option, just like the other two sources.  Run it
+through check_creds_field() as well so the invariant "the username never
+contains an option delimiter" holds regardless of where the username
+came from.  Unlike the credentials file and USER env, this value is not
+attacker-controlled, so this is defense in depth rather than a fix for
+the injection itself.
+
+While here, guard against getusername() returning NULL (no passwd entry
+for the uid), which was previously passed straight into strlcpy().
+
+Reviewed-by: Bharath SM <bharathsm@microsoft.com>
+Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
+Signed-off-by: Paulo Alcantara <pc@manguebit.org>
+---
+ mount.cifs.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/mount.cifs.c b/mount.cifs.c
+index 72beae874209..671d58fc919b 100644
+--- a/mount.cifs.c
++++ b/mount.cifs.c
+@@ -2030,8 +2030,18 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info,
+ 			strlcpy(parsed_info->username, getenv("USER"),
+ 				sizeof(parsed_info->username));
+ 		} else {
+-			strlcpy(parsed_info->username, getusername(getuid()),
+-				sizeof(parsed_info->username));
++			char *username = getusername(getuid());
++
++			if (username) {
++				if (check_creds_field(username)) {
++					fprintf(stderr, "Invalid username for uid %u\n",
++						(unsigned int)getuid());
++					rc = EX_USAGE;
++					goto assemble_exit;
++				}
++				strlcpy(parsed_info->username, username,
++					sizeof(parsed_info->username));
++			}
+ 		}
+ 		parsed_info->got_user = 1;
+ 	}
+-- 
+2.56.0
+

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-16 21:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 21:39 [rpms/cifs-utils] f43: Fix local privilege boundary bypass through credential-file Paulo Alcantara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox