Skip to content
Memory corruption Write-up Advanced

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.

Dylan Pindur Follow

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.

Dylan Pindur, on assetnote.io

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

  1. Set up two FortiGate VMs with versions 7.2.5 and 7.2.7.
  2. Extract the /bin/init binary from both versions.
  3. Decompile and compare the binaries to find the patched function.
  4. Enable debug logging and send chunked requests to identify a reachable endpoint.
  5. Craft a request with a zero-length chunk followed by many chunk trailers to trigger a crash.
  6. 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.

More by Dylan Pindur

View all

8 more disclosed reports, best first.

More from Fortinet

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.