CVE-2021-41282
📋 TL;DR
CVE-2021-41282 is a command injection vulnerability in pfSense's diag_routes.php that allows authenticated users to inject sed commands and write arbitrary files. This can lead to remote code execution on the firewall appliance. All pfSense 2.5.2 installations with authenticated users are affected.
💻 Affected Systems
- pfSense
📦 What is this software?
Pfsense by Pfsense
⚠️ Risk & Real-World Impact
Worst Case
Full system compromise with root access, allowing attacker to pivot to internal networks, intercept traffic, or disable firewall protections.
Likely Case
Unauthorized file write leading to web shell deployment and persistent access to the firewall management interface.
If Mitigated
Limited to authenticated users only, with proper access controls preventing exploitation by unauthorized personnel.
🎯 Exploit Status
Exploit requires authenticated access but is straightforward with published proof-of-concept code available.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 2.6.0 and later
Vendor Advisory: https://docs.netgate.com/pfsense/en/latest/releases/22-01_2-6-0.html
Restart Required: No
Instructions:
1. Backup current configuration. 2. Update pfSense to version 2.6.0 or later via System > Update. 3. Apply the update and verify successful installation.
🔧 Temporary Workarounds
Restrict Web Interface Access
allLimit access to pfSense web interface to trusted IP addresses only
Configure firewall rules to restrict access to pfSense web interface (port 443) to specific management IPs
Disable diag_routes.php
linuxRemove or restrict access to the vulnerable script
mv /usr/local/www/diag_routes.php /usr/local/www/diag_routes.php.disabled
chmod 000 /usr/local/www/diag_routes.php.disabled
🧯 If You Can't Patch
- Implement strict access controls to limit who can authenticate to pfSense web interface
- Monitor for suspicious file writes in /tmp directory and web root locations
🔍 How to Verify
Check if Vulnerable:
Check pfSense version via web interface Dashboard or CLI: pfSense-version
Check Version:
pfSense-version
Verify Fix Applied:
Verify version is 2.6.0 or later: pfSense-version | grep '2\.6\.'
📡 Detection & Monitoring
Log Indicators:
- Unusual sed command executions in system logs
- File writes to unexpected locations from web user
- Multiple failed authentication attempts followed by successful login
Network Indicators:
- Unusual outbound connections from pfSense appliance
- HTTP requests to diag_routes.php with suspicious parameters
SIEM Query:
source="pfSense" AND (process="sed" OR process="netstat") AND user="www"
🔗 References
- http://packetstormsecurity.com/files/166208/pfSense-2.5.2-Shell-Upload.html
- https://docs.netgate.com/pfsense/en/latest/releases/22-01_2-6-0.html
- https://www.shielder.it/advisories/
- https://www.shielder.it/advisories/pfsense-remote-command-execution/
- http://packetstormsecurity.com/files/166208/pfSense-2.5.2-Shell-Upload.html
- https://docs.netgate.com/pfsense/en/latest/releases/22-01_2-6-0.html
- https://www.shielder.it/advisories/
- https://www.shielder.it/advisories/pfsense-remote-command-execution/