顯示具有 lxc 標籤的文章。 顯示所有文章
顯示具有 lxc 標籤的文章。 顯示所有文章

2018年7月7日 星期六

Security concerns of LXC containers

Security Considerations

Containers use the same kernel as the host, so there is a big attack surface for malicious users. You should consider this fact if you provide containers to totally untrusted people. In general, fully virtualized VMs provide better isolation.
The good news is that LXC uses many kernel security features like AppArmor, CGroups and PID and user namespaces, which makes containers usage quite secure.
REF: https://pve.proxmox.com/wiki/Linux_Container

Unprivileged LXC containers

These kind of containers use a new kernel feature called user namespaces. All of the UIDs (user id) and GIDs (group id) are mapped to a different number range than on the host machine, usually root (uid 0) became uid 100000, 1 will be 100001 and so on. This means that most security issues (container escape, resource abuse, …) in those containers will affect a random unprivileged user, even if the container itself would do it as root user, and so would be a generic kernel security bug rather than an LXC issue. The LXC team thinks unprivileged containers are safe by design.
REF: https://pve.proxmox.com/wiki/Unprivileged_LXC_containers

2017年8月13日 星期日

Unprivileged container mapping

REF: https://pve.proxmox.com/wiki/Unprivileged_LXC_containers

Let's see an example, we want to make uid 1005 accessible in an unprivileged container.
First, we have to change the container UID mapping in the file /etc/pve/lxc/1234.conf:
# uid map: from uid 0 map 1005 uids (in the ct) to the range starting 100000 (on the host), so 0..1004 (ct) → 100000..101004 (host)
lxc.id_map = u 0 100000 1005
lxc.id_map = g 0 100000 1005
# we map 1 uid starting from uid 1005 onto 1005, so 1005 → 1005
lxc.id_map = u 1005 1005 1
lxc.id_map = g 1005 1005 1
# we map the rest of 65535 from 1006 upto 101006, so 1006..65535 → 101006..165535
lxc.id_map = u 1006 101006 64530
lxc.id_map = g 1006 101006 64530
Then we have to allow lxc to actually do the mapping on the host. Since lxc creates the CT using root, we have to allow root to use these uids in the container.
First the file /etc/subuid (we allow 1 piece of uid starting from 1005):
root:1005:1
then /etc/subgid:
root:1005:1

You can start or restart the container here, it should start and see /shared mapped from the host directory /mnt/bindmounts/shared, all uids will be mapped to 65534:65534 except 1005, which would be seen (and written) as 1005:1005.

2017年8月7日 星期一

Linux Container Security

LXC containers can be of two kinds:
  • Privileged containers
  • Unprivileged containers
The former can be thought as old-style containers, they're not safe at all and should only be used
in environments where unprivileged containers aren't available and where you would trust
your container's user with root access to the host.
The latter has been introduced back in LXC 1.0 (February 2014) and requires a reasonably recent
kernel (3.13 or higher). The upside being that we do consider those containers to be root-safe and so,
as long as you keep on top of kernel security issues, those containers are safe.
As privileged containers are considered unsafe, we typically will not consider new container escape
exploits to be security issues worthy of a CVE and quick fix. We will however try to mitigate those
issues so that accidental damage to the host is prevented.
REF: https://linuxcontainers.org/lxc/security/

2017年7月15日 星期六

Proxmox: PTY allocation request failed

...edit /etc/rc.sysinit and look for this line: /sbin/start_udev
Remove that line and restart the container and you might be good to go!
...This does work but as soon as you run yum if it updates any networking it puts it back in guys: /sbin/start_udev

REF: https://forum.proxmox.com/threads/pty-issue-with-ve-4-containers-converted-from-3.23485/

2017年3月22日 星期三

docker issue when nested

Docker may encounter issues when running inside other container such as LXC. It's better to use full virtualization such as KVM instead.

REF: http://stackoverflow.com/questions/22085657/can-docker-run-inside-a-linux-container

2016年3月26日 星期六

VM / Compute instances backup / restore

雖說VM可以自在遷移,但根本上還是依賴於實體CPU與儲存空間,本體instance還是得生存於storage上啊。除了以regular cycling的方式勤奮migration或backup來避免single point failure之外,還有更有效率的辦法嗎?縮短downtime時間是最簡單的第一步吧。

  • Compute-only. 無論KVM全虛擬或是LXC容器,只要沒存太多資料,instance不大,搬移backup都很快。
  • Storage dependent. 目前想到的就是分離storage componet,獨立出Compute,就可以單獨把Compute SOP了。接下來就是用哪種SDS來保障Storage availability.