-
Notifications
You must be signed in to change notification settings - Fork 21
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
Ship a more secure configuration by default #31
Comments
I've already working on an implementation. PR should be done in a week. |
Upstream issue on podman incompatibility found in testing: containers/podman#23453 |
We have plans to improve security regarding permission issues. MCSManager still requires root privileges to run because it does more than just run Docker images. It also supports running existing programs on the server. If we use a non-root user, it could cause a range of permission problems and increase the user's learning curve. However, we plan to have all child processes (also called instances) started by MCSManager run with non-root privileges, including Docker containers. All files in the instance working directory will have non-root permissions. |
I can also help implement that. What's you current plan on dropping the root privilege for child processes? Also, maybe it would suffice to add an option to the installation script for choosing whether existing programs will be run using root. I feel it rather safe to use a non-root user, because mostly this tool is for Minecraft (and alike) servers which listen on a port > 1024. Those who use existing tools that require su via MCSManager should be fine if they choose to enable root when installing. |
In summary, I think this involves quite a bit of work. Do you have any better ideas? If you agree, you can implement it according to my plan. If there are any other issues, feel free to bring them up here. If possible, you can also join our Discord, which might be more convenient. |
If you just want to create an "mcsm" user by installing the script and use this user to start MCSManager: This shouldn't be a problem for users familiar with Linux servers, but most users will encounter a series of permission issues, such as:
However, this development cost is the lowest. |
This is indeed much easier to implement. In fact in my deployment I'm using this model (along with rootless containers). Bullet point 1 would not be a problem, since most programs are accessible by normal users. Ordinary game servers do not require root privileges, and even if they do so for binding to lower ports such capability can be explicitly granted in the systemd service, avoiding root access. The node terminal should be disabled by default. It sounds pretty scary to have a root shell on the webpage, even if we impose strong password complexity requirements. Note that removing the node terminal feature along won't eliminate root access from web. The only way to do so would be running the service as a non-root user. |
Regarding the docker user issue: Docker does not use user namespaces. Instead, it uses a different /etc/passed file in the container. Thus, users inside the container and outside is not related at all, and uid in the container may not be valid outside. This will also cause issues when running with mcsm user in the container if we continue using docker as-is. |
If you're just aiming to have the setup script automatically create and use the "mcsm" user, I think someone's already helped me get that done. I'm just still on the fence about whether or not to use it. This is a brand new installation script, but we haven't officially used it yet. Line 41 in 9aae6b4
|
I actually wanna add installation and configuration of podman into the script
On Thu, Aug 1, 2024 at 14:50, Unitwk ***@***.***> wrote:
This is indeed much easier to implement. In fact in my deployment I'm using this model (along with rootless containers).
Bullet point 1 would not be a problem, since most programs are accessible by normal users. Ordinary game servers do not require root privileges, and even if they do so for binding to lower ports such capability can be explicitly granted in the systemd service, avoiding root access.
The node terminal should be disabled by default. It sounds pretty scary to have a root shell on the webpage, even if we impose strong password complexity requirements.
Note that removing the node terminal feature along won't eliminate root access from web. The only way to do so would be running the service as a non-root user.
If you're just aiming to have the setup script automatically create and use the "mcsm" user, I think someone's already helped me get that done. I'm just still on the fence about whether or not to use it.
https://github.com/MCSManager/Script/blob/9aae6b40cbb38ed4bfd88a0dc98e3f8c2c76d652/install_update.sh#L41
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I do not agree with this idea, nor is it necessary. |
Got it. But at least we should consider merging the PR that uses mcsm user to run the daemon, or allow the user to choose whether root should be used for running the daemon. Along with that we might better disable docker-related things when `mcsm` user is used (again, by default), since any use of docker may allow privilege escalation from that user. if the user `mcsm` is not in group `docker`, docker.sock will not be usable anyway. A good way of implementing this would be asking if you’re running the tool commercially for other users. If you’re not, we avoid using root and hide docker-related things.
I agree with you that the things related to rootless container should go into the docs instead of the script.
On Fri, Aug 2, 2024 at 16:47, Unitwk ***@***.***> wrote:
I actually wanna add installation and configuration of podman into the script
I do not agree with this idea, nor is it necessary.
If other users also need to use podman, just specify in the documentation how to make MCSManager use podman.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Merged |
Even if it is not a commercial scenario, using Docker is still an excellent solution for coexistence of multiple versions of MC. If you want to open multiple MC servers of different versions at the same time, you will encounter the problem that they have different requirements for Java versions. The Docker used is a simple, fast and stable solution for coexistence of different versions of Java. |
In fact this can be implemented in multiple ways, one being manual installation, the other being Nix package manager.
On Tue, Aug 6, 2024 at 12:57, huangsijun17 ***@***.***> wrote:
Got it. But at least we should consider merging the PR that uses mcsm user to run the daemon, or allow the user to choose whether root should be used for running the daemon. Along with that we might better disable docker-related things when mcsm user is used (again, by default), since any use of docker may allow privilege escalation from that user. if the user mcsm is not in group docker, docker.sock will not be usable anyway. A good way of implementing this would be asking if you’re running the tool commercially for other users. If you’re not, we avoid using root and hide docker-related things. I agree with you that the things related to rootless container should go into the docs instead of the script. On Fri, Aug 2, 2024 at 16:47, Unitwk @.> wrote: I actually wanna add installation and configuration of podman into the script I do not agree with this idea, nor is it necessary. If other users also need to use podman, just specify in the documentation how to make MCSManager use podman. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>
Even if it is not a commercial scenario, using Docker is still an excellent solution for coexistence of multiple versions of MC. If you want to open multiple MC servers of different versions at the same time, you will encounter the problem that they have different requirements for Java versions. The Docker used is a simple, fast and stable solution for coexistence of different versions of Java.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
But I agree that Docker is an elegant choice regarding this.
On Tue, Aug 6, 2024 at 12:57, huangsijun17 ***@***.***> wrote:
Got it. But at least we should consider merging the PR that uses mcsm user to run the daemon, or allow the user to choose whether root should be used for running the daemon. Along with that we might better disable docker-related things when mcsm user is used (again, by default), since any use of docker may allow privilege escalation from that user. if the user mcsm is not in group docker, docker.sock will not be usable anyway. A good way of implementing this would be asking if you’re running the tool commercially for other users. If you’re not, we avoid using root and hide docker-related things. I agree with you that the things related to rootless container should go into the docs instead of the script. On Fri, Aug 2, 2024 at 16:47, Unitwk @.> wrote: I actually wanna add installation and configuration of podman into the script I do not agree with this idea, nor is it necessary. If other users also need to use podman, just specify in the documentation how to make MCSManager use podman. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>
Even if it is not a commercial scenario, using Docker is still an excellent solution for coexistence of multiple versions of MC. If you want to open multiple MC servers of different versions at the same time, you will encounter the problem that they have different requirements for Java versions. The Docker used is a simple, fast and stable solution for coexistence of different versions of Java.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
As @unitwk mentioned, the current script already supports installation using a general user "mcsm" and this is the default behavior. It also supports upgrading to the latest version (9 or 10). In my opinion, MCSM, as a control panel program, will likely need sudo/root permissions at some point (e.g., managing Docker, system services, or permissions for files owned by other users). In that case, our goal should be to minimize the use of root permissions when possible. But this would require significant coding and restructuring of the entire architecture, and would make the program unnecessarily complex. I personally would vote for the default installation using user 'mcsm' (potentially with Docker disabled as @panda2134 suggested). For experienced users who can manage Docker correctly, using root is probably just fine. For others, a generic user should be sufficient for most cases and also provides better security. |
Currently, both the daemon and the frontend are run as root in the default configuration. This is too dangerous even for self-deployed instances. It is much better if we can get rid of root access, so that even if MCSManager is compromised, the system as a whole stays safe.
Attack model: Attacker can find ways to do remote execution with MCSManager. We need to isolate damages to the system even if this is done.
On the other hand, the source code in both
web/
anddaemon/
folders are writable. Even if we run MCSManager as a non-root user, the attacker can easily change the contents of the server code. It would be slightly better if we setapp.js
to be read-only for the user that executes MCSManager.It will be easy to run
web/app.js
as an ordinary user. However, runningdaemon/app.js
as an ordinary user would be difficult. To gain access of docker, one has to be added to thedocker
group. This immediately enables delegation attack -- an attacker who has shell access to host system (for instance, by compromising the daemon) will be able to modify every file on the host system as root by simply mounting/
into the container. This will allow the attacker to do privilege escalation.The solution would by user namespaces, either by using rootless docker or podman. This PR enables integration with other container runtimes like podman. With that in mind, the following changes should be made to the installation script:
mcsm-daemon
mcsm-daemon
while enabling related systemd hardening options.The text was updated successfully, but these errors were encountered: