From 772419010f87fab3df1e62781de2bb2b08e88b24 Mon Sep 17 00:00:00 2001 From: starlet-dx <15929766099@163.com> Date: Tue, 28 Oct 2025 10:08:58 +0800 Subject: [PATCH] Fix CVE-2025-62291 --- CVE-2025-62291.patch | 47 ++++++++++++++++++++++++++++++++++++++++++++ strongswan.spec | 6 +++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 CVE-2025-62291.patch diff --git a/CVE-2025-62291.patch b/CVE-2025-62291.patch new file mode 100644 index 0000000..b726461 --- /dev/null +++ b/CVE-2025-62291.patch @@ -0,0 +1,47 @@ +From dda24815d148b91209ebf2d27e3a7acefe9b6435 Mon Sep 17 00:00:00 2001 +From: Tobias Brunner +Date: Thu, 9 Oct 2025 11:33:45 +0200 +Subject: [PATCH] eap-mschapv2: Fix length check for Failure Request packets on + the client + +For message lengths between 6 and 8, subtracting HEADER_LEN (9) causes +`message_len` to become negative, which is then used in calls to malloc() +and memcpy() that both take size_t arguments, causing an integer +underflow. + +For 6 and 7, the huge size requested from malloc() will fail (it exceeds +PTRDIFF_MAX) and the returned NULL pointer will cause a segmentation +fault in memcpy(). + +However, for 8, the allocation is 0, which succeeds. But then the -1 +passed to memcpy() causes a heap-based buffer overflow (and possibly a +segmentation fault when attempting to read/write that much data). +Fortunately, if compiled with -D_FORTIFY_SOURCE=3 (the default on e.g. +Ubuntu), the compiler will use __memcpy_chk(), which prevents that buffer +overflow and causes the daemon to get aborted immediately instead. + +Fixes: f98cdf7a4765 ("adding plugin for EAP-MS-CHAPv2") +Fixes: CVE-2025-62291 + +Origin: +https://download.strongswan.org/security/CVE-2025-62291/strongswan-4.4.0-6.0.2_eap_mschapv2_failure_request_len.patch +--- + src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c +index 21cc95a6a360..35faad2e0bb5 100644 +--- a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c ++++ b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c +@@ -974,7 +974,7 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this, + data = in->get_data(in); + eap = (eap_mschapv2_header_t*)data.ptr; + +- if (data.len < 3) /* we want at least an error code: E=e */ ++ if (data.len < HEADER_LEN + 3) /* we want at least an error code: E=e */ + { + DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short"); + return FAILED; +-- +2.43.0 + diff --git a/strongswan.spec b/strongswan.spec index dab33d6..2d3f696 100644 --- a/strongswan.spec +++ b/strongswan.spec @@ -1,6 +1,6 @@ Name: strongswan Version: 5.9.14 -Release: 1 +Release: 2 Summary: An OpenSource IPsec-based VPN and TNC solution License: GPL-2.0-or-later URL: https://www.strongswan.org/ @@ -9,6 +9,7 @@ Source0: https://download.strongswan.org/old/5.x/strongswan-%{version}. Patch0: remove-warning-no-format.patch Patch1: aes-crypter-support-sw64-arch.patch Patch2: strongswan-5.9.14-harden-strongswan.service.patch +Patch3: CVE-2025-62291.patch BuildRequires: gcc chrpath autoconf automake libtool tpm2-abrmd BuildRequires: systemd-devel gmp-devel libcurl-devel NetworkManager-libnm-devel openldap-devel @@ -193,6 +194,9 @@ echo "%{_libdir}/strongswan" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.co %{_libexecdir}/strongswan/charon-nm %changelog +* Tue Oct 28 2025 yaoxin <1024769339@qq.com> - 5.9.14-2 +- Fix CVE-2025-62291 + * Sat Nov 02 2024 Funda Wang - 5.9.14-1 - update to 5.9.14 - harden strongswan.service with openSUSE effort -- Gitee