Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How does pfsense's web interface run root scripts

    Scheduled Pinned Locked Moved General pfSense Questions
    11 Posts 4 Posters 5.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jimpJ
      jimp Rebel Alliance Developer Netgate
      last edited by

      Our scripts all run under the root user. Not really ideal for some things, but ultimately unavoidable for the things we need to do.

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • M
        mercutio22
        last edited by

        Interesting. But the webinterface which is PHP itself doesn't run as root or does it? How do you run a root script after a user submits a form?

        I am trying to look at the source code but I am not finding the relevant parts. Perhaps you can point me in the right direction.

        1 Reply Last reply Reply Quote 0
        • jimpJ
          jimp Rebel Alliance Developer Netgate
          last edited by

          The web server runs as root, and so do all the pages (PHP, etc).

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          1 Reply Last reply Reply Quote 0
          • M
            mercutio22
            last edited by

            Ok I see. I thought that would too vulnerable in case there was some vulnerability in the webinterface itself, allowing for privilege escalation. Do you guys use chroot or freebsd's JAILS as a security measure instead?

            1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

              No, it's just the nature of how it has to be in order for it to properly function and do what needs to be done. In part it's that way because we inherited that from m0n0wall, but there's really not a viable way to separate those function and maintain all of required abilities.

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • D
                dhatz
                last edited by

                @mercutio22:

                Interesting. But the webinterface which is PHP itself doesn't run as root or does it? How do you run a root script after a user submits a form?

                Apart from dnsmasq and dhclient, most processes on pfSense run as roon, including lighthttpd, php, openvpn etc.

                As far as I can tell, to minimize exposure to potential security vulnerabilities in the webGUI, one would have to disallow access to the webGUI from all interfaces except a specific "secure" interface.

                1 Reply Last reply Reply Quote 0
                • M
                  mercutio22
                  last edited by

                  What about using sudo?

                  People on the python channel are saying I should not consider running the webserver and django as root. They were surprised to learn pfsense does that.

                  1 Reply Last reply Reply Quote 0
                  • C
                    cmb
                    last edited by

                    Ideally, no you don't want to do that. But by the nature of what we do, there is no effective security difference. The front end must have rights to change the config file at a minimum, and anything that has the rights to do that can execute things as root. You could use sudo if you want, but it's basically pointless, if the user running the web server can run sudo it's effectively no different than running it as root. We're considering options going forward to completely separate the front end and back end, which would eliminate that root requirement. But in 10+ years m0n0wall has existed and the 8+ years we've existed, there have been exactly 0 security vulnerabilities caused or worsened by that fact.

                    1 Reply Last reply Reply Quote 0
                    • M
                      mercutio22
                      last edited by

                      @cmb:

                      You could use sudo if you want, but it's basically pointless, if the user running the web server can run sudo it's effectively no different than running it as root.

                      Well I am no unix guru, but it seems to me that adding sudo access to a restricted subset of commands would be very different than allowing unrestricted access to all root commands.

                      I mean, you could have /etc/sudoers entry allowing the www user access to scripts that edit the /etc/interfaces, etc:
                      i.e.  www    ALL=(root)  NOPASSWD: /path/to/alter_interfaces.sh

                      Or something like that. I am not very fluent in sudo yet.

                      1 Reply Last reply Reply Quote 0
                      • C
                        cmb
                        last edited by

                        You can do that, but we run so many things from the web server that it would be functionally no different to allow everything.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.