Fix RXSS in status_captiveportal.php : leveraging XSS to Remote root command execution #3288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The status_captiveportal.php suffers from a Reflected Cross-Site Scripting vulnerability (RXSS).
tl;dr : Demonstration video of the exploitation of a RXSS to bypass all CSRF security and trigger a Remote root reverse-shell on pfSense 2.3.2 latest release : https://www.youtube.com/watch?v=IWtf6LlfP_c&t=4s
This simple RXSS is triggered on page loading with a specific URL (validated with Firefox latest version 50.1.0) on the latest pfSense 2.3.2 RELEASE.
Through this XSS in GET param, an attacker can benefit of the current pfSense context in a victim's browser already logged as administrator in pfSense web administration interface.
Via this XSS, the attacker can forge his own and hidden request in the victim browser, with :
So, an attacker can exploit this XSS to bypass all CSRF mechanisms enabled in pfSense, then run a specific shell command to gain a full Reverse-root-Shell on the pfSense distribution.
As proof-of-concept, I've made this x.js script (to be hosted on the attacker's website like http://attacker.com/x.js for example) :
The attacker have to place a listening port (to receive the reverse-root-shell) with netcat for example on his own computer.
Then, just trigger the RXSS with this script included in the context of an authenticated session as admin in pfSense :
Change the "lhost" and "lport" parameters in the URL with the corresponding attacker's IP and port (with a netcat in listen mode).
This final URL can be obfuscated and/or hidden in a bitly.com short-url then sent to the legitimate pfSense's administrator.
I have created some BeEF modules (private for the moment, while pfSense isn't fixed) to exploit the same vulnerability / scenario.
This full PoC can be seen in the not-referenced demonstration video here : https://www.youtube.com/watch?v=IWtf6LlfP_c&t=4s
pfSense 2.3.2 contains several security mechanisms like:
But just with a simple RXSS in GET, all these security best-practices can be bypassed to gain a full reverse root shell remotely.
I suggest to double-check all $_GET/$_POST params directly reflected in the pfSense PHP source code without sanitization.
Plus, some HTTP headers can be added in pfSense for a better security, like: