Closed flx42 closed 7 years ago
Hi @flx42 , thanks for the report. We are aware that this is currently the case, and we are currently investigating the proper way to handle importing as non-root. We should have the same or a greater level of non-root import functionality back in the code some time soon, but we want to make sure that we eliminate all security concerns before introducing any more non-root functionality.
Also, is the debug output from master or from that specific git commit. If it's from that commit, please re run this from master and show me what you see. Thanks.
With 1a83f9ceb8159155b089585765568ad4674afc80:
$ singularity -vvvv import ubuntu docker://ubuntu
increasing verbosity level (5)
ending argument loop
Exec'ing: /usr/local/libexec/singularity/cli/import.exec ubuntuVERBOSE [U=1000,P=13688] message.c:52:message_init() : Set messagelevel to: 5
DEBUG [U=1000,P=13688] privilege.c:66:singularity_priv_init() : Called singularity_priv_init(void)
DEBUG [U=1000,P=13688] privilege.c:131:singularity_priv_init() : Returning singularity_priv_init(void)
DEBUG [U=1000,P=13688] simage.c:55:main() : Running /usr/local/libexec/singularity/simage mount workflow
DEBUG [U=1000,P=13688] privilege.c:152:singularity_priv_escalate(): Temporarily escalating privileges (U=1000)
ERROR [U=1000,P=13688] privilege.c:155:singularity_priv_escalate(): The feature you are requesting requires privilege you do not have
ABORT [U=1000,P=13688] privilege.c:156:singularity_priv_escalate(): Retval = 255
Just curious, does it work when not using docker? If it does, could you try exporting SINGULARITY_CACHEDIR (or whatever argument goes into the command or config to specify cache) to something definitely owned by your user?
It's maybe not that, but just want to be extra sure since we added a bunch of new stuffs recently!
@vsoch The reason it doesn't work right now is because in simage.c we call singularity_priv_escalate()
before anything else. Since simage binary doesn't have SUID, this has the effect of checking for root. When you call singularity_priv_escalate()
without SUID or when running as a regular user, it will abort due to it being unable to escalate. We could theoretically remove/move these lines in #322 , to enable certain workflows to attempt to run without root.
Ah ok cool! Thanks for the details, I'll keep watching!
@bauerm97 is right about why it is not working now. I am considering removing that bit from simage.c because the idea of bootstrap'ing with SUID just opens us up to too many potential security risks (users manipulating the shell or python environment to run arbitrary code as root).
+1
Import is no longer allowed for directories, but this feature works for images in the development branch. Closing issue. Comment if it needs to be reopened. Thanks!
It doesn't seem to work on 5f5e3bc92f3d0aba07c060089585d4bb27da4cef (development branch) with the following:
$ ./configure --disable-suid && make && sudo make install
$ singularity create -F trusty.img
Initializing Singularity image subsystem
Opening image file: trusty.img
Creating 768MiB image
Binding image to loop
ERROR : The feature you are requesting requires privilege you do not have
ABORT : Retval = 255
Without --disable-suid
, it works, but probably because this path is broken (see #569):
$ ./configure && make && sudo make install
$ singularity create -F trusty.img
Initializing Singularity image subsystem
Opening image file: trusty.img
Creating 768MiB image
Binding image to loop
Creating file system within image
Image is done: trusty.img
$ SINGULARITY_NOSUID=1 singularity create -F trusty.img
Initializing Singularity image subsystem
Opening image file: trusty.img
Creating 768MiB image
Binding image to loop
ERROR : The feature you are requesting requires privilege you do not have
ABORT : Retval = 255
To create a new container, it does require privileges, and it uses SUID for that which is why you are seeing this error. There is no workaround, aside from calling with sudo and allowing SUID.
Considering you need SUID in order to use Singularity images anyway, you may as well either use the SUID process flow or don't use images (just run a shell (or other action) on a docker URI):
$ singularity shell docker://centos
Ok, so this isn't supported for images, I didn't understand that from your previous comment. fine for me.
The bug in https://github.com/singularityware/singularity/issues/569 probably gave the illusion that it worked ;)
Yeah, exactly! The user namespace doesn't provide the means to deal with loop images, so if it worked, it was because there was some SUID code doing it's job.
Why not just use the SUID code? Honestly, the user namespace is flakey at best due to the fact that it is not ubiquitous or equally implemented across different distributions. Maybe one day it will become more standardized, but for now, all I hear from large production sites is that it is an unstable headache.
On CentOS, don't even try, user namespaces are a preview feature and therefore largely unusable.
On other distros (like ubuntu 16.04), it works fine, and if you remap the UID you are root in the container, which allow you to do more things without being "real" root from the outside. From a security standpoint, we prefer to rely on user namespaces instead of SUID binaries, no offense ;)
I understand that it's not possible to create a Singularity image without privileges, and that doing a singularity import
on a folder with SUID creates many security issues and that's why you removed this feature (right? or was there other reasons?).
But in a full non-SUID setting (--disable-suid
), folder import should work without any security concern.
Ubuntu and Debian's implementation of user namespaces are not even equal though! I stopped putting conditionals in, so Singularity mostly works with user namespace on Ubuntu (as long as you don't use images), but not always on Debian. It is quite frustrating... Luckily, almost no big HPC centers use Debian or Ubuntu. I don't mean to alienate any of the *.deb-heads out there, but I did a check on the top500, your DGX was the only one!
The problem is that the user namespaces, even as Ubuntu implemented it, isn't quite enough for all of the HPC features most centers rely on. While, I would also prefer to discard the security baggage of SUID, it just isn't possible in the production world. :(
Yes, you are 100% correct about doing the import on a folder with SUID, and thus it is disabled.
You are also right about import "should" work without any security concern, but... import is an image specific function. Plus, I have an OCD about writing files to the file system that have incorrect permissions (and if splatting them out as a user, every file is wrong).
Plus, I have an OCD about writing files to the file system that have incorrect permissions (and if splatting them out as a user, every file is wrong).
That's what docker shell docker://image
is already doing :), but by caching layers to $HOME/.singularity
, and extracting them to /tmp/.singularity-runtime.XXXXXXXX/
. This path also works for us, but it's slower since you pay the extraction cost at every container start (and we have large images).
Now the only option is to docker export
to a folder, then singularity shell ~/myrootfs/
Yep, but by definition it is not persistent. It is the persistency of wrong permissions that makes it intolerable to me! But ... with that said, @vsoch and I have been discussing a pull
sub command that might do exactly what you are thinking. :)
I don't know if you are already aware of this.
The following used to work as non-root and
setuid=no
It no longer works:
git bisect: