-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SELinux support development thread #1
Comments
Copied from a ticket on virtualmin.com: I actually do test with SELinux enabled and run with it enabled full-time on a couple of my own servers as a learning experience, and I think it's mostly reasonable these days, but there are several booleans you have to switch to make it work. The reason we disable it, and still recommend it be disabled, is that there's a huge variety of things (mostly outside of Virtualmin itself and not controlled by Virtualmin) that will fail in mysterious ways, and if they fail for a user other than root, they almost certainly won't even be able to figure out why. It really depends a lot on what you're doing. I have a list of the booleans I've come up with so far. Lemme grab those... OK, here's my notes on the subject, if you wanted to try it (but I can't recommend it for any system that'll be hosting other users...they will almost certainly run into weird errors and may not have any idea that it's SELinux causing it): # ProFTPd
setsebool -P ftp_home_dir=1
# Compatibility for FTP clients that don't use ephemeral ports
setsebool -P ftpd_connect_all_unreserved=1
# FTP server runs as daemon rather than inetd mode (maybe systemd spawn, as well?)
setsebool -P ftpd_is_daemon=1
# See also: ftpd_selinux man page
# Apache bools: https://wiki.centos.org/TipsAndTricks/SelinuxBooleans Sorry, this last bit is just a link, and I haven't sorted out exactly which bools are needed for the general case, but there will be quite a few httpd bools that need to be enabled that aren't default. I have a list of some of them somewhere, but it's not in my todo list for some reason. I guess I have some SELinux notes somewhere else. I'll try to dig those up. It's in my plans to make an install target that enables SELinux, but it probably won't be super soon; the problem is that if you setup SELinux to work really smoothly for all the use cases most people have for a Virtualmin system, you've probably opened it up too much to do any good. There really needs to be some awareness of what the system is used for, so that the booleans can be set appropriately. But, the good news is that they are mostly booleans (just on/off switches) at this point. The first time I setup a Virtualmin system with SELinux it required a gazillion specific manually created rules. There's still gonna be a lot of them...maybe two dozen once all services are accounted for, but nothing like that first SELinux system. I guess what I'm trying to say is that SELinux is probably actually usable enough to where we could roll it out for some users, and I've started adding support for it in Virtualmin-Config already (some bools get set during the relevant plugin), but I still have serious reservations about its usability. It's a terrifyingly complex system. |
SELinux would be amazing to get working fully on Virtualmin to help prevent users from hacking other users accounts on a shared server, currently possible against live internet servers, such the hack where they upload a PHP shell disguised with an image extension, then visiting the URL of the image, the web server executes it and the hacker gets the php shell which gives the ability to read privileged system security files |
No PHP script has the ability to run as root, even if the user isn't using suexec. PHP never runs as root and thus can't read There are real threats that SELinux can prevent, but that's not one of them. |
|
SELinux wouldn't prevent that. Your attacker was using privileges the domain owner user and the script already had and would continue to have under SELinux. SELinux wouldn't prevent a user from reading files the user is supposed to have access to. It won't solve exploitable web apps. It solves some kinds of privilege escalation, which would be its primary purpose on any sort of hosting system. There are tools that attempt to prevent some kinds of web-based exploits (like mod_security in Apache), though they tend to mostly address things that have already been fixed in the applications they protect so they are of limited utility. That kind of tool can maybe protect poorly designed apps that are exploitable using common SQL injection attacks. It's another discussion as to whether we ought to ship mod_security. It tends to introduce subtle functionality bugs, and rarely works without extensive tweaking, so it's been something I've been hesitant to inflict on users (or on our support burden, which is already too high for the small team we have), particularly since it tends to give people a false sense of security...it probably only prevents attacks that are already long fixed in WordPress or Drupal or whatever, and new exploits won't be addressed in the rulesets until some point after it's already fixed in WP or Drupal or whatever.
Improving security is always great; but we've gotta match up the threat model to the right solutions. SELinux solves several security problems. But, it doesn't solve insecure web applications. |
@swelljoe |
Hi, Does anyone know if Virtualmin be used with SELinux enforcing? Is it by default or some changes are required? Thanks! |
I think all of the answers to your question can be inferred from this thread, @ShopixRo . ;-) Virtualmin can be used with SELinux enforcing (read above, I have a couple of servers doing so), but it is not the default (also mentioned above for the reasons also given). Some changes are required (at least the ones mentioned above, possibly more given your environment and requirements). SELinux needs a lot more hand-holding than most people are willing to do, and in my testing I think I've convinced myself it's not going to be something we can ship as a default, but it might be something that can be enabled for users that want it and are are prepared to pay the additional administrative and support cost. |
I think having as good or better security than Android OS - which runs on Linux, and is "everywhere", just like Virtualmin is - is a worthy goal to aim for.
|
Android is a wildly different platform. They don't even use common package formats, and distribute their OS updates in a container-y image format. Completely irrelevant to what we do...we aren't shipping an operating system and don't have that level of control over the system. SELinux is on the radar but it's unlikely to be default anytime soon unless someone else does the development or sponsors it. |
This is just a place for me to dump my notes about running Virtualmin with SELinux enabled (and for anyone else to contribute their own experimental results). It's possible, but still somewhat prone to mysterious failures for non-root user actions (i.e. domain owner users may still find themselves getting confusing permissions errors and will be unable to diagnose them without root-user assistance).
The text was updated successfully, but these errors were encountered: