public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Paulo Alcantara <paalcant@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/cifs-utils] f43: Fix local privilege boundary bypass through credential-file
Date: Fri, 16 Oct 2026 21:39:41 GMT [thread overview]
Message-ID: <179218678198.1.8888074258028066452.rpms-cifs-utils-9f3749293bd8@fedoraproject.org> (raw)
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
+
reply other threads:[~2026-10-16 21:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179218678198.1.8888074258028066452.rpms-cifs-utils-9f3749293bd8@fedoraproject.org \
--to=paalcant@redhat.com \
--cc=git-commits@fedoraproject.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox