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
{{ message }}
Repository navigation
Bind-mounted files in /etc allow for resource depletion #13152
The file /etc/resolv.conf, /etc/hostname, and /etc/hosts are mounted read-write into containers. A malicious user can make these files as large as the filesystem allows and deplete the storage resource of the host. The following patch attempts to resolve the issue by introducing a new command line option --etc-inside.
Closing as this is not really a bug.
A user can create huge files anywhere in the container FS and it will fill up the host's disk.
Additionally you can create your container with --read-only (though mounted in files may still be mounted rw in 1.6, pretty sure this is fixed at least on master).
"[dm.baseize] Specifies the size to use when creating the base device, which limits the size of images and containers. The default value is 10G. Note, thin devices are inherently "sparse", so a 10G device which is mostly empty doesn't use 10 GB of space on the pool. However, the filesystem will use more space for the empty case the larger the device is."
You can maybe close this bug, but I would still suggest that a command line option should be introduced that has docker writing the 3 files in /etc into the container. For a multi-tenant environment it seems necessary to restrict access to the host's filesystem and not let quotas be circumvented.
--read-only IMO causes a lot of problems since /var then would have to be moved and updates (yum update, apt-get ) to existing programs do not work so easily.
I suggest --read-only could be more fine, the user can specify which file to be mount as read-only.
For example --read-only:/etc/hosts will only mount /etc/hosts as read-only and --read-only:all will mount the whole filesystem as read-only.
At this situation the user can mount hostshostnameresolv.conf as read-only and others are read-write
It depends on the environment where --read-only can be applied. If a user doesn't have control over the parameters passed to the docker for running the container, since for example the container is used in a multi-tenant cloud, he cannot do that. Yet, the user may want to have control over the contents of these files and therefore. having them inside the container in r/w mode seems necessary. A cloud provider could provide the --read-only:/etc/hosts but would take away control over the file from the user.
@cpuguy83 The difference between these files and the container's filesystem are that the filesystem is different. With devicemapper for instance, files into the container's FS might be writing into an ext4 filesystem created just for that container, but writing to /etc/hosts will write into the /var/lib/docker/containers directory of the host, no matter the selected graph driver.
@coolljt0725 I think that's a legitimate suggestion.
@stefanberger I think considerations specific to multi-tenant are out of scope. A cloud provider in that case should have a customized AppArmor or SELinux policy protecting these files.
@ewindisch : You take away any control from users if you restrict access to the files. Users cannot update /etc/hosts anymore to add new hosts to the lookup list etc.
@ewindisch : Here's now a solution that lets the user provide the three network files using the -v option while preventing the docker daemon from mounting the files it created over them, which was hiding the user-provided files.
@stefanberger I'm happy with allowing '-v' for those files, overriding the mounts for these files. At a glance, I still have some questions about that patch and I'm not sure it's as clean as I'd like it... but that can be sorted out if you make a PR.
@coolljt0725, I have a PR in review which defaults these files to read-only when the container is such. Please feel free to offer a patch if you'd like to set more granular r/o masks: #13669
@stefanberger also, I do not propose we do not allow users to modify these files at all. I do think they should be read-only if the container is set as such. My patch does this. Your patch would allow overriding this for read-only containers, by passing in a read/write volume, so I think they would be complementary.
Activity
cpuguy83 commentedon May 12, 2015
Closing as this is not really a bug.
A user can create huge files anywhere in the container FS and it will fill up the host's disk.
Additionally you can create your container with
--read-only(though mounted in files may still be mounted rw in 1.6, pretty sure this is fixed at least on master).stefanberger commentedon May 12, 2015
A container FS can have size limitations installed, limiting it to 2G for example. R/W access to these files circumvents these quotas.
Check out dm.basesize at https://docs.docker.com/reference/commandline/cli/
"[dm.baseize] Specifies the size to use when creating the base device, which limits the size of images and containers. The default value is 10G. Note, thin devices are inherently "sparse", so a 10G device which is mostly empty doesn't use 10 GB of space on the pool. However, the filesystem will use more space for the empty case the larger the device is."
You can maybe close this bug, but I would still suggest that a command line option should be introduced that has docker writing the 3 files in /etc into the container. For a multi-tenant environment it seems necessary to restrict access to the host's filesystem and not let quotas be circumvented.
--read-only IMO causes a lot of problems since /var then would have to be moved and updates (yum update, apt-get ) to existing programs do not work so easily.
cpuguy83 commentedon May 12, 2015
That's a good point. I'll re-open.
Though I would not consider DM's container size settings to be any real quota.
stefanberger commentedon May 13, 2015
How can we move this forward?
coolljt0725 commentedon May 15, 2015
I suggest
--read-onlycould be more fine, the user can specify which file to be mount as read-only.For example
--read-only:/etc/hostswill only mount/etc/hostsas read-only and--read-only:allwill mount the whole filesystem as read-only.At this situation the user can mount
hostshostnameresolv.confas read-only and others are read-writestefanberger commentedon May 15, 2015
It depends on the environment where --read-only can be applied. If a user doesn't have control over the parameters passed to the docker for running the container, since for example the container is used in a multi-tenant cloud, he cannot do that. Yet, the user may want to have control over the contents of these files and therefore. having them inside the container in r/w mode seems necessary. A cloud provider could provide the --read-only:/etc/hosts but would take away control over the file from the user.
duglin commentedon May 18, 2015
@ewindisch any thoughts on this one?
ewindisch commentedon May 19, 2015
@cpuguy83 The difference between these files and the container's filesystem are that the filesystem is different. With devicemapper for instance, files into the container's FS might be writing into an ext4 filesystem created just for that container, but writing to /etc/hosts will write into the /var/lib/docker/containers directory of the host, no matter the selected graph driver.
@coolljt0725 I think that's a legitimate suggestion.
@stefanberger I think considerations specific to multi-tenant are out of scope. A cloud provider in that case should have a customized AppArmor or SELinux policy protecting these files.
stefanberger commentedon Jun 1, 2015
@ewindisch : You take away any control from users if you restrict access to the files. Users cannot update /etc/hosts anymore to add new hosts to the lookup list etc.
stefanberger commentedon Jul 5, 2015
@ewindisch : Here's now a solution that lets the user provide the three network files using the -v option while preventing the docker daemon from mounting the files it created over them, which was hiding the user-provided files.
https://github.com/stefanberger/docker/commit/7ca899a16bc68091638d89ea109e1172c7fc69f6.patch
stefanberger commentedon Jul 10, 2015
@ewindisch : Do you have any comments to the above referenced patch?
ewindisch commentedon Jul 10, 2015
@stefanberger I'm happy with allowing '-v' for those files, overriding the mounts for these files. At a glance, I still have some questions about that patch and I'm not sure it's as clean as I'd like it... but that can be sorted out if you make a PR.
@coolljt0725, I have a PR in review which defaults these files to read-only when the container is such. Please feel free to offer a patch if you'd like to set more granular r/o masks: #13669
ewindisch commentedon Jul 10, 2015
@stefanberger also, I do not propose we do not allow users to modify these files at all. I do think they should be read-only if the container is set as such. My patch does this. Your patch would allow overriding this for read-only containers, by passing in a read/write volume, so I think they would be complementary.
thaJeztah commentedon Jul 26, 2015
closing because #14613 was merged. Thanks @stefanberger !