General security in an OMV/Portainer installation

  • I don't know where this belongs, because it's very general regarding security.


    I think a lot of new OMV users expect that they can expose their servers to the Internet, to create their own cloud and to use apps to access their content over the Internet. I don't think many sane person would do all this work if it wasn't to avoid the pitfalls of big techs easy offerings, so, I think many OMV users see it from a perspective of replacing big tech with their own server and as such expect it to be exposed to the Internet.


    I'm a new user of Open Media Vault and I'm not used with Linux or administrating privileges or have any deeper knowledge about security. Basically I'm a Windows slave that have only occasionally been checking out Linux, but never rally gone down that path.


    After setting up Portainer and installing Airsonic and Jellyfin, I started wondering how in the world they could access my media drive without specifying anything but binds, UID and GID. I didn't specify the user password anywhere or give permissions to the users created for Airsonic or Jellyfin. What I gather is that to do all it's magic, Portainer runs the containers with elevated privileges and I find that very insecure, especially if I want to expose the server to the Internet?


    When I started to dive into this question, it quickly started to become very esoteric to me and I think it would to the vast majority of people.


    Somehow I would need to not run the containers in privileged mode and only use the specified users credentials, to be able to control their access from OMV. (Why do I have to specify UID and GID, when it's being overridden by privileged mode?)


    As I see it I would also have to restrict Portainer and Docker, as they can create new containers that could run in privileged mode. So, if they are hacked, wouldn't it be more or less an open door to the system? Or maybe I could get away with maximizing the security when accessing Portainer and Docker, probably by not opening those ports to the Internet? Or at the very least use 2FA if I expose them to the Internet?


    I should probably also set up SSL and my limited knowledge about it is that it isn't a walk in the park.


    After that, my lack of experience and understanding with security would probably leave some wide open holes anyway?


    So, that leads me the the greater question, is it safe at all for ordinary people to expose their OMV/Portainer installation to the Internet? Is there any easy way to handle decent security, that most people would be able to manage?

    • Official Post

    I started wondering how in the world they could access my media drive without specifying anything but binds, UID and GID. I didn't specify the user password anywhere or give permissions to the users created for Airsonic or Jellyfin. What I gather is that to do all it's magic

    You are just basically creating a mountpoint inside the container with the volume you pass. And since the user inside the container is root, it can access the data in those mountpoints. No magic involved. That is why you need to be selective on what volumes you expose to your containers. You could mount it ro (readonly) though.


    I would not expose your OMV web interface or portainer to the internet. If you expose a container to the internet, a hacker would first have to hack the application running in the container and the hack docker to get out of the container. That takes a lot of skill and most hackers that good are not going to target a home user. Running unprivileged containers would help but still not impossible to hack and a pain to setup/use.


    I think you are over-worrying about this. Just expose the containers to the internet that you absolutely have to. Only present data to those containers that they absolutely need. Use readonly mounts if you can. If you still are worried, run docker in a VM (could be OMV too) running on OMV. It would take a country sponsored hacker to break out of that.

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Official Post

    As I see it I would also have to restrict Portainer and Docker, as they can create new containers that

    Exposing Portainer to the internet is a bad idea.

    You can use swag to safely expose the services you need. swag allows you to configure authelia if you need it in certain services to establish access with 2FA double authentication...

  • Thanks for your reply.


    I definitely lack understanding of the security in Docker/Portainer, Linux and security in general.


    I understand the mount point more as a direction and not a permission? So, I suppose that somehow it's still Docker/Portainer providing the access to the shared folder with the root from Open Media Vault? Or am I lost here?

    • Official Post

    I understand the mount point more as a direction and not a permission? So, I suppose that somehow it's still Docker/Portainer providing the access to the shared folder with the root from Open Media Vault? Or am I lost here?

    Just to clear one thing up, portainer doesn't do anything of this. All portainer does is start and stop containers. It doesn't even restart the containers on boot (docker service does).


    When you tell a container it can access a path (a sharedfolder is just a path), the container can access that path because docker is running as root meaning your container is running as root as well. rootless docker is a pain. If you wanted to run rootless, I would recommend podman. When you specify uid or gid, that is basically just the container emulating that user/group and the container can do that because it runs as root.

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Just to clear one thing up, portainer doesn't do anything of this. All portainer does is start and stop containers. It doesn't even restart the containers on boot (docker service does).


    When you tell a container it can access a path (a sharedfolder is just a path), the container can access that path because docker is running as root meaning your container is running as root as well. rootless docker is a pain. If you wanted to run rootless, I would recommend podman. When you specify uid or gid, that is basically just the container emulating that user/group and the container can do that because it runs as root.

    Yes, I'm still feeling like landing on Mars, a lot of new concepts.

    Thanks for the suggestion about Podman. I guess it would add some security to run rootless, even though Portainer isn't directly exposed, if there for example is a security vulnerability in one of the containers. I guess I just configure a "dockeruser", that has access to the necessary resources and Podmad could help me with that.

    Your answer also cleared it up bit about UID and GID.

    • Official Post

    even though Portainer isn't directly exposed,

    If you moved from portainer to the compose plugin, that would be one less security vulnerability to worry about.

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Official Post

    Your answer also cleared it up bit about UID and GID.

    I think this reading would be explanatory for you. https://wiki.omv-extras.org/doku.php?id=omv6:docker_in_omv

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!