summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2024-10-28 16:47:41 +0800
committerArmin Kuster <akuster808@gmail.com>2024-12-08 14:39:17 -0500
commit5782095b7bb750250651837751609a9945ddff57 (patch)
treeaf9025d791d3f6c169d82df703b564798d8624c1 /meta-networking/recipes-support
parent33eb562e382d0c90fc6574c3de2fff3e79a414cf (diff)
downloadmeta-openembedded-5782095b7bb750250651837751609a9945ddff57.tar.gz
open-vm-tools: Security fixes CVE-2023-34059
CVE-2023-34059: open-vm-tools contains a file descriptor hijack vulnerability in the vmware-user-suid-wrapper. A malicious actor with non-root privileges may be able to hijack the /dev/uinput file descriptor allowing them to simulate user inputs. Reference: https://nvd.nist.gov/vuln/detail/CVE-2023-34059 Patch from: https://github.com/vmware/open-vm-tools/blob/CVE-2023-34059.patch/CVE-2023-34059.patch Signed-off-by: Yi Zhao <yi.zhao@windriver.com> Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-networking/recipes-support')
-rw-r--r--meta-networking/recipes-support/open-vm-tools/open-vm-tools/CVE-2023-34059.patch188
-rw-r--r--meta-networking/recipes-support/open-vm-tools/open-vm-tools_11.3.5.bb1
2 files changed, 189 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/open-vm-tools/open-vm-tools/CVE-2023-34059.patch b/meta-networking/recipes-support/open-vm-tools/open-vm-tools/CVE-2023-34059.patch
new file mode 100644
index 0000000000..9a806c79a2
--- /dev/null
+++ b/meta-networking/recipes-support/open-vm-tools/open-vm-tools/CVE-2023-34059.patch
@@ -0,0 +1,188 @@
1From 2011181cbe60b256ced8d28daf7b704e8613467c Mon Sep 17 00:00:00 2001
2From: John Wolfe <jwolfe@vmware.com>
3Date: Wed, 18 Oct 2023 09:11:54 -0700
4Subject: [PATCH] Address CVE-2023-34059
5
6Fix file descriptor vulnerability in the open-vm-tools
7 vmware-user-suid-wrapper on Linux.
8 - Moving the privilege drop logic (dropping privilege to the real uid
9 and gid of the process for the vmusr service) from suidWrapper to
10 vmtoolsd code.
11
12CVE: CVE-2023-34059
13
14Upstream-Status: Backport
15[https://github.com/vmware/open-vm-tools/blob/CVE-2023-34059.patch/CVE-2023-34059.patch]
16
17Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
18---
19 open-vm-tools/services/vmtoolsd/mainPosix.c | 76 +++++++++++++++++++++++++++
20 open-vm-tools/vmware-user-suid-wrapper/main.c | 26 ++-------
21 2 files changed, 79 insertions(+), 23 deletions(-)
22
23diff --git a/open-vm-tools/services/vmtoolsd/mainPosix.c b/open-vm-tools/services/vmtoolsd/mainPosix.c
24index fd2667c..8b46979 100644
25--- a/open-vm-tools/services/vmtoolsd/mainPosix.c
26+++ b/open-vm-tools/services/vmtoolsd/mainPosix.c
27@@ -28,10 +28,12 @@
28 #include <signal.h>
29 #include <string.h>
30 #include <unistd.h>
31+#include <fcntl.h>
32 #include <glib/gstdio.h>
33 #include "file.h"
34 #include "guestApp.h"
35 #include "hostinfo.h"
36+#include "su.h"
37 #include "system.h"
38 #include "unicode.h"
39 #include "util.h"
40@@ -155,6 +157,59 @@ ToolsCoreWorkAroundLoop(ToolsServiceState *state,
41
42
43 /**
44+ * Tools function to set close-on-exec flg for the fd.
45+ *
46+ * @param[in] fd open file descriptor.
47+ *
48+ * @return TRUE on success, FALSE otherwise.
49+ */
50+
51+static gboolean
52+ToolsSetCloexecFlag(int fd)
53+{
54+ int flags;
55+
56+ if (fd == -1) {
57+ /* fd is not present, no need to manipulate */
58+ return TRUE;
59+ }
60+
61+ flags = fcntl(fd, F_GETFD, 0);
62+ if (flags < 0) {
63+ g_printerr("Couldn't get the flags set for fd %d, error %u.", fd, errno);
64+ return FALSE;
65+ }
66+ flags |= FD_CLOEXEC;
67+ if (fcntl(fd, F_SETFD, flags) < 0) {
68+ g_printerr("Couldn't set close-on-exec for fd %d, error %u.", fd, errno);
69+ return FALSE;
70+ }
71+
72+ return TRUE;
73+}
74+
75+
76+/**
77+ * Tools function to close the fds.
78+ */
79+
80+static void
81+ToolsCloseFds(void)
82+{
83+ if (gState.ctx.blockFD != -1) {
84+ close(gState.ctx.blockFD);
85+ }
86+
87+ /*
88+ * uinputFD will be available only for wayland.
89+ */
90+ if (gState.ctx.uinputFD != -1) {
91+ close(gState.ctx.uinputFD);
92+ }
93+}
94+
95+
96+/**
97 * Tools daemon entry function.
98 *
99 * @param[in] argc Argument count.
100@@ -210,6 +265,27 @@ main(int argc,
101 g_free(argvCopy);
102 argvCopy = NULL;
103
104+ /*
105+ * Drops privilege to the real uid and gid of the process
106+ * for the "vmusr" service.
107+ */
108+ if (TOOLS_IS_USER_SERVICE(&gState)) {
109+ uid_t uid = getuid();
110+ gid_t gid = getgid();
111+
112+ if ((Id_SetREUid(uid, uid) != 0) ||
113+ (Id_SetREGid(gid, gid) != 0)) {
114+ g_printerr("could not drop privileges: %s", strerror(errno));
115+ ToolsCloseFds();
116+ goto exit;
117+ }
118+ if (!ToolsSetCloexecFlag(gState.ctx.blockFD) ||
119+ !ToolsSetCloexecFlag(gState.ctx.uinputFD)) {
120+ ToolsCloseFds();
121+ goto exit;
122+ }
123+ }
124+
125 if (gState.pidFile != NULL) {
126 /*
127 * If argv[0] is not an absolute path, make it so; all other path
128diff --git a/open-vm-tools/vmware-user-suid-wrapper/main.c b/open-vm-tools/vmware-user-suid-wrapper/main.c
129index e9d7e50..a19af53 100644
130--- a/open-vm-tools/vmware-user-suid-wrapper/main.c
131+++ b/open-vm-tools/vmware-user-suid-wrapper/main.c
132@@ -156,8 +156,7 @@ MaskSignals(void)
133 *
134 * Obtains the library directory from the Tools locations database, then
135 * opens a file descriptor (while still root) to add and remove blocks,
136- * drops privilege to the real uid of this process, and finally starts
137- * vmware-user.
138+ * and finally starts vmware-user.
139 *
140 * Results:
141 * Parent: TRUE on success, FALSE on failure.
142@@ -173,8 +172,6 @@ static Bool
143 StartVMwareUser(char *const envp[])
144 {
145 pid_t pid;
146- uid_t uid;
147- gid_t gid;
148 int blockFd = -1;
149 char blockFdStr[8];
150 int uinputFd = -1;
151@@ -191,8 +188,8 @@ StartVMwareUser(char *const envp[])
152 }
153
154 /*
155- * Now create a child process, obtain a file descriptor as root, downgrade
156- * privilege, and run vmware-user.
157+ * Now create a child process, obtain a file descriptor as root and
158+ * run vmware-user.
159 */
160 pid = fork();
161 if (pid == -1) {
162@@ -229,23 +226,6 @@ StartVMwareUser(char *const envp[])
163 }
164 }
165
166- uid = getuid();
167- gid = getgid();
168-
169- if ((setreuid(uid, uid) != 0) ||
170- (setregid(gid, gid) != 0)) {
171- Error("could not drop privileges: %s\n", strerror(errno));
172- if (blockFd != -1) {
173- close(blockFd);
174- }
175- if (useWayland) {
176- if (uinputFd != -1) {
177- close(uinputFd);
178- }
179- }
180- return FALSE;
181- }
182-
183 /*
184 * Since vmware-user provides features that don't depend on vmblock, we
185 * invoke vmware-user even if we couldn't obtain a file descriptor or we
186--
1872.6.2
188
diff --git a/meta-networking/recipes-support/open-vm-tools/open-vm-tools_11.3.5.bb b/meta-networking/recipes-support/open-vm-tools/open-vm-tools_11.3.5.bb
index c54fd4de48..762ac4c0e9 100644
--- a/meta-networking/recipes-support/open-vm-tools/open-vm-tools_11.3.5.bb
+++ b/meta-networking/recipes-support/open-vm-tools/open-vm-tools_11.3.5.bb
@@ -48,6 +48,7 @@ SRC_URI = "git://github.com/vmware/open-vm-tools.git;protocol=https;branch=maste
48 file://CVE-2023-20867.patch;patchdir=.. \ 48 file://CVE-2023-20867.patch;patchdir=.. \
49 file://CVE-2023-20900.patch;patchdir=.. \ 49 file://CVE-2023-20900.patch;patchdir=.. \
50 file://CVE-2023-34058.patch;patchdir=.. \ 50 file://CVE-2023-34058.patch;patchdir=.. \
51 file://CVE-2023-34059.patch;patchdir=.. \
51 " 52 "
52 53
53UPSTREAM_CHECK_GITTAGREGEX = "stable-(?P<pver>\d+(\.\d+)+)" 54UPSTREAM_CHECK_GITTAGREGEX = "stable-(?P<pver>\d+(\.\d+)+)"