pfSense CE 2.9.0-DEVELOPMENT - High - Remote - File write - CP file manager
abraxaslabs.tech · github.com/abraxas · @abraxas_null · [email protected] · pfsense-cp-filemanager-write
Class: File write Reach: Remote
pfSense CE 2.9.0-DEVELOPMENT (9363ac5) - pfsense.org
Upload name is not basename(). A name that already contains captiveportal- skips the prefix. file_put_contents("{$g['captiveportal_element_path']}/{$data['name']}") with cpelements = /var/db/cpelements. Remaining ../ after captiveportal-.. still walks to /.
| ID | no CVE yet |
| Class | File write |
| Reach | Remote (authenticated WebGUI unless noted) |
| CWE | CWE-22 |
| CVSS | High: 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| Product | pfSense CE |
| Affected | 2.9.0-DEVELOPMENT (9363ac5b8651a1c7a333180425ce7719070f95f9) |
| Auth | WebGUI session with page-services-captiveportal-filemanager |
| License | GNU Affero GPL v3.0 |
| Lab | 127.0.0.1 only |
I pinned public master 9363ac5. The lab is a PHP gadget of the pinned sink, loopback HTTP on 127.0.0.1:19000.
Series write-up: https://abraxaslabs.tech/research/pfsense-ce-leftovers
| Method | Sink | Privilege |
|---|---|---|
| POST services_captiveportal_filemanager.php file name | file_put_contents cpelements/{$data['name']} | Integrity: Lab-proven: name captiveportal-../../../../../oracle/... skipped the prefix and wrote outside cpelements. Root PHP write is host RCE on this platform. |
| same leftover | same sink | Recon: Inferred: overwrite config.xml or www PHP. |
| same leftover | same sink | Availability: Inferred: overwrite critical files. |
Requires: page-services-captiveportal-filemanager. CSRF-magic on POST unless noted. WebGUI PHP-FPM is root.
Requires: page-services-captiveportal-filemanager. CSRF-magic on POST unless noted. WebGUI PHP-FPM is root. CSRF-magic on POST unless noted. WebGUI PHP-FPM is root.
Name without the substring is prefixed and cannot escape that way. Documented PHP inside the portal jail is a different feature.
No Diagnostics: Command unless that page is also granted.
cd lab
./run.sh
Loopback 127.0.0.1:19000. Compose project pfsense-cp-filemanager-write. Witness PFSENSE-CP-FILEMANAGER-WRITE-WITNESS. Loopback only: 127.0.0.1:19000. Compose project pfsense-cp-filemanager-write. Witness PFSENSE-CP-FILEMANAGER-WRITE-WITNESS. PHP gadget of the pinned lines. Stack tears down after the run.
Last line:
SUCCESS PFSENSE-CP-FILEMANAGER-WRITE control-prefixed=yes prefix-no-escape=yes trigger-outside=yes PFSENSE-CP-FILEMANAGER-WRITE-WITNESS
basename() the upload name. Always prefix. Reject .. .
9363ac5b8651a1c7a333180425ce7719070f95f9