CVE-2021-22123 Overview
CVE-2021-22123 is an OS command injection vulnerability affecting Fortinet FortiWeb's management interface. This flaw enables a remote authenticated attacker to execute arbitrary commands on the underlying system via the SAML server configuration page. Command injection vulnerabilities of this nature are particularly dangerous in web application firewalls like FortiWeb, as successful exploitation can lead to complete system compromise and lateral movement within enterprise networks.
Critical Impact
Authenticated attackers can execute arbitrary system commands on FortiWeb appliances, potentially leading to full device takeover, data exfiltration, and network compromise.
Affected Products
- Fortinet FortiWeb version 6.3.7 and below
- Fortinet FortiWeb version 6.2.3 and below
- Fortinet FortiWeb versions 6.1.x, 6.0.x, 5.9.x
Discovery Timeline
- 2021-06-01 - CVE-2021-22123 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2021-22123
Vulnerability Analysis
This vulnerability resides in the SAML server configuration page within FortiWeb's management interface. The flaw stems from improper input validation (CWE-78: Improper Neutralization of Special Elements used in an OS Command), allowing user-supplied input to be passed directly to system shell commands without adequate sanitization.
The attack requires network access to the management interface and valid authentication credentials. Once authenticated, an attacker can inject malicious commands through the SAML configuration parameters, which are then executed with the privileges of the FortiWeb system process. This can result in complete confidentiality, integrity, and availability compromise of the affected device.
Root Cause
The root cause is insufficient input validation and sanitization in the SAML server configuration handler. User-controlled input is concatenated into OS command strings and executed without proper escaping or validation. This classic command injection pattern allows metacharacters and command separators (such as ;, |, &&, or backticks) to break out of the intended command context and execute arbitrary commands.
Attack Vector
The attack vector is network-based, targeting the FortiWeb management interface. An attacker must first obtain valid credentials through phishing, credential stuffing, or other means. Once authenticated, the attacker navigates to the SAML server configuration page and injects malicious payloads into vulnerable input fields. The injected commands execute on the underlying operating system, potentially allowing the attacker to:
- Read sensitive configuration files and credentials
- Modify firewall rules and security policies
- Install persistent backdoors
- Pivot to other network resources
- Exfiltrate sensitive data passing through the WAF
The vulnerability mechanism involves insufficient sanitization of user input in the SAML server configuration page. When an authenticated user submits configuration data, the application processes these values and incorporates them into shell commands without proper escaping. Attackers can leverage shell metacharacters to terminate the intended command and append malicious instructions. For detailed technical information, refer to the FortiGuard Security Advisory.
Detection Methods for CVE-2021-22123
Indicators of Compromise
- Unusual process execution originating from FortiWeb management processes
- Unexpected outbound network connections from the FortiWeb appliance
- Modified system files or new unauthorized files in system directories
- Suspicious entries in authentication logs showing repeated SAML configuration access
- Evidence of reverse shell connections or command-and-control traffic
Detection Strategies
- Monitor FortiWeb management interface access logs for unusual SAML configuration page activity
- Implement network detection rules for common command injection patterns in HTTP traffic
- Deploy SIEM rules to correlate multiple failed authentication attempts followed by SAML configuration changes
- Enable enhanced logging on FortiWeb appliances to capture detailed request parameters
- Use file integrity monitoring to detect unauthorized changes to system files
Monitoring Recommendations
- Restrict management interface access to trusted networks and IP addresses
- Implement continuous monitoring of FortiWeb system processes for anomalous child process spawning
- Configure alerts for administrative actions on SAML configuration pages
- Review authentication logs regularly for suspicious login patterns
- Deploy network traffic analysis to detect command injection attempts and data exfiltration
How to Mitigate CVE-2021-22123
Immediate Actions Required
- Upgrade FortiWeb to version 6.3.8 or later, 6.2.4 or later, or the latest available patched version
- Restrict access to the FortiWeb management interface to trusted IP addresses only
- Review and audit all administrative accounts for unauthorized access
- Enable multi-factor authentication for management interface access
- Monitor for indicators of compromise on all FortiWeb appliances
Patch Information
Fortinet has released security updates to address this vulnerability. Organizations should consult the FortiGuard Security Advisory FG-IR-20-120 for specific patch versions and upgrade instructions. All affected versions should be upgraded to the following minimum patched versions:
- FortiWeb 6.3.x: Upgrade to 6.3.8 or later
- FortiWeb 6.2.x: Upgrade to 6.2.4 or later
- FortiWeb 6.1.x, 6.0.x, 5.9.x: Upgrade to a supported patched version
Workarounds
- Isolate the FortiWeb management interface on a dedicated management VLAN
- Implement strict firewall rules limiting management access to authorized administrator workstations
- Use VPN connections for remote management access instead of exposing the interface directly
- Disable SAML authentication if not required for operations
- Deploy a jump server or bastion host for administrative access to FortiWeb appliances
# Example: Restrict management interface access via firewall rules
# Limit management access to specific trusted IP ranges
# On network firewall, allow only trusted admin IPs to FortiWeb management port
iptables -A INPUT -p tcp --dport 443 -s 10.10.10.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j DROP
# Verify FortiWeb firmware version
# Login to FortiWeb CLI and run:
# get system status
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

