summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/networking-layer/recipes-security/sssd/files
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers/networking-layer/recipes-security/sssd/files')
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/CVE-2021-3621.patch288
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/drop_ntpdate_chk.patch28
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/fix-ldblibdir.patch25
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/fix_gid.patch27
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/musl_fixup.patch53
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/no_gen.patch19
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/sssd.conf8
-rw-r--r--dynamic-layers/networking-layer/recipes-security/sssd/files/volatiles.99_sssd1
8 files changed, 449 insertions, 0 deletions
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/CVE-2021-3621.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/CVE-2021-3621.patch
new file mode 100644
index 0000000..7a59df9
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/CVE-2021-3621.patch
@@ -0,0 +1,288 @@
1Backport patch to fix CVE-2021-3621.
2
3Upstream-Status: Backport [https://github.com/SSSD/sssd/commit/7ab83f9]
4CVE: CVE-2021-3621
5
6Signed-off-by: Kai Kang <kai.kang@windriver.com>
7
8From 7ab83f97e1cbefb78ece17232185bdd2985f0bbe Mon Sep 17 00:00:00 2001
9From: Alexey Tikhonov <atikhono@redhat.com>
10Date: Fri, 18 Jun 2021 13:17:19 +0200
11Subject: [PATCH] TOOLS: replace system() with execvp() to avoid execution of
12 user supplied command
13MIME-Version: 1.0
14Content-Type: text/plain; charset=UTF-8
15Content-Transfer-Encoding: 8bit
16
17:relnote: A flaw was found in SSSD, where the sssctl command was
18vulnerable to shell command injection via the logs-fetch and
19cache-expire subcommands. This flaw allows an attacker to trick
20the root user into running a specially crafted sssctl command,
21such as via sudo, to gain root access. The highest threat from this
22vulnerability is to confidentiality, integrity, as well as system
23availability.
24This patch fixes a flaw by replacing system() with execvp().
25
26:fixes: CVE-2021-3621
27
28Reviewed-by: Pavel Březina <pbrezina@redhat.com>
29---
30 src/tools/sssctl/sssctl.c | 39 ++++++++++++++++-------
31 src/tools/sssctl/sssctl.h | 2 +-
32 src/tools/sssctl/sssctl_data.c | 57 +++++++++++-----------------------
33 src/tools/sssctl/sssctl_logs.c | 32 +++++++++++++++----
34 4 files changed, 73 insertions(+), 57 deletions(-)
35
36diff --git a/src/tools/sssctl/sssctl.c b/src/tools/sssctl/sssctl.c
37index 2997dbf968..8adaf30910 100644
38--- a/src/tools/sssctl/sssctl.c
39+++ b/src/tools/sssctl/sssctl.c
40@@ -97,22 +97,36 @@ sssctl_prompt(const char *message,
41 return SSSCTL_PROMPT_ERROR;
42 }
43
44-errno_t sssctl_run_command(const char *command)
45+errno_t sssctl_run_command(const char *const argv[])
46 {
47 int ret;
48+ int wstatus;
49
50- DEBUG(SSSDBG_TRACE_FUNC, "Running %s\n", command);
51+ DEBUG(SSSDBG_TRACE_FUNC, "Running '%s'\n", argv[0]);
52
53- ret = system(command);
54+ ret = fork();
55 if (ret == -1) {
56- DEBUG(SSSDBG_CRIT_FAILURE, "Unable to execute %s\n", command);
57 ERROR("Error while executing external command\n");
58 return EFAULT;
59- } else if (WEXITSTATUS(ret) != 0) {
60- DEBUG(SSSDBG_CRIT_FAILURE, "Command %s failed with [%d]\n",
61- command, WEXITSTATUS(ret));
62+ }
63+
64+ if (ret == 0) {
65+ /* cast is safe - see
66+ https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
67+ "The statement about argv[] and envp[] being constants ... "
68+ */
69+ execvp(argv[0], discard_const_p(char * const, argv));
70 ERROR("Error while executing external command\n");
71- return EIO;
72+ _exit(1);
73+ } else {
74+ if (waitpid(ret, &wstatus, 0) == -1) {
75+ ERROR("Error while executing external command '%s'\n", argv[0]);
76+ return EFAULT;
77+ } else if (WEXITSTATUS(wstatus) != 0) {
78+ ERROR("Command '%s' failed with [%d]\n",
79+ argv[0], WEXITSTATUS(wstatus));
80+ return EIO;
81+ }
82 }
83
84 return EOK;
85@@ -132,11 +146,14 @@ static errno_t sssctl_manage_service(enum sssctl_svc_action action)
86 #elif defined(HAVE_SERVICE)
87 switch (action) {
88 case SSSCTL_SVC_START:
89- return sssctl_run_command(SERVICE_PATH" sssd start");
90+ return sssctl_run_command(
91+ (const char *[]){SERVICE_PATH, "sssd", "start", NULL});
92 case SSSCTL_SVC_STOP:
93- return sssctl_run_command(SERVICE_PATH" sssd stop");
94+ return sssctl_run_command(
95+ (const char *[]){SERVICE_PATH, "sssd", "stop", NULL});
96 case SSSCTL_SVC_RESTART:
97- return sssctl_run_command(SERVICE_PATH" sssd restart");
98+ return sssctl_run_command(
99+ (const char *[]){SERVICE_PATH, "sssd", "restart", NULL});
100 }
101 #endif
102
103diff --git a/src/tools/sssctl/sssctl.h b/src/tools/sssctl/sssctl.h
104index 0115b2457c..599ef65196 100644
105--- a/src/tools/sssctl/sssctl.h
106+++ b/src/tools/sssctl/sssctl.h
107@@ -47,7 +47,7 @@ enum sssctl_prompt_result
108 sssctl_prompt(const char *message,
109 enum sssctl_prompt_result defval);
110
111-errno_t sssctl_run_command(const char *command);
112+errno_t sssctl_run_command(const char *const argv[]); /* argv[0] - command */
113 bool sssctl_start_sssd(bool force);
114 bool sssctl_stop_sssd(bool force);
115 bool sssctl_restart_sssd(bool force);
116diff --git a/src/tools/sssctl/sssctl_data.c b/src/tools/sssctl/sssctl_data.c
117index 8d79b977fd..bf22913416 100644
118--- a/src/tools/sssctl/sssctl_data.c
119+++ b/src/tools/sssctl/sssctl_data.c
120@@ -105,15 +105,15 @@ static errno_t sssctl_backup(bool force)
121 }
122 }
123
124- ret = sssctl_run_command("sss_override user-export "
125- SSS_BACKUP_USER_OVERRIDES);
126+ ret = sssctl_run_command((const char *[]){"sss_override", "user-export",
127+ SSS_BACKUP_USER_OVERRIDES, NULL});
128 if (ret != EOK) {
129 ERROR("Unable to export user overrides\n");
130 return ret;
131 }
132
133- ret = sssctl_run_command("sss_override group-export "
134- SSS_BACKUP_GROUP_OVERRIDES);
135+ ret = sssctl_run_command((const char *[]){"sss_override", "group-export",
136+ SSS_BACKUP_GROUP_OVERRIDES, NULL});
137 if (ret != EOK) {
138 ERROR("Unable to export group overrides\n");
139 return ret;
140@@ -158,8 +158,8 @@ static errno_t sssctl_restore(bool force_start, bool force_restart)
141 }
142
143 if (sssctl_backup_file_exists(SSS_BACKUP_USER_OVERRIDES)) {
144- ret = sssctl_run_command("sss_override user-import "
145- SSS_BACKUP_USER_OVERRIDES);
146+ ret = sssctl_run_command((const char *[]){"sss_override", "user-import",
147+ SSS_BACKUP_USER_OVERRIDES, NULL});
148 if (ret != EOK) {
149 ERROR("Unable to import user overrides\n");
150 return ret;
151@@ -167,8 +167,8 @@ static errno_t sssctl_restore(bool force_start, bool force_restart)
152 }
153
154 if (sssctl_backup_file_exists(SSS_BACKUP_USER_OVERRIDES)) {
155- ret = sssctl_run_command("sss_override group-import "
156- SSS_BACKUP_GROUP_OVERRIDES);
157+ ret = sssctl_run_command((const char *[]){"sss_override", "group-import",
158+ SSS_BACKUP_GROUP_OVERRIDES, NULL});
159 if (ret != EOK) {
160 ERROR("Unable to import group overrides\n");
161 return ret;
162@@ -296,40 +296,19 @@ errno_t sssctl_cache_expire(struct sss_cmdline *cmdline,
163 void *pvt)
164 {
165 errno_t ret;
166- char *cmd_args = NULL;
167- const char *cachecmd = SSS_CACHE;
168- char *cmd = NULL;
169- int i;
170-
171- if (cmdline->argc == 0) {
172- ret = sssctl_run_command(cachecmd);
173- goto done;
174- }
175
176- cmd_args = talloc_strdup(tool_ctx, "");
177- if (cmd_args == NULL) {
178- ret = ENOMEM;
179- goto done;
180+ const char **args = talloc_array_size(tool_ctx,
181+ sizeof(char *),
182+ cmdline->argc + 2);
183+ if (!args) {
184+ return ENOMEM;
185 }
186+ memcpy(&args[1], cmdline->argv, sizeof(char *) * cmdline->argc);
187+ args[0] = SSS_CACHE;
188+ args[cmdline->argc + 1] = NULL;
189
190- for (i = 0; i < cmdline->argc; i++) {
191- cmd_args = talloc_strdup_append(cmd_args, cmdline->argv[i]);
192- if (i != cmdline->argc - 1) {
193- cmd_args = talloc_strdup_append(cmd_args, " ");
194- }
195- }
196-
197- cmd = talloc_asprintf(tool_ctx, "%s %s", cachecmd, cmd_args);
198- if (cmd == NULL) {
199- ret = ENOMEM;
200- goto done;
201- }
202-
203- ret = sssctl_run_command(cmd);
204-
205-done:
206- talloc_free(cmd_args);
207- talloc_free(cmd);
208+ ret = sssctl_run_command(args);
209
210+ talloc_free(args);
211 return ret;
212 }
213diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c
214index 9ff2be05b6..ebb2c4571c 100644
215--- a/src/tools/sssctl/sssctl_logs.c
216+++ b/src/tools/sssctl/sssctl_logs.c
217@@ -31,6 +31,7 @@
218 #include <ldb.h>
219 #include <popt.h>
220 #include <stdio.h>
221+#include <glob.h>
222
223 #include "util/util.h"
224 #include "tools/common/sss_process.h"
225@@ -230,6 +231,7 @@ errno_t sssctl_logs_remove(struct sss_cmdline *cmdline,
226 {
227 struct sssctl_logs_opts opts = {0};
228 errno_t ret;
229+ glob_t globbuf;
230
231 /* Parse command line. */
232 struct poptOption options[] = {
233@@ -253,8 +255,20 @@ errno_t sssctl_logs_remove(struct sss_cmdline *cmdline,
234
235 sss_signal(SIGHUP);
236 } else {
237+ globbuf.gl_offs = 4;
238+ ret = glob(LOG_PATH"/*.log", GLOB_ERR|GLOB_DOOFFS, NULL, &globbuf);
239+ if (ret != 0) {
240+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to expand log files list\n");
241+ return ret;
242+ }
243+ globbuf.gl_pathv[0] = discard_const_p(char, "truncate");
244+ globbuf.gl_pathv[1] = discard_const_p(char, "--no-create");
245+ globbuf.gl_pathv[2] = discard_const_p(char, "--size");
246+ globbuf.gl_pathv[3] = discard_const_p(char, "0");
247+
248 PRINT("Truncating log files...\n");
249- ret = sssctl_run_command("truncate --no-create --size 0 " LOG_FILES);
250+ ret = sssctl_run_command((const char * const*)globbuf.gl_pathv);
251+ globfree(&globbuf);
252 if (ret != EOK) {
253 ERROR("Unable to truncate log files\n");
254 return ret;
255@@ -269,8 +283,8 @@ errno_t sssctl_logs_fetch(struct sss_cmdline *cmdline,
256 void *pvt)
257 {
258 const char *file;
259- const char *cmd;
260 errno_t ret;
261+ glob_t globbuf;
262
263 /* Parse command line. */
264 ret = sss_tool_popt_ex(cmdline, NULL, SSS_TOOL_OPT_OPTIONAL, NULL, NULL,
265@@ -280,13 +294,19 @@ errno_t sssctl_logs_fetch(struct sss_cmdline *cmdline,
266 return ret;
267 }
268
269- cmd = talloc_asprintf(tool_ctx, "tar -czf %s %s", file, LOG_FILES);
270- if (cmd == NULL) {
271- ERROR("Out of memory!");
272+ globbuf.gl_offs = 3;
273+ ret = glob(LOG_PATH"/*.log", GLOB_ERR|GLOB_DOOFFS, NULL, &globbuf);
274+ if (ret != 0) {
275+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to expand log files list\n");
276+ return ret;
277 }
278+ globbuf.gl_pathv[0] = discard_const_p(char, "tar");
279+ globbuf.gl_pathv[1] = discard_const_p(char, "-czf");
280+ globbuf.gl_pathv[2] = discard_const_p(char, file);
281
282 PRINT("Archiving log files into %s...\n", file);
283- ret = sssctl_run_command(cmd);
284+ ret = sssctl_run_command((const char * const*)globbuf.gl_pathv);
285+ globfree(&globbuf);
286 if (ret != EOK) {
287 ERROR("Unable to archive log files\n");
288 return ret;
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/drop_ntpdate_chk.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/drop_ntpdate_chk.patch
new file mode 100644
index 0000000..338af5d
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/drop_ntpdate_chk.patch
@@ -0,0 +1,28 @@
1nsupdate path is needed for various exec call
2but don't run natvie tests on it.
3
4
5Upstream-Status: Inappropriate [OE specific]
6Signed-off-by: Armin Kuster <akuster808@gmail.com>
7
8Index: sssd-2.5.0/src/external/nsupdate.m4
9===================================================================
10--- sssd-2.5.0.orig/src/external/nsupdate.m4
11+++ sssd-2.5.0/src/external/nsupdate.m4
12@@ -3,16 +3,4 @@ AC_MSG_CHECKING(for executable nsupdate)
13 if test -x "$NSUPDATE"; then
14 AC_DEFINE_UNQUOTED([NSUPDATE_PATH], ["$NSUPDATE"], [The path to nsupdate])
15 AC_MSG_RESULT(yes)
16-
17- AC_MSG_CHECKING(for nsupdate 'realm' support')
18- if AC_RUN_LOG([echo realm |$NSUPDATE >&2]); then
19- AC_MSG_RESULT([yes])
20- else
21- AC_MSG_RESULT([no])
22- AC_MSG_ERROR([nsupdate does not support 'realm'])
23- fi
24-
25-else
26- AC_MSG_RESULT([no])
27- AC_MSG_ERROR([nsupdate is not available])
28 fi
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/fix-ldblibdir.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/fix-ldblibdir.patch
new file mode 100644
index 0000000..e350baf
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/fix-ldblibdir.patch
@@ -0,0 +1,25 @@
1When calculate value of ldblibdir, it checks whether the directory of
2$ldblibdir exists. If not, it assigns ldblibdir with ${libdir}/ldb. It is not
3suitable for cross compile. Fix it that only re-assign ldblibdir when its value
4is empty.
5
6Upstream-Status: Inappropriate [cross compile specific]
7
8Signed-off-by: Kai Kang <kai.kang@windriver.com>
9---
10 src/external/libldb.m4 | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/src/external/libldb.m4 b/src/external/libldb.m4
14index c400add..5e5f06d 100644
15--- a/src/external/libldb.m4
16+++ b/src/external/libldb.m4
17@@ -19,7 +19,7 @@ if test x"$with_ldb_lib_dir" != x; then
18 ldblibdir=$with_ldb_lib_dir
19 else
20 ldblibdir="`$PKG_CONFIG --variable=modulesdir ldb`"
21- if ! test -d $ldblibdir; then
22+ if test -z $ldblibdir; then
23 ldblibdir="${libdir}/ldb"
24 fi
25 fi
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/fix_gid.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/fix_gid.patch
new file mode 100644
index 0000000..9b481cc
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/fix_gid.patch
@@ -0,0 +1,27 @@
1from ../sssd-2.5.0/src/util/sss_pam_data.c:27:
2| ../sssd-2.5.0/src/util/debug.h:88:44: error: unknown type name 'uid_t'; did you mean 'uint_t'?
3| 88 | int chown_debug_file(const char *filename, uid_t uid, gid_t gid);
4| | ^~~~~
5| | uint_t
6| ../sssd-2.5.0/src/util/debug.h:88:55: error: unknown type name 'gid_t'
7| 88 | int chown_debug_file(const char *filename, uid_t uid, gid_t gid);
8| | ^~~~~
9| make[2]: *** [Makefile:22529: src/util/libsss_iface_la-sss_pam_data.lo] Error 1
10| make[2]: *** Waiting for unfinished jobs....
11
12Upstream-Status: Pending
13Signed-off-by: Armin Kuster <akuster808@gmail.com>
14
15Index: sssd-2.5.0/src/util/debug.h
16===================================================================
17--- sssd-2.5.0.orig/src/util/debug.h
18+++ sssd-2.5.0/src/util/debug.h
19@@ -24,6 +24,8 @@
20 #include "config.h"
21
22 #include <stdio.h>
23+#include <unistd.h>
24+#include <sys/types.h>
25 #include <stdbool.h>
26
27 #include "util/util_errors.h"
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/musl_fixup.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/musl_fixup.patch
new file mode 100644
index 0000000..68f267c
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/musl_fixup.patch
@@ -0,0 +1,53 @@
1fix musl build failures
2
3Missing _PATH_HOSTS and some NETDB defines when musl is enabled.
4
5These are work arounds for now while we figure out where the real fix should reside (musl, gcompact, sssd):
6
7./sssd-2.5.1/src/providers/fail_over.c:1199:19: error: '_PATH_HOSTS' undeclared (first use in this function)
8| 1199 | _PATH_HOSTS);
9| | ^~~~~~~~~~~
10
11and
12
13i./sssd-2.5.1/src/sss_client/nss_ipnetworks.c:415:21: error: 'NETDB_INTERNAL' undeclared (first use in this function)
14| 415 | *h_errnop = NETDB_INTERNAL;
15
16
17Upstream-Status: Pending
18Signed-off-by: Armin Kuster <akuster808@gmail.com>
19
20Index: sssd-2.5.1/src/providers/fail_over.c
21===================================================================
22--- sssd-2.5.1.orig/src/providers/fail_over.c
23+++ sssd-2.5.1/src/providers/fail_over.c
24@@ -31,6 +31,10 @@
25 #include <talloc.h>
26 #include <netdb.h>
27
28+#if !defined(_PATH_HOSTS)
29+#define _PATH_HOSTS "/etc/hosts"
30+#endif
31+
32 #include "util/dlinklist.h"
33 #include "util/refcount.h"
34 #include "util/util.h"
35Index: sssd-2.5.1/src/sss_client/sss_cli.h
36===================================================================
37--- sssd-2.5.1.orig/src/sss_client/sss_cli.h
38+++ sssd-2.5.1/src/sss_client/sss_cli.h
39@@ -44,6 +44,14 @@ typedef int errno_t;
40 #define EOK 0
41 #endif
42
43+#ifndef NETDB_INTERNAL
44+# define NETDB_INTERNAL (-1)
45+#endif
46+
47+#ifndef NETDB_SUCCESS
48+# define NETDB_SUCCESS (0)
49+#endif
50+
51 #define SSS_NSS_PROTOCOL_VERSION 1
52 #define SSS_PAM_PROTOCOL_VERSION 3
53 #define SSS_SUDO_PROTOCOL_VERSION 1
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/no_gen.patch b/dynamic-layers/networking-layer/recipes-security/sssd/files/no_gen.patch
new file mode 100644
index 0000000..5c83777
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/no_gen.patch
@@ -0,0 +1,19 @@
1don't run generate-sbus-code
2
3Upstream-Status: Inappropriate [OE Specific]
4
5Signed-off-by: Armin Kuster <akuster808@gmail.com>
6
7Index: sssd-2.5.0/Makefile.am
8===================================================================
9--- sssd-2.5.0.orig/Makefile.am
10+++ sssd-2.5.0/Makefile.am
11@@ -1033,8 +1033,6 @@ generate-sbus-code:
12
13 .PHONY: generate-sbus-code
14
15-BUILT_SOURCES += generate-sbus-code
16-
17 EXTRA_DIST += \
18 sbus_generate.sh.in \
19 src/sbus/codegen/dbus.xml \
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/sssd.conf b/dynamic-layers/networking-layer/recipes-security/sssd/files/sssd.conf
new file mode 100644
index 0000000..1709a7a
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/sssd.conf
@@ -0,0 +1,8 @@
1[sssd]
2services = nss, pam
3config_file_version = 2
4
5[nss]
6
7[pam]
8
diff --git a/dynamic-layers/networking-layer/recipes-security/sssd/files/volatiles.99_sssd b/dynamic-layers/networking-layer/recipes-security/sssd/files/volatiles.99_sssd
new file mode 100644
index 0000000..2a82413
--- /dev/null
+++ b/dynamic-layers/networking-layer/recipes-security/sssd/files/volatiles.99_sssd
@@ -0,0 +1 @@
d root root 0750 /var/log/sssd none