Fortinet FortiGate CVE-2024-23113 - A Super Complex Vulnerability In A Super Secure Appliance In 2024
A format string vulnerability in FortiGate's FGFM service allowed an attacker to pass a crafted value to snprintf, potentially leading to remote code execution. The researchers found that exploitation is limited by TLS certificate requirements in some firmware branches, but they could still detect vulnerable devices.
labs.watchtowr.com
Published on labs.watchtowr.com
This research is a glimpse into the capability powering the watchTowr Platform, a Preemptive Exposure Management solution. We enable organizations to autonomously validate and mitigate their exposure to emerging threats, ahead of in-the-wild exploitation.
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
The vulnerable code passed a user-controlled string directly as the format argument to snprintf instead of using a fixed format string like "%s".
Impact
An attacker who can reach the FGFM service could potentially achieve remote code execution, but in some firmware branches exploitation requires a trusted certificate, limiting the attack to the managing FortiManager or high-availability peer.
What the attacker needed
Network access to TCP port 541; ability to present a trusted certificate (for some branches)
The fix
The vulnerability was fixed by using a hardcoded format string in the patched version.
How it was found
- Connect to TCP port 541 and perform a TLS handshake where the client acts as the TLS server (using openssl s_server and socat).
- Receive the initial packet from the FortiGate, which contains a header and an ASCII newline-delimited message.
- Send a packet with a header and a payload containing 'reply 200', 'request=auth', and 'authip=<format string payload>'.
- Observe whether the connection is aborted (indicating vulnerability) or not (indicating patched).
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.
A format string bug happens when a program uses user input as the format template for printing functions like printf. If the input contains special characters like %n, the program may write to memory or crash. Here, the FortiGate device passed an attacker-controlled value to snprintf, which could let an attacker run code or at least detect the vulnerability.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.