294 points · by GordonS · 7y ago · 112 comments
We put a lot of effort into being able to run an application directly from a compressed single-file binary, you have a small executable with a big payload attached to the end of it. The payload essentially contains a mountable filesystem, however because windows doesn't support doing anything like that from an unprivileged account we had to emulate many things Windows normally does, including execution of binary images.
We did some tricks where executable data was stored on disk in a format it can be directly memory mapped and run without reading anything - this allowed us to launch most applications over a network without extracting anything to disk locally and achieve millisecond launch times. Pages would get pulled into local memory by the OS as needed while the application was running.
The end result was that you can create a single EXE file could contain things like python + script, or more complex like photoshop & Word. Just go to a new computer from a guest account, launch the EXE and you instantly start using that app.
I haven't been involved with it for the last 6 years, but I believe vmware still offers it.
My email is in my profile - fee free to say hi!
I've seen people do it by running something like calc.exe suspended then remapping all the memory. The trouble is, this approach certainly wouldn't work for situations involving 64 bit Windows and 32 bit binaries, and well, it's ugly and confusing ("why is Photoshop running under calc.exe?") Surely, the solution had to be nicer than that?
[0] https://en.wikipedia.org/wiki/W%5EX [1] AFAIK, on Linux NX isn't something that is enabled or disabled for individual programs anyways, it's up to the userland whether or not it takes advantage of the mmap(2) mapping flags
And yet we always find new ways to waste it. 16 GB was once an unimaginable amount of space, and yet one of my coworkers now takes it for granted that 16 GB isn't enough storage for a smartphone.
We should do our best not to waste any more.
No one seemed to understand that if data filled up completely, the entire cluster would go offline because _we wouldn’t have the space for anything_.
Sure, but I don't think you can do that within a self-contained binary, the kernel doesn't really support that. It would have to just be a loopback image, and lose the whole "self-contained binary" angle that makes this different from all sorts of other container tech.
I think this could also be achieved with a loopback device setup to cover some of the file, again no relevance to NX etc, but that would require setuid or similar to configure the device
Which is why we use Singularity[0]. Apologies if I’m missing something, but to me this problem they’re trying to solve, has already been solved. As stated in the README:
> Singularity is an open source container platform designed to be simple, fast, and secure. Singularity is optimized for EPC and HPC workloads, allowing untrusted users to run untrusted containers in a trusted way.
Singularity ‘requires’ root or elevated privileges to create and modify containers, but running them is done in the user’s namespace with that user’s permission set. And privileges can’t be elevated during the containers runtime as there are kernel level catches that prevent sudo and su from working inside the container.
In terms of the ‘static’ part, Singularity uses SquashFS to produce a single binary image, and uses the SIF (Singularity Image File) format to define applications, their dependencies, and runscripts. On top of being able to run anything inside the container with the `exec` subcommand.
You can also create sandbox development images that are just a directory on disk for testing things out and installing/building tools manually, then convert it into a SIF container after for cluster deployment. Or be nicer and port your process into a recipe/definition file.
Most scientific/HPC related centers have started utilizing Singularity for their container workflow. Tools like Docker are essentially banned because of their perma-root privileges[1].
[0] https://github.com/sylabs/singularity [1] I’m an admin who reimplemented Singularity on our university’s cluster. With a heavy need on filesystem integration (which Singularity solves with great configuration options), containers which run with root privileges would be a massive security vulnerability.
> Which is why we use Singularity[0]. Apologies if I’m missing something, but to me this problem they’re trying to solve, has already been solved. Singularity ‘requires’ root or elevated privileges to create and modify containers,
Well, Singularity came out at the same time as runc's rootless containers support was developed -- so at the time it wasn't solved at all. It required (and still requires for several operations and features) root privileges in order to work (such as suid helpers in addition to explicit root requirements).
It's not acceptable for a usecase where you cannot run anything as root (not even installation scripts). That was the use-case, and rootless runc (and now thanks to Akihiro and Guiseppe, rootless Docker and Kubernetes) in theory can now work without the need for any suid helpers -- though these days there is an increasing usage of newuidmap and newgidmap (which isn't mandated for the rootless runc implementation).
At the time, LXC's unprivileged containers was the closest thing and it had a few (mostly optional) suid binaries -- I wanted absolutely none.
> but running them is done in the user’s namespace with that user’s permission set. And privileges can’t be elevated during the containers runtime as there are kernel level catches that prevent sudo and su from working inside the container.
This last part really isn't revolutionary at all. All it really takes is a syscall and three files to write to. The hard part is getting everything else to work without root privileges.
> Well, Singularity came out at the same time as runc's rootless containers support was developed -- so at the time it wasn't solved at all. It required (and still requires for several operations and features) root privileges in order to work (such as suid helpers in addition to explicit root requirements).
Alright, but I wasn’t asking about a “back then” scenario, I was mostly trying to figure out what this offers _today_. From a Singularity end-user’s perspective, there’s only one function that requires elevated permissions, and that’s building.
> It's not acceptable for a usecase where you cannot run anything as root (not even installation scripts). ... At the time, LXC's unprivileged containers was the closest thing and it had a few (mostly optional) suid binaries -- I wanted absolutely none.
Now I understand what this offers and it’s overarching goal is. In my specific situation (which is the angle I’m looking at this from), that’s not really a big deal due to the way we handle global and local software installation. I understand this is not a universal situation.
> This last part really isn't revolutionary at all.
I don’t think I made it sound like it was revolutionary, I was just sharing what a commonly used tool in HPC does for a security measure.
Based off of the binctr README:
> Create fully static, including rootfs embedded, binaries that pop you directly into a container. _Can be run by an unprivileged user._
My main confusion stems from that. In comparison to Singularity, it doesn’t seem to offer anything new or noteworthy that would make me take a second look at it. The first phrase just makes me think I’m saving myself a few keystrokes as I wouldn’t have to type `singularity shell <container>` to shell into my container of choice. It just looks like yet another container solution. I still find these things cool (and their above my head in dev terms), but it feels like programming languages, a new one popping up every so often.
I’m primarily looking to see what advantages (or differences in approach) this offers over Singularity, Shifter, or Charliecloud, etc for my context. At least in terms of security and efficiency.
No, but I'm a maintainer of runc and implemented all of the core features that binctr uses (or rather, that Jessie hacked together for a proof of concept). I've also implemented rootless support in quite a few other tools to the point where now an unprivileged user can download, extract, and run a rootless container. In addition, I'm working with some other folks who joined later to get Kubernetes (and Docker) to be completely rootless.
> From a Singularity end-user’s perspective, there’s only one function that requires elevated permissions, and that’s building.
(Most forms of) execution still requires setuid binaries, which means that you have to have root permissions in order to install Singularity. You can use rootless containers as a completely unprivilged user (meaning that if you have unprivileged shell access to a random box you can use containers). Singularity cannot do this.
> I was just sharing what a commonly used tool in HPC does for a security measure.
My point was that basically any container runtime can do what you described.
> I’m primarily looking to see what advantages (or differences in approach) this offers over Singularity, Shifter, or Charliecloud, etc for my context. At least in terms of security and efficiency.
Many of those tools require setuid binaries that are developed as part of their container runtime -- which means that all of the security is contingent in no vulnerabilities in their setuid binaries (something that is hard to do even for the developers of programs like sudo).
Rootless containers are a project that requires absolutely no privileged codepaths for any container operation (though these days you can optionally use standard setuid binaries -- by default they are not used). This is something that none of the projects you listed (as far as I'm aware) can do.
The only new thing I’m seeing from this solution is the ability to create containers as an unprivileged user, which for most scenarios I tend to view as a non-issue. Or am I misunderstanding that?
binctr is a proof of concept that was written almost 3 years ago. These days, rootless containers are being integrated into many tools. Right now, under [1] we have some tooling which allows you to run Docker, cri-o and Kubernetes in rootless mode. Cloud Foundry's default configuration now uses rootless containers.
So really, it's not a choice between binctr and something else (binctr was a proof-of-concept) -- in fact please don't run binctr in production. But runc and quite a lot of other tooling has rootless support now.
Singularity doesn't do rootless containers, it still requires suid binaries in several cases. But I'm biased, having had some pretty bad arguments with the lead developers in the past (mainly for misrepresenting runc).
I believe you're mislabeling it as a non-issue, it seems to be the core problem they're trying to solve:
From the blog[0]:
> Yes, we all know that containers run unprivileged processes; but creating and running the containers themselves requires root privileges at some point.
> What is the awesome sauce we all gain from this?
> Well judging by the original GitHub issue about unprivileged runc containers, the largest group of commenters is from the scientific community who are restricted to not run certain programs as root.
[0]: https://blog.jessfraz.com/post/getting-towards-real-sandbox-...
charliecloud is designed specifically not to need suid: https://github.com/hpc/charliecloud
docker will hopefully support full unprivileged use soon: https://github.com/moby/moby/pull/38050
I have one Python project where I'm just using Docker to produce a single, self-contained lump so I don't have to fuck around when installing. This would be a step forward for me.
And then I have a Python library and command-line tool [1] where an awful lot of the issues people report are library version nonsense. I tried to help the first few, but at this point I've decided it's just not my job to make up for the Python community's packaging issues and/or issues related to other open-source projects and OSes. I'd love to be able to produce the equivalent of a statically linked binary for those people.
Java jars aren't far off from having their own rootfs included along with the compiled class files.
The single-user approach creates clashes between the network devs who want to build empires of containers they "own", and the stack-level bare metal purists who want the system to be as clean and secure as possible by isolating things where they should be isolated (to a single user instance for that purpose alone). This is not a new problem, nor a very well thought-out solution.
Containers are always a less-than-ideal implementation for people running Linux natively. The ideal way to sandbox in Linux is create a user account, download and test whatever code, see what breaks or infringes with its unique notion of "privileges", and delete the user when done.
But because you can't switch users on the same kernel when you're not running Linux natively, we have containers and all the messes they create. https://developers.slashdot.org/story/12/12/29/018234/linus-...
So people thought that instead of fixing the apps it was easier to fix the kernel. But this resulted in a big complexity with namespaces, capabilities, cgroups etc.
- under its own userid
- in its own namespace for mount, network, process-id, user-id, ipc, uts and control groups
and presto, you are running in a container.
With linux, it's because the tools are exposed piecewise. Creating a process namespace isn't the same thing as creating a virtual network device. You can use cgroups to stop a container all at once, sure, but you can also use them for other useful purposes and the code is the same. Some of these APIs are simple, some less so. But they're tools.
I know, I know, now you're asking "well, why didn't someone just put all the tools together in one box that would do it with one sane UI?!"
They did. It's called Docker.
> They did. It's called Docker.
Yes I see that. But I was hoping more for a toolbox like GNU fileutils, not a toolbox with a billion dollar valuation (which is what Docker is)
What do you see as the primary differences between those two projects, or types of projects?
I think just saying it's a VM is an over simplification
Admittedly jails and pledge(2) seem rather nice to work with compared to Linux's equivalents.
He has spoken out against the modern security industry and security theatre, both of which are distinct from security.
And still nowhere near the flexibility, security, the power and simplicity of illumos zones and SMF.
https://github.com/deislabs/cnab-workshop/blob/master/conten...