CVE-2022-31814 Overview
CVE-2022-31814 is a critical command injection vulnerability affecting pfSense pfBlockerNG through version 2.1.4_26. The vulnerability allows unauthenticated remote attackers to execute arbitrary operating system commands with root privileges by injecting shell metacharacters into the HTTP Host header. This vulnerability represents a severe security risk as it enables complete system compromise without any prior authentication.
Critical Impact
Unauthenticated remote attackers can achieve root-level command execution on pfSense firewalls running vulnerable versions of pfBlockerNG, potentially compromising the entire network perimeter security.
Affected Products
- Netgate pfBlockerNG versions through 2.1.4_26 for pfSense
- pfSense installations with vulnerable pfBlockerNG package installed
- Note: pfBlockerNG 3.x is unaffected by this vulnerability
Discovery Timeline
- 2022-09-05 - CVE-2022-31814 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-31814
Vulnerability Analysis
This vulnerability stems from insufficient input validation in the pfBlockerNG package's handling of HTTP Host headers. When a request is processed, the Host header value is incorporated into shell commands without proper sanitization, allowing attackers to break out of the intended command context and inject arbitrary commands.
The attack requires no authentication, making it particularly dangerous for internet-exposed pfSense installations. Successful exploitation grants attackers root-level access to the underlying FreeBSD operating system, enabling them to modify firewall rules, intercept network traffic, establish persistence, or pivot to internal network resources.
Root Cause
The root cause is classified as CWE-78 (Improper Neutralization of Special Elements used in an OS Command - OS Command Injection). The pfBlockerNG package fails to sanitize shell metacharacters present in the HTTP Host header before passing the value to system shell functions. Characters such as semicolons, backticks, and pipe operators are not filtered or escaped, allowing command injection attacks.
Attack Vector
The attack is network-based and can be executed remotely against any pfSense installation running the vulnerable pfBlockerNG versions. The attacker crafts a malicious HTTP request with shell metacharacters embedded in the Host header. When the pfBlockerNG package processes this request, the injected commands are executed with root privileges on the firewall system.
The exploitation technique involves sending specially crafted HTTP requests to the pfSense web interface with a manipulated Host header containing shell metacharacters followed by the attacker's commands. The vulnerability can be leveraged to upload web shells, establish reverse connections, or directly execute commands for immediate impact. Detailed technical exploitation methods are documented in the IHTeam Advisory on pfBlockerNG RCE and Packet Storm Remote Code Execution resources.
Detection Methods for CVE-2022-31814
Indicators of Compromise
- Unusual HTTP requests to pfSense with malformed or suspicious Host headers containing shell metacharacters (;, `, |, $())
- Unexpected processes spawned by the web server with root privileges
- New or modified files in web-accessible directories, particularly PHP web shells
- Outbound connections from the pfSense firewall to unknown external IP addresses
- Modifications to pfSense configuration files or user accounts
Detection Strategies
- Monitor web server access logs for requests containing shell metacharacters in the Host header field
- Implement network-based intrusion detection rules to identify command injection patterns in HTTP headers
- Deploy file integrity monitoring on the pfSense system to detect unauthorized file modifications
- Review process execution logs for unexpected command execution by web server processes
Monitoring Recommendations
- Enable detailed HTTP access logging on pfSense and forward logs to a SIEM for analysis
- Configure alerts for any new user accounts or SSH keys added to the firewall
- Monitor for unexpected network connections originating from the pfSense management interface
- Implement behavioral monitoring to detect anomalous process execution patterns on the firewall
How to Mitigate CVE-2022-31814
Immediate Actions Required
- Upgrade pfBlockerNG to version 3.x or later, which is not affected by this vulnerability
- If immediate upgrade is not possible, consider temporarily disabling the pfBlockerNG package
- Restrict access to the pfSense web interface to trusted IP addresses only
- Review firewall logs for any signs of exploitation attempts
Patch Information
Netgate has addressed this vulnerability in pfBlockerNG version 3.x. The fix involves proper sanitization and validation of HTTP header inputs before they are processed by shell commands. Administrators should update to the latest available version of pfBlockerNG through the pfSense Package Manager. Details about the fix can be found in the GitHub FreeBSD-ports Pull Request and the GitHub Commit Details for Pull Request.
Workarounds
- Implement network-level access controls to restrict access to the pfSense web interface from untrusted networks
- Use a web application firewall (WAF) in front of pfSense to filter requests containing shell metacharacters in headers
- Disable the pfBlockerNG package if it is not actively required until patching can be completed
- Consider implementing IP-based allowlisting for management interface access at the network perimeter
# Configuration example - Restrict pfSense web interface access via firewall rules
# Add rule to allow management access only from trusted admin subnet
# Navigate to: Firewall > Rules > WAN
# Action: Block, Source: any, Destination: This Firewall, Dest Port: 443
# Then add allow rule above for trusted admin IP range only
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

