You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building the Dangerzone container image, we use multi-stage builds, where we create the inner container first, and then copy it to the outer container, under /home/dangerzone/dangerzone-image/rootfs:
This was the most clean way to use nested containers, and was implemented during #590. Now that we plan to use Debian Stable for the base image of Dangerzone (see #1046), it would be nice to merge these two container images into one, to avoid the double overhead of the Debian container image.
I have experimented with a way we can achieve this, and the following seem to work:
Remove the /home/dangerzone/dangerzone-image/ dir, and write instead the OCI config to /config.json, i.e., at the root of the container image.
Change the OCI config to use the container root (/) as the image bundle, instead of /home/dangerzone/dangerzone-image/rootfs.
These changes are reflected in the following diff:
--- a/dangerzone/gvisor_wrapper/entrypoint.py+++ b/dangerzone/gvisor_wrapper/entrypoint.py@@ -56,7 +56,7 @@ oci_config: dict[str, typing.Any] = {
{"type": "RLIMIT_NOFILE", "hard": 4096, "soft": 4096},
],
},
- "root": {"path": "rootfs", "readonly": True},+ "root": {"path": "/", "readonly": True},
"hostname": "dangerzone",
"mounts": [
{
@@ -133,7 +142,7 @@ if os.environ.get("RUNSC_DEBUG"):
json.dump(oci_config, sys.stderr, indent=2, sort_keys=True)
# json.dump doesn't print a trailing newline, so print one here:
log("")
-with open("/home/dangerzone/dangerzone-image/config.json", "w") as oci_config_out:+with open("/config.json", "w") as oci_config_out:
json.dump(oci_config, oci_config_out, indent=2, sort_keys=True)
# Run gVisor.
@@ -150,7 +159,7 @@ if os.environ.get("RUNSC_DEBUG"):
runsc_argv += ["--debug=true", "--alsologtostderr=true"]
if os.environ.get("RUNSC_FLAGS"):
runsc_argv += [x for x in shlex.split(os.environ.get("RUNSC_FLAGS", "")) if x]
-runsc_argv += ["run", "--bundle=/home/dangerzone/dangerzone-image", "dangerzone"]+runsc_argv += ["run", "--bundle=/", "dangerzone"]
log(
"Running gVisor with command line: {}", " ".join(shlex.quote(s) for s in runsc_argv)
)
My question is, do we risk something security-wise by doing this? Note that we instruct GVisor to treat the root filesystem as read-only (not that GVisor would write to these files in any case). Also, we mask sensitive system dirs (/proc, /tmp, /dev, sys, /home/dangerzone). There are some extra files that are mounted to the outer container on /etc/ and /run that we can mask, although they don't seem to give any sensitive info:
$ mount
[...]
tmpfs on /run/.containerenv type tmpfs (rw,nosuid,nodev,relatime,size=3258360k,nr_inodes=814590,mode=700,uid=1000,gid=958,inode64)
tmpfs on /etc/hostname type tmpfs (rw,nosuid,nodev,relatime,size=3258360k,nr_inodes=814590,mode=700,uid=1000,gid=958,inode64)
tmpfs on /etc/hosts type tmpfs (rw,nosuid,nodev,relatime,size=3258360k,nr_inodes=814590,mode=700,uid=1000,gid=958,inode64)
[...]
$ cat /etc/hostname
cec0ac615cbe
$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.1.23 host.containers.internal host.docker.internal
127.0.0.1 cec0ac615cbe dangerzone-doc-to-pixels-KwY1lA
$ cat /run/.containerenv
Overall, I'm inclined to go forward with this, but I'd like a second set of 👀 to validate my assumptions.
Remove the need to copy the Dangerzone container image (used by the
inner container) within a wrapper gVisor image (used by the outer
container). Instead, use the root of the container filesystem for both
containers. We can do this safely because we don't mount any secrets to
the container, and because gVisor offers a read-only view of the
underlying filesystem
Fixes#1048
When building the Dangerzone container image, we use multi-stage builds, where we create the inner container first, and then copy it to the outer container, under
/home/dangerzone/dangerzone-image/rootfs
:dangerzone/Dockerfile
Line 94 in 1298e9c
This was the most clean way to use nested containers, and was implemented during #590. Now that we plan to use Debian Stable for the base image of Dangerzone (see #1046), it would be nice to merge these two container images into one, to avoid the double overhead of the Debian container image.
I have experimented with a way we can achieve this, and the following seem to work:
/home/dangerzone/dangerzone-image/
dir, and write instead the OCI config to/config.json
, i.e., at the root of the container image./
) as the image bundle, instead of/home/dangerzone/dangerzone-image/rootfs
.These changes are reflected in the following diff:
My question is, do we risk something security-wise by doing this? Note that we instruct GVisor to treat the root filesystem as read-only (not that GVisor would write to these files in any case). Also, we mask sensitive system dirs (
/proc
,/tmp
,/dev
,sys
,/home/dangerzone
). There are some extra files that are mounted to the outer container on/etc/
and/run
that we can mask, although they don't seem to give any sensitive info:Overall, I'm inclined to go forward with this, but I'd like a second set of 👀 to validate my assumptions.
CCing @EtiennePerot for obvious reasons.
The text was updated successfully, but these errors were encountered: