summaryrefslogtreecommitdiffstats
path: root/recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch
blob: 436bba42628f9592a0e0955843e3a98543893087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
From: Sebastian Wolf <swolf@nagios.com>
Date: Wed, 31 May 2023 16:43:54 -0400
Subject: [PATCH] check_by_ssh: Prevent users from using several SSH options
 which run local commands.

CVE: CVE-2023-37154
Upstream-Status: Backport [https://github.com/nagios-plugins/nagios-plugins/commit/e8810de21be80148562b7e0168b0a62aeedffde6]

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 configure.ac           | 10 ++++++++++
 plugins/check_by_ssh.c | 12 +++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 963514a..236d233 100644
--- a/configure.ac
+++ b/configure.ac
@@ -418,6 +418,16 @@ then
 		[path and arguments for invoking 'who'])
 fi
 
+AC_ARG_WITH(unrestricted_ssh_options,
+	[AS_HELP_STRING([--with-unrestricted-ssh-options],
+		[allow any SSH options to be used with check_by_ssh])],
+	[],
+	[unrestricted_ssh_options=no])
+
+if test "x$with_unrestricted_ssh_options" = xyes ; then
+	AC_DEFINE(HAVE_UNRESTRICTED_SSH_OPTIONS,[1],[Allow SSH to use options that run local commands.])
+fi
+
 AC_ARG_WITH([ipv6],
 	[AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
 	[], [with_ipv6=check])
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index b6f3130..6cc6c7a 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -27,7 +27,7 @@
 *****************************************************************************/
 
 const char *progname = "check_by_ssh";
-const char *copyright = "2000-2014";
+const char *copyright = "2000-";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -299,6 +299,16 @@ process_arguments (int argc, char **argv)
 				skip_stderr = atoi (optarg);
 			break;
 		case 'o':									/* Extra options for the ssh command */
+
+			/* Don't allow the user to run commands local to the nagios server, unless they decide otherwise at compile time. */
+#ifndef HAVE_UNRESTRICTED_SSH_OPTIONS
+			if (   strcasestr(optarg, "ProxyCommand") != NULL
+				|| strcasestr(optarg, "PermitLocalCommand") != NULL
+				|| strcasestr(optarg, "LocalCommand") != NULL) {
+				break;
+			}
+#endif
+
 			comm_append("-o");
 			comm_append(optarg);
 			break;
-- 
2.23.0