A strongSwan, VPN package based on the IPSec protocol, used in Linux, Android, FreeBSD, and macOS, has a vulnerability (CVE-2023-41913) that can be exploited for remote code execution by attackers. The vulnerability is caused by an error in the charon-tkm process with the key exchange protocol (IKE) based on TKMv2 (Trusted Key Manager), leading to a buffer overflow when processing specially crafted DH (Diffie-Hellman) scheme values. The vulnerability appears only in systems using charon-tkm and in strongSwan releases starting from 5.3.0. The issue has been resolved in the strongSwan 5.9.12 update. Patches have also been prepared for fixing the vulnerability in branches starting from 5.3.x.
The error is caused by the lack of size checks for the public Diffie-Hellman values before copying them into a fixed-size buffer in the stack. The overflow can be triggered by sending a specially crafted IKE_SA_INIT message, processed without authentication. In older versions of strongSwan, size checks were performed in the KE payload (Key Exchange) handler, but in version 5.3.0, changes were made to move the size check for public values to the DH protocol handler, adding standard functions to simplify the validation of known DH groups. By oversight, the new validation functions were omitted from the charon-tkm process, which acts as a proxy between the IKE process and the TKM (Trusted Key Manager), causing unchecked values to reach the memcpy() function, allowing up to 10,000 bytes of data to be written to a 512-byte buffer.
Forrás: opennet.ru
