|
| 1 | +From ae75a582a276ca4b1f6b9b68fe602f41a6e93109 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tobias Brunner <tobias@strongswan.org> |
| 3 | +Date: Thu, 9 Oct 2025 11:33:45 +0200 |
| 4 | +Subject: [PATCH] eap-mschapv2: Fix length check for Failure Request packets on |
| 5 | + the client |
| 6 | + |
| 7 | +For message lengths between 6 and 8, subtracting HEADER_LEN (9) causes |
| 8 | +`message_len` to become negative, which is then used in calls to malloc() |
| 9 | +and memcpy() that both take size_t arguments, causing an integer |
| 10 | +underflow. |
| 11 | + |
| 12 | +For 6 and 7, the huge size requested from malloc() will fail (it exceeds |
| 13 | +PTRDIFF_MAX) and the returned NULL pointer will cause a segmentation |
| 14 | +fault in memcpy(). |
| 15 | + |
| 16 | +However, for 8, the allocation is 0, which succeeds. But then the -1 |
| 17 | +passed to memcpy() causes a heap-based buffer overflow (and possibly a |
| 18 | +segmentation fault when attempting to read/write that much data). |
| 19 | +Fortunately, if compiled with -D_FORTIFY_SOURCE=3 (the default on e.g. |
| 20 | +Ubuntu), the compiler will use __memcpy_chk(), which prevents that buffer |
| 21 | +overflow and causes the daemon to get aborted immediately instead. |
| 22 | + |
| 23 | +Fixes: f98cdf7a4765 ("adding plugin for EAP-MS-CHAPv2") |
| 24 | +Fixes: CVE-2025-62291 |
| 25 | +Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> |
| 26 | +Upstream-reference: https://download.strongswan.org/security/CVE-2025-62291/strongswan-4.4.0-6.0.2_eap_mschapv2_failure_request_len.patch |
| 27 | +--- |
| 28 | + src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c | 2 +- |
| 29 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 30 | + |
| 31 | +diff --git a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c |
| 32 | +index 1bb54c8..9ad509a 100644 |
| 33 | +--- a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c |
| 34 | ++++ b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c |
| 35 | +@@ -974,7 +974,7 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this, |
| 36 | + data = in->get_data(in); |
| 37 | + eap = (eap_mschapv2_header_t*)data.ptr; |
| 38 | + |
| 39 | +- if (data.len < 3) /* we want at least an error code: E=e */ |
| 40 | ++ if (data.len < HEADER_LEN + 3) /* we want at least an error code: E=e */ |
| 41 | + { |
| 42 | + DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short"); |
| 43 | + return FAILED; |
| 44 | +-- |
| 45 | +2.45.4 |
| 46 | + |
0 commit comments