mirror of
https://github.com/hwdsl2/docker-ipsec-vpn-server.git
synced 2026-04-26 01:55:53 +03:00
[GH-ISSUE #21] Running "--privileged" is a security risk #21
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @t3chn0m4g3 on GitHub (Mar 4, 2017).
Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/21
Just stumbled over this repo and noticed the active
--privilegedflag for the container.Instead I'd recommend using
--cap-add=NET_ADMIN --net=host, which leaves the host less exposed.@hwdsl2 commented on GitHub (Mar 4, 2017):
@t3chn0m4g3 Hello! First, thanks for the report. Unfortunately this docker image will not work with just
--cap-add=NET_ADMIN, I have tried that before. In addition, because this image modifies IPTables rules, using--net=hostcould affect the rules on the host, which is more complicated and may cause issues.On the other hand, as you can review the Dockerfile and source code, this docker image contains only trusted software (Libreswan, xl2tpd and dependencies). In addition, I have already set options in Docker Hub to automatically rebuild the image each time the Debian base image is updated with security patches.
@t3chn0m4g3 commented on GitHub (Mar 4, 2017):
@hwdsl2 Thanks for the swift response :bowtie:
While running the container in
privilegedmode it is my understanding thatnet=hostand all capabilities are already included by this flag (Runtime privilege and Linux capabilities).Of course, you are right, using the latest software within the container will help prevent security issues, however if the container or the docker host is not updated regularly this might still pose a risk.
@hwdsl2 commented on GitHub (Mar 4, 2017):
@t3chn0m4g3 The
--privilegedmode does not include--net=host, which is a separate setting [1].[1] https://docs.docker.com/engine/userguide/networking/
@t3chn0m4g3 commented on GitHub (Mar 4, 2017):
@hwdsl2 Confirmed for
--net=host. Thanks for the clarification!However, exchanged
--privilegedfor--cap-add=NET_ADMINand everything was working just fine:Maybe give it a retry 😄
@hwdsl2 commented on GitHub (Mar 4, 2017):
@t3chn0m4g3 Thanks for the update. You accidentally posted the generated VPN login details. Please remove the container.
As you can see from the output:
sysctl: setting key ... Read-only file system. Without--privilegedit is not possible to set options such asnet.ipv4.ip_forward, and others. Therefore the VPN won't be able to forward traffic correctly.@t3chn0m4g3 commented on GitHub (Mar 4, 2017):
@hwdsl2 Was no accident (container was destroyed before post), but thanks for noticing!
While you were noticing that you might interfere with iptables rules the
sysctlsettings you perform inside the container remain active on the host as well and might complicate things for users as well, especially if not expecting that suddenly IP forwarding is enabled. Which is why I'd still recommend a solution without--privileged.@t3chn0m4g3 commented on GitHub (Mar 4, 2017):
@hwdsl2 Anyways, nice discussion 😃
@hwdsl2 commented on GitHub (Mar 4, 2017):
@t3chn0m4g3 Thanks for the update. As far as I know, when you install and run Docker it already enables IP forwarding on your server, so that the containers will have access to the network.
@cancan101 commented on GitHub (Apr 9, 2018):
What was the conclusion on
--privilegedvs--cap-add=NET_ADMIN, etc?@Chuckame commented on GitHub (Feb 1, 2020):
Hi, same problem for me, but just
--cap-add=NET_ADMINis not enough for me, and getting allread-only file system.OS: debian 9
Docker: 18.09.6
@hwdsl2 commented on GitHub (Feb 2, 2020):
Aside from the
read-only file systemerrors which are mostly harmless, using--cap-add=NET_ADMINdoes not work for IPsec/L2TP mode (the connection will fail), although it may work for IPsec/XAuth mode. Therefore--privilegedis required for this Docker image to work as intended.