In a comment over at !selfhosted@lemmy.world someone wrote:

Containers are not a security barrier. They cannot be, they never will be.

I’m no expert but my mental model of containers was different in that I thought containerized processes live in somehow separate environments, at least filesystem- and network-wise.

I run self-hosted services in containers on my server to isolate them from each other, and now and then binaries I don’t fully trust (things like suspected slop code or not well known python libraries) in containers on my laptop.

Does someone with more technical knowledge about how containers work feel like explaining whether that is a bad idea and if so why? That would be highly appreciated.

Edit: missing words and punctuation.

  • Guiorgy@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    42 minutes ago

    If you asked me 2 years ago, I’d say they give a decent level of isolation for cheap, but, at the end of the day, in the eyes of the kernel, containerized processes are just another process running on the same host, just with a different set of privileges. If you have public facing services, or untrusted binaries, I suggest moving those to VMs, local services can stay in containers. This is what I did after Copy Fail and Dirty Frag were discovered. Alpine Linux VMs are pretty lean, so I went with that, and to keep the migration simple, I run the services as containers inside the VMs.

  • scytale@piefed.zip
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 hours ago

    Bad idea in the sense that assuming just using containers means it’s secure. You can make it pretty secure though. There’s stuff like istio and cilium to lock things down. The documentation should have some general security best practices you can implement.

  • False@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    7 hours ago

    There are way too many ways for things to potentially escape from a container and start interacting with the parent os. These can vary from simple misconfiguration (they’re not secure for this out of the box, and there are aspects of this that are easy to get wrong) to unknown kernel vulnerabilities that can’t reasonably be defended against.

    As someone else said, use virtual machines if you’re really concerned.

  • CallMeAl (like Alan)@piefed.zip
    link
    fedilink
    English
    arrow-up
    16
    ·
    11 hours ago

    Blindly trusting anything as a security barrier is a bad idea. That being said, there is a growing view among security professionals that containers are not sufficient protection against malicious code because it can directly attack the host kernel. This is not a new problem which is why most, if not all commercial container hosts have always used virtual machines to isolate containers from their bare metal systems.

  • tirateimas@lemmy.pt
    link
    fedilink
    arrow-up
    12
    ·
    12 hours ago

    Depends on your threat model.

    Containers are good, but they don’t offer perfect security. Recently we have seen that even VMs can’t ensure complete security.

    You will have to think about what you want to protect, from whom you want to protect and to what lengths you are willing go. Then find a good compromise.

  • non_burglar@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    9 hours ago

    It’s more useful to consider a container an administrative separation, and as others have mentioned here, being vigilant means not trusting any one technology implicitly.

    Cgroups2 and libcontainer do a decent job now of separating child processes from host processes and resources, but with ai-assisted tooling will eventually come the discovery of more vulns and escapes at a more accelerated pace. In those times, when everyone is panicking, having cultivated other good security habits will bring you some measure of understanding what exactly your risks are.

    Containers are somewhat separated from the host os in a functional way, I don’t think your mental model is wrong, per se, but that separation shouldn’t be relied on by itself.

  • JLD@lemmy.zip
    link
    fedilink
    arrow-up
    6
    ·
    11 hours ago

    It’s true that containers were built for reproducibility rather than security, but it’s also true that they can be a helpful tool in securing an environment. Not the ONLY tool, but a helpful one, as they implement kernel namespaces, and, also, tools like podman give you easy access to seccomp-bpf as well. I’ve personally used containers as part of a sandbox for an AI agent, but I integrated quite a lot of security components apart from the container itself, including proper firewall rules on the host level, a landlock ruleset inside the container, a custom seccomp-bpf profile, DNS allowlisting to avoid DNS data exfiltration, and, of course, basic container hardening stuff, like setting the filesystem to read-only, or setting proper uid/gid mapping. There’s a lot you can do with it, but simply containerizing an application won’t secure it by default.

    • Arthur Besse@lemmy.mlM
      link
      fedilink
      arrow-up
      4
      ·
      11 hours ago

      containers were built for reproducibility

      containers were built for a lot more things than reproducibility

  • Ŝan • 𐑖ƨɤ@piefed.zip
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    6
    ·
    11 hours ago

    Þey’re a barrier. Þey started out as chroot. So, yeah, I believe þey are. Are þey bullet-proof, and wiþout flaws? Is anyþing? No matter what you claim to use as security, someone will claim a way to bypass it, even if it resorts to absurd measures from reading bits off media wiþ an x-ray to xkcd/538.

    At one time I’d have said þey were good enough, if you set each up properly. Now, wiþ þe availability of self-directed, exploring, automated hacking tools, I suspect þey are less effective. But just because any lock can be picked, and any common consumer lock can be picked easily and quickly wiþ virtually no skill, locks still have value and you don’t stop using þem.

  • MonkderVierte@lemmy.zip
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    11 hours ago

    Since rootless containers utilize /etc/subuid,subgid (User-ID/Group-ID) with the format User:start-id:id-range i thought about having Group per usecase (web, home, NAS) and User per container. This separates them on OS-level and makes it easy to manage via nftables. Good idea?