Is Priviledged LXC behind Proxy server a risk?

JensK

Member
Oct 14, 2022
6
1
23
I have a Proxmox setup with lots of priviledged LXCs. Many of those are acessible from the external net through a proxyserver running in af unpriviledged LXC

The reason for the many priviledged LXCs is that they access data from my NAS via NFS. I run the nas on the same Proxmox server in a VM.

Over time i have become worryed because a breach in a privileged LXC can give access to the Proxmox OS. I am therefore wondering if I should change my setup so LXCs that are exposed to external networsl through nthe proxy should be unpriviledged.

If they should be unpriviledged how do I then share the data that now is shared from the NAS VM?

My setup of machines on my Proxmox:
- VM with PCI sata controller passthrough share out data from 3 x 6Tb disks. Synced via Snapraid. Shares the same data through NFS and SMB – both personal, mailbox and shared datadrives (videos music photos etc.)
- LXC priviledged with Nextcloud personal data from NAS personale drives via NFS mounts
- LXC priviledged with Jellyfin videos drives via NFS from NAS
- LXC priviledged with xxx external service with data mountet from NAS via NFS
- ….
- LXC unpriviledged Proxy server

Users access their personal datadrives either via Nextcloud or via local smb mounts from their workstation.

So if my external LXC based services should be run in unpriviledged LXCs i need to have the shares mountet otherwise than through NFS. At the same time the drives should be shareablke through smb. I also need Snapraid to secure my data

I shall note that my server is a low power Intel N6005 based MB running personal shares, mailserver, video and music streaming all together 3 Vms and 12 LXCs for all 6 members of the family, so everything has to be very ressource efficient.

What is your best advice - is my setup secure behind the proxy or should I restructure everything to unpriviledged LXCs?
If reconstruction is the best - how can i share the same data til the LXCs and to workstations via SMB?
 
  • Like
Reactions: AzharAbbasPK
JensK said:"If they should be unpriviledged how do I then share the data that now is shared from the NAS VM?"you can keep nfs but mount it on the pve host instead of inside the container (Datacenter > Storage > Add > NFS, it ends up under /mnt/pve/<storageid>) and bind mount that into the unprivileged ct with: pct set <ctid> -mp0 /mnt/pve/<storageid>/<folder>,mp=/mnt/data. an unprivileged ct sees host uid/gid shifted by 100000, so make the files readable for that on the nas side (group/other perms or the export squash settings), or add an lxc.idmap entry in /etc/pve/lxc/<ctid>.conf (plus root:uid:1 in /etc/subuid and /etc/subgid) to pass through just the one uid/gid your app uses. one gotcha since the nas is a vm on the same box: give it a lower start order with a startup delay so the nfs mount is up before those containers start.
 
To me, trying to put data into an LXC container is just too much work with privileges etc. I would rather use docker for my containers so that the containers have their own kernel and there is separation between the kernel of the VM and the kernel of the hypervisor.
 
  • Like
Reactions: Johannes S
I was driving earlier so let me expound on my thoughts. The proxy doesn't remove the risk, since it forwards outside requests straight to those apps. In a privileged LXC, root in the container is root on the Proxmox host, so one app vulnerability can put the whole box at risk. Unprivileged LXCs with the host mount and bind mount AzharAbbasPK described are a real improvement, but you take on UID mapping and start-order dependencies. To me (and reasonable people can disagree on this point) I would put any service that needs to access an NFS share (as well as any service exposed to the internet) in Docker in a single VM. A breakout lands in the VM's kernel, not the hypervisor's, and the VM mounts NFS from your NAS directly, so nothing changes on the NAS side. SMB and SnapRAID stay as they are. The overhead is about 1 to 2 GB of RAM, and internal-only services can stay in LXCs.

In my system I only use LXC containers for workloads that are basically stateless and don't need external storage: the Crowdsec security engine, Pi Hole, and the Cloud Flare Tunnel daemon. These are also not exposed to the internet.
 
  • Like
Reactions: Johannes S
Thank you for your answers.

I wil try to redesign my setup like:

The NAS in a VM serving out NFS and SMB with PCI SATA controller passthrough - as today.

Mount the samme NFS shares on the proxmox host.
Do I need to make a NFS mount script that mounts NFS shares after a delay so the NAS VM and sharing out NFS drives has startet?

Migrate the many LXC's to unpriviledged and bind mount the NFS shares from the host to the individual LXC's

This solution with unporiviledged LXC's because i have very limited computing ressources with this little 9W host setup and I think that a couple of docker hosts would cripple the platform.
 
Last edited:
This solution with unporiviledged LXC's because i have very limited computing ressources with this little 9W host setup and I think that a couple of docker hosts would cripple the platform.
Well in that case, I think Proxmox is the wrong solution for you. You may as well just load Debian or Alpine as your main/only OS, install docker and run everything in the one OS and avoid the overhead of a hypervisor. Virtually everything you want to do can be done natively on Linux (snapraid, NFS, SMB, etc.) or through docker containers (proxy, Nextcloud, media server, etc.). You are wasting resources and really not gaining anything by using Proxmox IMHO.
 
  • Like
Reactions: Johannes S