Skip to contentSkip to conversation

znc: patch CVE-2024-39844

PATCH New Gyorgy Sarvari 1 participant 4 messages Dec 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 znc: patch CVE-2024-39844

Details: https://nvd.nist.gov/vuln/detail/CVE-2024-39844

Pick the patch that is mentioned in the oss-security[1] advisory

[1]: https://www.openwall.com/lists/oss-security/2024/07/03/9

---
 .../recipes-irc/znc/znc/CVE-2024-39844.patch  | 61 +++++++++++++++++++
 meta-networking/recipes-irc/znc/znc_1.8.2.bb  |  4 +-
 2 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 meta-networking/recipes-irc/znc/znc/CVE-2024-39844.patch
meta-networking/recipes-irc/znc/znc/CVE-2024-39844.patch new file +61 -0
new file mode 100644
index 0000000000..de0d8c5541
@@ -0,0 +1,61 @@
+From 5f6c872e44830d41d4d242e241af7b096a62a7c3 Mon Sep 17 00:00:00 2001
+From: Alexey Sokolov <[email protected]>
+Date: Mon, 1 Jul 2024 09:59:16 +0100
+Subject: [PATCH] Fix RCE vulnerability in modtcl
+
+Remote attacker could execute arbitrary code embedded into the kick
+reason while kicking someone on a channel.
+
+To mitigate this for existing installations, simply unload the modtcl
+module for every user, if it's loaded.
+Note that only users with admin rights can load modtcl at all.
+
+While at it, also escape the channel name.
+
+Discovered by Johannes Kuhn (DasBrain)
+
+Patch by https://github.com/glguy
+
+CVE-2024-39844
+
+CVE: CVE-2024-39844
+Upstream-Status: Backport [https://github.com/znc/znc/commit/8cbf8d628174ddf23da680f3f117dc54da0eb06e]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ modules/modtcl.cpp | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/modules/modtcl.cpp b/modules/modtcl.cpp
+index c64bc43f..58e68f51 100644
+--- a/modules/modtcl.cpp
++++ b/modules/modtcl.cpp
+@@ -248,8 +248,9 @@ class CModTcl : public CModule {
+         // chan specific
+         unsigned int nLength = vChans.size();
+         for (unsigned int n = 0; n < nLength; n++) {
++            CString sChannel = TclEscape(CString(vChans[n]->GetName()));
+             sCommand = "Binds::ProcessNick {" + sOldNick + "} {" + sHost +
+-                       "} - {" + vChans[n]->GetName() + "} {" + sNewNickTmp +
++                       "} - {" + sChannel + "} {" + sNewNickTmp +
+                        "}";
+             int i = Tcl_Eval(interp, sCommand.c_str());
+             if (i != TCL_OK) {
+@@ -260,14 +261,16 @@ class CModTcl : public CModule {
+ 
+     void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Channel,
+                 const CString& sMessage) override {
++        CString sMes = TclEscape(sMessage);
+         CString sOpNick = TclEscape(CString(OpNick.GetNick()));
+         CString sNick = TclEscape(sKickedNick);
+         CString sOpHost =
+             TclEscape(CString(OpNick.GetIdent() + "@" + OpNick.GetHost()));
++        CString sChannel = TclEscape(Channel.GetName());
+ 
+         CString sCommand = "Binds::ProcessKick {" + sOpNick + "} {" + sOpHost +
+-                           "} - {" + Channel.GetName() + "} {" + sNick + "} {" +
+-                           sMessage + "}";
++                           "} - {" + sChannel + "} {" + sNick + "} {" +
++                           sMes + "}";
+         int i = Tcl_Eval(interp, sCommand.c_str());
+         if (i != TCL_OK) {
+             PutModule(Tcl_GetStringResult(interp));
meta-networking/recipes-irc/znc/znc_1.8.2.bb +3 -1
index a50431982e..f7a99c876f 100644
@@ -5,7 +5,9 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
 
 DEPENDS = "openssl zlib icu"
 
-SRC_URI = "gitsm://github.com/znc/znc.git;branch=master;protocol=https"
+SRC_URI = "gitsm://github.com/znc/znc.git;branch=master;protocol=https \
+           file://CVE-2024-39844.patch \
+           "
 
 SRCREV = "bf253640d33d03331310778e001fb6f5aba2989e"
 
#1 lore raw

PATCH 2/4 zlog: patch CVE-2024-22857

Details: https://nvd.nist.gov/vuln/detail/CVE-2024-22857

Pick the patch from the PR mentioned by the nvd report.

---
 .../zlog/zlog/CVE-2024-22857.patch            | 31 +++++++++++++++++++
 meta-oe/recipes-extended/zlog/zlog_1.2.15.bb  |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 meta-oe/recipes-extended/zlog/zlog/CVE-2024-22857.patch
meta-oe/recipes-extended/zlog/zlog/CVE-2024-22857.patch new file +31 -0
new file mode 100644
index 0000000000..d5db6a12fe
@@ -0,0 +1,31 @@
+From 68c712b401538abc3028ecc5071fa787f87afa7f Mon Sep 17 00:00:00 2001
+From: Ali Raza <[email protected]>
+Date: Thu, 29 Feb 2024 11:36:25 +0500
+Subject: [PATCH] buffer overflow patched (#251)
+
+Thank you for the PR
+
+CVE: CVE-2024-22857
+Upstream-Status: Backport [https://github.com/HardySimpson/zlog/commit/c47f781a9f1e9604f5201e27d046d925d0d48ac4]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/rule.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/rule.c b/src/rule.c
+index ae3d74f..38d3fdc 100644
+--- a/src/rule.c
++++ b/src/rule.c
+@@ -866,8 +866,10 @@ zlog_rule_t *zlog_rule_new(char *line,
+ 		}
+ 		break;
+ 	case '$' :
+-		sscanf(file_path + 1, "%s", a_rule->record_name);
+-			
++		// read only MAXLEN_PATH characters from the file_path + 1
++		strncpy(a_rule->record_name, file_path + 1, MAXLEN_PATH);
++		a_rule->record_name[MAXLEN_PATH] = '\0';
++		
+ 		if (file_limit) {  /* record path exists */
+ 			p = strchr(file_limit, '"');
+ 			if (!p) {
meta-oe/recipes-extended/zlog/zlog_1.2.15.bb +1 -0
index 7930c234d1..74a394bf52 100644
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
 SRCREV = "876099f3c66033f3de11d79f63814766b1021dbe"
 SRC_URI = "git://github.com/HardySimpson/zlog;branch=master;protocol=https \
            file://0001-Fix-stack-buffer-overflow-at-zlog_conf_build_with_fi.patch \
+           file://CVE-2024-22857.patch \
            "
 
 S = "${WORKDIR}/git"
#2 lore raw

PATCH 3/4 sysdig: set SRCREV_FORMAT

In reply to Gyorgy Sarvari

It fetches from multiple repositories, but didn't have SRCREV_FORMAT set. Because of this, the recipe couldn't use sstate artifacts from a mirror, just threw many warnings:

WARNING: sysdig-0.28.0-r0 do_package_qa_setscene: ExpansionError('SRCPV',
'${@bb.fetch2.get_srcrev(d)}', FetchError('The SRCREV_FORMAT variable
must be set when multiple SCMs are used.\nThe SCMs are:\ngit://github.com/draios/sysdig.git;branch=dev;protocol=https;name=sysdig
git://github.com/falcosecurity/libs;protocol=https;branch=master;name=falco;subdir=git/falcosecurity-libs',
None))
WARNING: Setscene task (/cocto/kirkstone-next/meta-openembedded/meta-oe/recipes-extended/sysdig/sysdig_0.28.0.bb
:do_package_qa_setscene) failed with exit code '1' - real task will be run instead

---
 meta-oe/recipes-extended/sysdig/sysdig_0.28.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta-oe/recipes-extended/sysdig/sysdig_0.28.0.bb +2 -0
index 4181da732f..7a894960d3 100644
@@ -29,6 +29,8 @@ SRC_URI = "git://github.com/draios/sysdig.git;branch=dev;protocol=https;name=sys
 SRCREV_sysdig = "4fb6288275f567f63515df0ff0a6518043ecfa9b"
 SRCREV_falco= "caa0e4d0044fdaaebab086592a97f0c7f32aeaa9"
 
+SRCREV_FORMAT = "sysdig_falco"
+
 S = "${WORKDIR}/git"
 
 EXTRA_OECMAKE = "\
#3 lore raw

PATCH 4/4 gosu: set SRCREV_FORMAT variable

In reply to Gyorgy Sarvari

The recipe fetches from multiple repositories, however the SRCREV_FORMAT variable wasn't set. Due to this the recipe couldn't reuse sstate artifacts from a mirror, only threw warnings:

WARNING: gosu-1.14-r0 do_package_qa_setscene: ExpansionError('SRCPV',
'${@bb.fetch2.get_srcrev(d)}', FetchError('The SRCREV_FORMAT variable must be set when multiple SCMs are used.\nThe SCMs are:
git://github.com/tianon/gosu.git;branch=master;protocol=https
git://github.com/opencontainers/runc;name=runc;branch=main;protocol=https', None))
WARNING: Setscene task (/cocto/kirkstone-next/meta-openembedded/meta-oe/recipes-support/
gosu/gosu_1.14.bb:do_package_qa_setscene) failed with exit code '1' - real task will be run instead

---
 meta-oe/recipes-support/gosu/gosu_1.14.bb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta-oe/recipes-support/gosu/gosu_1.14.bb +4 -2
index 624adf3099..f354f67194 100644
@@ -5,13 +5,15 @@ LICENSE = "Apache-2.0 "
 LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
 
 GO_IMPORT = "github.com/tianon/gosu"
-SRC_URI = "git://${GO_IMPORT}.git;branch=master;protocol=https \
+SRC_URI = "git://${GO_IMPORT}.git;branch=master;protocol=https;name=core \
            git://github.com/opencontainers/runc;name=runc;destsuffix=${S}/src/github.com/opencontainers/runc;branch=main;protocol=https \
 "
-SRCREV = "9f7cd138a1ebc0684d43ef6046bf723978e8741f"
+SRCREV_core = "9f7cd138a1ebc0684d43ef6046bf723978e8741f"
 SRCREV_runc = "d7f7b22a85a2387557bdcda125710c2506f8d5c5"
 inherit go
 
+SRCREV_FORMAT = "core"
+
 do_compile:prepend() {
     # New Go versions has Go modules support enabled by default
     export GO111MODULE=off