FortiOS, FortiProxy, and FortiSwitchManager Authentication Bypass Technical Deep Dive (CVE-2022-40684)
An authentication bypass in FortiOS, FortiProxy, and FortiSwitchManager allowed an attacker to send crafted HTTP requests with a spoofed Forwarded header and a specific User-Agent to impersonate a trusted local source, gaining administrator access. The attacker could then add an SSH key to the admin user and log in via SSH.
Published on horizon3.ai
Fortinet recently patched a critical authentication bypass vulnerability in their FortiOS, FortiProxy, and FortiSwitchManager projects (CVE-2022-40684). This vulnerability gives an attacker the ability to login as an administrator on the affected system.
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 authentication check trusted the client IP address taken from the Forwarded header and the User-Agent header, both of which are controlled by the attacker.
Impact
An attacker could do almost anything on the vulnerable system, including changing network configurations, adding users, and initiating packet captures.
What the attacker needed
Network access to management interface; ability to send crafted HTTP requests
The fix
The vulnerability was fixed in FortiOS 7.2.2 by explicitly setting the forwarded headers in the httpsd proxy handler.
How it was found
- Send an HTTP PUT request to the admin API endpoint with a Forwarded header setting the client IP to [redacted] and a User-Agent of 'Report Runner'.
- Include a JSON body that adds an SSH public key to the admin user.
- Use the added SSH key to log in to the system as admin.
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 a flaw in Fortinet's management software that lets someone skip the login step entirely. By sending a request that pretends to come from the machine itself (using a special header) and using a particular browser identifier, the attacker is treated as already logged in as an administrator. Once in, they can add their own SSH key to the admin account and connect directly to the device.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.