by Mitja Kolsek, the 0patch Team
September 2022 Windows Updates brought a fix for a remote code execution vulnerability in Windows IKE Extension discovered by Yuki Chen with Cyber KunLun. Soon after that, researchers from 78ResearchLab published an analysis and POC for this vulnerability. This made it possible for us to create a patch for affected "security-adopted" Windows systems that no longer receive official fixes from Microsoft.
The vulnerability is in the code responsible for handling IKEv1 (Internet Key Exchange version 1) key exchange protocol, which is deprecated but still supported for legacy reasons. It is a memory corruption issue, with the POC causing the svchost.exe process hosting the IKEEXT service to crash by attempting to read data beyond an allocated buffer. The crash only occurs with page heap (a debugging accessory) enabled for the process, while in a typical production configuration, the vulnerability could potentially be used for arbitrary code execution (as confirmed by Microsoft's advisory).
Microsoft assigned this issue CVE-2022-34721 and fixed it by adding a check for the length of incoming data, and bypassing the processing of such data if the length is too small. Our micropatch is logically
equivalent to Microsoft's:
MODULE_PATH ".\ikeext.dll"
PATCH_ID 1000009
PATCH_FORMAT_VER 2
VULN_ID 1000010
PLATFORM win64
patchlet_start
PATCHLET_ID 1
PATCHLET_TYPE 2
PATCHLET_OFFSET 0x2d131
N_ORIGINALBYTES 5
JUMPOVERBYTES 0
PIT ikeext!0xaafd8,ikeext!0x2d1c0,ikeext!0x2d14f
; 0xaafd8 -> IkeCopyIncomingData
; 0x2d1c0 -> first WfpMemFree block
; 0x2d14f -> jump to NtohHeader in same block as patch
code_start
mov r8d, 1Ch ; number of characters to copy; for memcpy in IkeCopyIncomingData
lea rcx, [rbp-30h] ; new buffer; for memcpy in IkeCopyIncomingData mov rdx, r14 ; buffer to copy from; for memcpy in IkeCopyIncomingData
call PIT_0xaafd8 ; call IkeCopyIncomingData
mov rbx, rax ; save return from IkeCopyIncomingData
test rax, rax ; check if return from IkeCopyIncomingData is non-zero
jnz PIT_0x2d1c0 ; jump to WfpMemFree block if non-zero
lea rcx, [rbp-30h] ; buffer with copied data
jmp PIT_0x2d14f ; jmp to NtohHeader in same block as patch
code_end
patchlet_end
This video demonstrates the effect of our micropatch. With
0patch disabled, launching the POC against a vulnerable computer causes a svchost.exe process to crash due to memory access violation. With 0patch enabled, the vulnerability is no longer there, the malformed IKEv1 packet is blocked, and the service doesn't crash.
The micropatch was written for the following Versions of Windows with all available Windows Updates installed:
- Windows 10 v2004
- Windows 10 v1909
- Windows 10 v1903
- Windows 10 v1809
- Windows 10 v1803
- Windows 7 without ESU, with year 1 of ESU and with year 2 of ESU
- Windows Server 2008 R2 without ESU, with year 1 of ESU and with year 2 of ESU
To learn more about 0patch, please visit our Help Center. For a trial or demo please contact sales@0patch.com.
We'd like to thank Yuki Chen for finding this issue, and 78ResearchLab researchers for publishing their analysis and providing a proof-of-concept that allowed us to reproduce the vulnerability and create a micropatch. We also encourage security researchers to privately share their analyses with us for micropatching.
This patch block connection to our Vpn server Windows 2008 R2, our Windows 10 pc or Mac using native clients with VPN L2TP/IPSEC are no more able to login correctly on server.
ReplyDeletePlease check and fix.
Thanks
Hi there,
DeleteThank you for reporting this. This is most likely due to the patch we had issued yesterday. We did test L2TP/IPSEC connections from Windows 10 to Windows Server 2019, but we'll now try to reproduce this issue on Server 2008 R2. Please disable the associated patch (look for CVE-2022-34721) while we're working on resolving this.
Thanks,
Mitja
Based on your report, two of our micropatches For Windows IKE Extension Remote Code Execution (CVE-2022-34721) - both for Windows Server 2008 R2 - were confirmed to be defective and have been corrected and re-issued today. Users don't have to do anything to have the defective patches un-applied and the corrected ones applied.
DeleteThank you again for reporting this.