void-linux / xbps

The X Binary Package System (XBPS)
https://voidlinux.org/xbps/
Other
821 stars 124 forks source link

Use a different user for downloading and verifying packages / repodata #292

Open ericonr opened 4 years ago

ericonr commented 4 years ago

I talked about this quickly with @maldridge on #xbps. It's what the title says, and I would be interested in implementing it. The idea is to isolate the part that deals with the outside world and not have it run as root. We could even come to have an AppArmor profile for it (this for the far future, though).

It would only support changing the user if it was running as root. Methods for changing user:

Architecture:

I'm throwing these ideas here so I can try to come up with a sound(er) first implementation, and with mechanisms agreed upon by everyone.

ericonr commented 4 years ago
      duncaen │ one issue with splitting out is that there are other codepaths in xbps-query that use libfetch
      duncaen │ and you need some kind of IPC or something I guess to keep keepalive working and also keep /var/cache/xbps only root writable
      duncaen │ so xbps would pass a open fd and a url for each package to download to a xbps-fetch process
kevlar700 commented 3 months ago

The usual practice is setreseuid and using a Unix socket. You may not even need a file descriptor though that is the usual way of doing it. The other option may be to use a secure language like Ada, Rust with no unsafe or Go without C as the downloader or exec an existing downloader with this privilege dropping functionality or ran as a restricted user.