Skip to contentSkip to conversation

nagios-plugins: fix CVE-2023-37154

PATCH In review [email protected] 3 participants 6 messages Nov 28, 2024 – Dec 10, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nagios-plugins: fix CVE-2023-37154

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary command execution via ProxyCommand, LocalCommand, and PermitLocalCommand with \${IFS}. This has been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69 +++++++++++++++++++
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +69 -0
new file mode 100644
index 00000000..436bba42
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
+From: Sebastian Wolf <[email protected]>
+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 <[email protected]>
+---
+ 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 = "[email protected]";
+ 
+ #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
+
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -0
index 471d4b42..cd89b329 100644
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
Signature · 1 line
2.25.1
#1 lore raw

merged.

Bruce

In message: [meta-virtualization] [kirkstone][PATCH] nagios-plugins: fix CVE-2023-37154

Quoted 117 lines · on 28/11/2024 Changqing Li via lists.yoctoproject.org wrote:

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary command execution via ProxyCommand, LocalCommand, and PermitLocalCommand with \${IFS}. This has been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69 +++++++++++++++++++
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +69 -0
new file mode 100644
index 00000000..436bba42
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
+From: Sebastian Wolf <[email protected]>
+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 <[email protected]>
+---
+ 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 = "[email protected]";
+ 
+ #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
+
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -0
index 471d4b42..cd89b329 100644
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
Signature · 11 lines
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9015): https://lists.yoctoproject.org/g/meta-virtualization/message/9015
Mute This Topic: https://lists.yoctoproject.org/mt/109817333/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#2 lore raw

Something went wrong when applying this in kirkstone and recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch doesn't exist.

Quoted 129 lines · Bruce Ashfield via lists.yoctoproject.org

merged.

Bruce

In message: [meta-virtualization] [kirkstone][PATCH] nagios-plugins: fix CVE-2023-37154

Quoted 105 lines · on 28/11/2024 Changqing Li via lists.yoctoproject.org wrote:

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary command execution via ProxyCommand, LocalCommand, and PermitLocalCommand with \${IFS}. This has been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69 +++++++++++++++++++
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +69 -0
new file mode 100644
index 00000000..436bba42
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
+From: Sebastian Wolf <[email protected]>
+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 <[email protected]>
+---
+ 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 = "[email protected]";
+
+ #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
+
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -1
index 471d4b42..cd89b329 100644
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
--
Quoted 6 lines

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9049): https://lists.yoctoproject.org/g/meta-virtualization/message/9049
Mute This Topic: https://lists.yoctoproject.org/mt/109817333/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

odd. I don't even have any refuse sitting around in my merge directory.

I'll revert and re-apply.

Bruce

Quoted 158 lines · Martin Jansa

Something went wrong when applying this in kirkstone and recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch doesn't exist.

Quoted 6 lines · Bruce Ashfield via lists.yoctoproject.org

merged.

Bruce

In message: [meta-virtualization] [kirkstone][PATCH] nagios-plugins: fix

CVE-2023-37154

Quoted 6 lines
Quoted 4 lines · on 28/11/2024 Changqing Li via lists.yoctoproject.org wrote:

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary command

execution

Quoted 1 line
Quoted 1 line

via ProxyCommand, LocalCommand, and PermitLocalCommand with \${IFS}.

This has

Quoted 11 lines
Quoted 11 lines

been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69 +++++++++++++++++++
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch b/recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 9 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 4

Quoted 9 lines

new file mode 100644
index 00000000..436bba42

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +4 -0
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
+From: Sebastian Wolf <[email protected]>
+Date: Wed, 31 May 2023 16:43:54 -0400
+Subject: [PATCH] check_by_ssh: Prevent users from using several SSH

options

Quoted 4 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 4 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +4 -0
+ which run local commands.
+
+CVE: CVE-2023-37154
+Upstream-Status: Backport [

https://github.com/nagios-plugins/nagios-plugins/commit/e8810de21be80148562b7e0168b0a62aeedffde6
]

Quoted 15 lines
Quoted 15 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +15 -0
+
+Signed-off-by: Changqing Li <[email protected]>
+---
+ 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
+
Quoted 8 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 8 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +8 -0
++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.])

Quoted 4 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 4 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +4 -0
++fi
++
+ AC_ARG_WITH([ipv6],
+     [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@

:>@])],

Quoted 7 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 43

Quoted 7 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +7 -0
+     [], [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 @@
+

*****************************************************************************/

Quoted 11 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 11 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +11 -0
+
+ const char *progname = "check_by_ssh";
+-const char *copyright = "2000-2014";
++const char *copyright = "2000-";
+ const char *email = "[email protected]";
+
+ #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 */
Quoted 2 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 55

Quoted 2 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +2 -0
++
++                    /* Don't allow the user to run commands local to

the nagios server, unless they decide otherwise at compile time. */

Quoted 3 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 3 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +3 -0
++#ifndef HAVE_UNRESTRICTED_SSH_OPTIONS
++                    if (   strcasestr(optarg, "ProxyCommand") != NULL
++                            || strcasestr(optarg,

"PermitLocalCommand") != NULL

Quoted 1 line

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 59

Quoted 1 line
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +1 -0
++                            || strcasestr(optarg, "LocalCommand") !=

NULL) {

Quoted 11 lines

Review

Quoted 11 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +10 -0
++                            break;
++                    }
++#endif
++
+                     comm_append("-o");
+                     comm_append(optarg);
+                     break;
+--
+2.23.0
+
(quoted diff) +0 -0

b/recipes-extended/nagios/nagios-plugins_2.2.1.bb

Quoted 5 lines

recipes-extended/nagios/nagios-plugins_2.2.1.bb LICENSE = "GPL-3.0-only" · line 9

Quoted 5 lines

index 471d4b42..cd89b329 100644

recipes-extended/nagios/nagios-plugins_2.2.1.bb +0 -0
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM =

"file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

Quoted 2 lines

recipes-extended/nagios/nagios-plugins_2.2.1.bb LICENSE = "GPL-3.0-only" · line 10

Quoted 2 lines
recipes-extended/nagios/nagios-plugins_2.2.1.bb +0 -0
 SRC_URI = "

https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \

Quoted 13 lines
Quoted 11 lines
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -1
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
--

2.25.1

Quoted 3 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9049):

https://lists.yoctoproject.org/g/meta-virtualization/message/9049

Quoted 3 lines

Mute This Topic: https://lists.yoctoproject.org/mt/109817333/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub

[[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
#4 lore raw

Looks like most of that .patch file ended in the commit message, but the patch looks ok to me, so not sure what happened.

Quoted 152 lines · Bruce Ashfield

odd. I don't even have any refuse sitting around in my merge directory.

I'll revert and re-apply.

Bruce

Quoted 137 lines · Martin Jansa

Something went wrong when applying this in kirkstone and recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch doesn't exist.

Quoted 129 lines · Bruce Ashfield via lists.yoctoproject.org

merged.

Bruce

In message: [meta-virtualization] [kirkstone][PATCH] nagios-plugins: fix CVE-2023-37154

Quoted 105 lines · on 28/11/2024 Changqing Li via lists.yoctoproject.org wrote:

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary command execution via ProxyCommand, LocalCommand, and PermitLocalCommand with \${IFS}. This has been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69 +++++++++++++++++++
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +69 -0
new file mode 100644
index 00000000..436bba42
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00 2001
+From: Sebastian Wolf <[email protected]>
+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 <[email protected]>
+---
+ 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 = "[email protected]";
+
+ #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
+
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -1
index 471d4b42..cd89b329 100644
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
--
Quoted 6 lines

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9049): https://lists.yoctoproject.org/g/meta-virtualization/message/9049
Mute This Topic: https://lists.yoctoproject.org/mt/109817333/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

#5 lore raw
Quoted 3 lines · Martin Jansa

Looks like most of that .patch file ended in the commit message, but the patch looks ok to me, so not sure what happened.

My scripts/utilities that save patches to mbox just can't deal with that message.

I tried a new save. Same result. Hopefully this is a one-off formatting issue, or
I'm going to need to modify my scripts.

I manually saved the patch, and it looks ok now. So the branch should now build again.

Bruce

Quoted 183 lines
Quoted 8 lines · Bruce Ashfield

odd. I don't even have any refuse sitting around in my merge directory.

I'll revert and re-apply.

Bruce

On Tue, Dec 10, 2024 at 3:21 AM Martin Jansa <[email protected]>

Quoted 9 lines · wrote:
Quoted 9 lines

Something went wrong when applying this in kirkstone and recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch doesn't exist.

Quoted 1 line · Bruce Ashfield via lists.yoctoproject.org
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

merged.

Bruce

In message: [meta-virtualization] [kirkstone][PATCH] nagios-plugins:

fix CVE-2023-37154

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines · on 28/11/2024 Changqing Li via lists.yoctoproject.org wrote:

From: Changqing Li <[email protected]>

CVE-2023-37154:
check_by_ssh in Nagios nagios-plugins 2.4.5 allows arbitrary

command execution

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

via ProxyCommand, LocalCommand, and PermitLocalCommand with

\${IFS}. This has

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

been categorized both as fixed in e8810de, and as intended behavior.

Refer:
https://nvd.nist.gov/vuln/detail/CVE-2023-37154

---
 .../nagios-plugins/CVE-2023-37154.patch       | 69

+++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
 .../nagios/nagios-plugins_2.2.1.bb            |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

diff --git

a/recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch b/recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 1

Quoted 6 lines

new file mode 100644
index 00000000..436bba42

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +1 -0
@@ -0,0 +1,69 @@
+From 7f07a9e89373d5906c2b6a9eee0e74cf69f302c1 Mon Sep 17 00:00:00

2001

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 3 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +3 -0
+From: Sebastian Wolf <[email protected]>
+Date: Wed, 31 May 2023 16:43:54 -0400
+Subject: [PATCH] check_by_ssh: Prevent users from using several

SSH options

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 4 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +4 -0
+ which run local commands.
+
+CVE: CVE-2023-37154
+Upstream-Status: Backport [

https://github.com/nagios-plugins/nagios-plugins/commit/e8810de21be80148562b7e0168b0a62aeedffde6
]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +10 -0
+
+Signed-off-by: Changqing Li <[email protected]>
+---
+ 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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 8 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +8 -0
++++ 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])],

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 5 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +5 -0
++    [],
++    [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.])

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 4 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +4 -0
++fi
++
+ AC_ARG_WITH([ipv6],
+     [AS_HELP_STRING([--with-ipv6], [support IPv6

@<:@default=check@:>@])],

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 43

Quoted 7 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +7 -0
+     [], [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 @@
+

*****************************************************************************/

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch

Quoted 11 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +11 -0
+
+ const char *progname = "check_by_ssh";
+-const char *copyright = "2000-2014";
++const char *copyright = "2000-";
+ const char *email = "[email protected]";
+
+ #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 */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 55

Quoted 2 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +2 -0
++
++                    /* Don't allow the user to run commands local

to the nagios server, unless they decide otherwise at compile time. */

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 57

Quoted 2 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +2 -0
++#ifndef HAVE_UNRESTRICTED_SSH_OPTIONS
++                    if (   strcasestr(optarg, "ProxyCommand") !=

NULL

Quoted 1 line
Quoted 1 line
Quoted 1 line

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 58

Quoted 1 line
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +1 -0
++                            || strcasestr(optarg,

"PermitLocalCommand") != NULL

Quoted 1 line
Quoted 1 line
Quoted 1 line

recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch line 59

Quoted 1 line
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +1 -0
++                            || strcasestr(optarg, "LocalCommand")

!= NULL) {

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Review

Quoted 11 lines
recipes-extended/nagios/nagios-plugins/CVE-2023-37154.patch new file +10 -0
++                            break;
++                    }
++#endif
++
+                     comm_append("-o");
+                     comm_append(optarg);
+                     break;
+--
+2.23.0
+
(quoted diff) +0 -0

b/recipes-extended/nagios/nagios-plugins_2.2.1.bb

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

recipes-extended/nagios/nagios-plugins_2.2.1.bb LICENSE = "GPL-3.0-only" · line 9

Quoted 5 lines

index 471d4b42..cd89b329 100644

recipes-extended/nagios/nagios-plugins_2.2.1.bb +0 -0
@@ -9,6 +9,7 @@ LICENSE = "GPL-3.0-only"
 LIC_FILES_CHKSUM =

"file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

recipes-extended/nagios/nagios-plugins_2.2.1.bb LICENSE = "GPL-3.0-only" · line 10

Quoted 2 lines
recipes-extended/nagios/nagios-plugins_2.2.1.bb +0 -0
 SRC_URI = "

https://www.nagios-plugins.org/download/${BPN}-${PV}.tar.gz \

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
recipes-extended/nagios/nagios-plugins_2.2.1.bb +1 -1
+           file://CVE-2023-37154.patch \
 "
 
 SRC_URI[md5sum] = "fb521d5c05897f165b0b1862c1e5cb27"
--

2.25.1

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9049):

https://lists.yoctoproject.org/g/meta-virtualization/message/9049

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Mute This Topic: https://lists.yoctoproject.org/mt/109817333/3617156
Group Owner: [email protected] Unsubscribe:

https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

--
- Thou shalt not follow the NULL pointer, for chaos and madness await

thee at its end

Quoted 2 lines

- "Use the force Harry" - Gandalf, Star Trek II

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II