-
Notifications
You must be signed in to change notification settings - Fork 789
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
Error during unshare(CLONE_NEWUSER): Operation not permitted #1901
Comments
We recommend that people running buildah within a locked down container use images from quay.io. |
It doesn't seem to help at all:
Also it appears to be default isolation as well in the container. |
Could you try this with podman? I think Docker might be blocking the unshare syscall. |
Not sure if this is the case on Ubuntu, but on Debian the kernel itself disables the unsharing: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808915. I had to manually allow unprivileged users to unshare, get Docker to use Podman's seccomp profile, and then Buildah ran in the container. Using |
Don't fully understand what you are saying, Did Buildah work or not work within the container? |
Yes it did (on a Debian host), once I ran: echo 1 > /proc/sys/kernel/unprivileged_userns_clone I'm not sure why this is necessary if Then when using Podman's seccomp profile, Buildah worked in the container: docker run --security-opt seccomp=/usr/share/containers/seccomp.json --rm -it quay.io/buildah/stable |
@giuseppe Why, what do we need this for? I guess we are still bind mounting the /proc and /sys into the chroot. |
yes, we still need to be able to create bind mounts to create the environment used by the |
Thanks, I had figured that out. |
So docker seccomp.json file blocking unshare is the issue, and should be changed, or as I reccoment use podman/CRI-O for running these containers. You can run docker with Podman /usr/share/containers/seccomp.json file. |
Seeing this error in podman on a ppc64le RHEL 7.6 host with a CentOS7 container.
If one starts podman with superpowers, one gets a different error:
|
If you are in a container, then you should use buildah from --isolation=chroot, no reason to use container technology within a container. We do a lot of configuration to make buildah run within a locked down container. https://github.com/containers/buildah/blob/master/contrib/buildahimage/stable/Dockerfile |
Sorry but when building a image from inside a Jenkins container agent it is useful. Since dockerd is deprecated in Kubernetes we need an alternative; Is it possible with Buildah or do we need to find something else ? |
The comment should have been more specific. Basically locking down a process within a container with additional duplicative lock down is not worth it. So if I have dropped caps, and running with SELinux lock down and seccomp rules locked down, then don't attempt to do them again. If the container engines attempt to, they will be blocked, because of the existing container lockdown and your container engine will fail. It is possible to run buildah and podman within a container. The issue is how much security you lock said container down with. Running docker within a container has the same issues. It requires a --priivleged container or a container with a leaked docker.socket from the host into the container, which is arguably less secure then just running --privileged. |
The goal is not to have a docker socket available in a Container but to build a container image inside a CI agent running in K8S |
Sure, but in order to run most containers, you need more then one UID within the container, and a lot of times the process needs some linux capabilities. Podman requires these. (as well as Docker). |
This seems to be the recommended way to run buildah when already inside a container, see containers/buildah#1901 (comment)
This seems to be the recommended way to run buildah when already inside a container, see containers/buildah#1901 (comment)
This seems to be the recommended way to run buildah when already inside a container, see containers/buildah#1901 (comment)
Still encountering this issue on buildah build --isolation=chroot ${CI_PROJECT_DIR}/Dockerfile The container is run inside a Gitlab CI Pipeline |
Same for me |
I think the default seccomp profile blocks |
Dockers/containerd blocks unshare and mount. Podman, Buildah, CRI-O do not. |
CRI-O by default blocks unshare as well. There is need to change the seccomp profile with CRI-O too |
Ok CRI-O Should be using the same seccomp.json file as podman and buildah. |
That was disabled AFAIK because user namespaces open up a lot of new features that can be abused. Many security issues in the kernel in the last years were caused by user namespaces and Docker/containerd were not affected while CRI-O was. Personally I think it makes sense for CRI-O to be more locked up than Podman and allow more kernel features only when strictly necessary |
we actually typically embed the seccomp profile by default inside of the binary, but we also do manually remove unshare from it: https://github.com/cri-o/cri-o/blob/main/internal/config/seccomp/seccomp.go#L45 and this was done for the reasons @giuseppe mentions |
I can hear Eric B, screaming from the hinderlands. How would a user add back unshare to his own seccomp.go file? |
they can either specify a separate profile inside of a pod spec (or |
But docker (or any other purely container tech) is inherently insecure anyway. What's the point? |
what do you mean with that? The point of seccomp for containers is to try to make them safer, as much as possible with the right trade-off between security and what programs would break. If you need a custom profile you can provide that. User namespaces open up a wider kernel attack surface since more kernel features can be used (e.g. mount APIs). So to play safe it is better to disable it by default, at least on a cluster, and allow it only when it is necessary and in a controlled way. IMO this should not be changed for CRI-O and |
I mean that docker is insecure. |
Well there are compromises. Allowing unshare would give more possibilities to the malicious agent, e.g. https://unit42.paloaltonetworks.com/cve-2022-0492-cgroups/ could be avoided with unshare blocked. I am closing the issue since I don't think we should change the default we currently have in CRI-O |
@giuseppe am I right that people need to "unblock unshare" anyway to build containers in containers with I also came here from GitLab, because I saw |
@abitrolly |
@awildturtok thanks for the pointer. Going to try EDIT: https://gitlab.com/abitrolly/gitlab-elasticsearch-indexer/-/jobs/4250152765#L22 |
It seems a bit weird to need unshared to build a multiarch manifest from already built images. AFAIK, there are no users or privileged operations happening. |
Description
I cannot run
buildah bud
Steps to reproduce the issue:
Within the docker container I run the following:
https://github.com/containers/buildah/blob/master/install.md#ubuntu
Describe the results you expected:
I expected everything to work our and build the OCI image.
Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
podman version
if reporting apodman build
issue:not installed
Output of
cat /etc/*release
:Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:(( default one ))
The text was updated successfully, but these errors were encountered: