Two Bytes is Plenty: FortiGate RCE with CVE-2024-21762
An out-of-bounds write in FortiGate's SSL VPN HTTP chunked transfer encoding parser allowed a pre-authentication attacker to corrupt stack memory and potentially achieve remote code execution. The vulnerability was patched by adding length checks on chunk trailers and chunk length strings.
Published on assetnote.io
The exploit described in this post is tailored to the exact version of FortiGate SSL VPN used for testing. It is unlikely the exploit will work on other versions.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the chunked transfer encoding parser did not properly validate the length of chunk trailers and chunk length strings, leading to a stack buffer overflow.
Impact
A pre-authentication attacker could potentially execute arbitrary code on the device, but the exploit is tailored to a specific version and may not work on others.
What the attacker needed
Network access to the SSL VPN interface; specific FortiGate version (7.2.5)
How it was found
- Set up two FortiGate VMs with versions 7.2.5 and 7.2.7.
- Extract the /bin/init binary from both versions.
- Decompile and compare the binaries to find the patched function.
- Enable debug logging and send chunked requests to identify a reachable endpoint.
- Craft a request with a zero-length chunk followed by many chunk trailers to trigger a crash.
- Set up a debugger by patching integrity checks and backdooring the firmware to analyse the crash.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This is about a security flaw in a network device called FortiGate, which many organisations use to let employees connect remotely. The flaw is in the part that reads web requests, and a specially crafted request could overwrite memory and let an attacker run their own code on the device without logging in first.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.