Homebrew's security model on Linux and a prototype of an alternative setup #6892
Replies: 1 comment 1 reply
-
|
Thanks, and nice work prototyping this. Worth noting we shipped a default Linux build sandbox in Homebrew 6.0.0 today ( The part of your approach that's still distinctive is the bit you flagged yourself: systemd service sandboxing doesn't depend on unprivileged userns, which is exactly where The ownership/multi-user side can't go upstream regardless. Multi-user is explicitly Unsupported (https://docs.brew.sh/Support-Tiers), by policy not oversight, and brew-proxy is a wrapper, which is the right home for it. nix-homebrew sits at Tier 3 for the same reason. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been thinking about Homebrew's security model on Linux; I have an idea (with a working prototype) of an alternative model, and I'd love to get feedback and see if there's interest in incorporating any of it (concept and/or implementation) into Homebrew.
Currently, the Homebrew installation at
/home/linuxbrew/.linuxbrewis owned and exclusively writable by the user who installs it. Homebrew build/install scripts can, in principle, run arbitrary code; recent developments with Linux sandboxing are great, but sandboxing is a hard problem in general, and it's currently not all that strict of a sandbox (for example, it doesn't look like it has a very restrictive seccomp filter). And in the opposite direction, any unsandboxed process run by the same user can modify the Homebrew installation, same as that user's other files. (Contrast with packages installed by a typical Linux package manger like dnf, apt, pacman, etc., where root access is required to modify installed packages.)My idea is to instead have the Homebrew installation owned by a dedicated
linuxbrewsystem user, in combination with a DBus service that allows any authorized user to requestbrewcommands be run. I've implemented this here. For comparison, with this setup:/home/linuxbrew/.linuxbrewis owned by and exclusively writable by thelinuxbrewuser, and readable by all users.brewcommands to be run aslinuxbrewvia abrew-proxyexecutable, which communicates over the DBus system bus with a daemon run bylinuxbrew; command output is transparently relayed back to the user. Authorization is managed by Polkit, and Polkit policy determines which users have to authenticate for which commands.brew installand similar commands from having access to users' home directories. Additionally, the daemon runs with systemd sandboxing options, which can provide a seccomp filter, restrict access to various system resources and interfaces, and so on, similar to what bwrap can do but not requiring the system to allow unprivileged user namespace creation (since the sandbox is set up by the system service manager).This seems to me to be a substantial security improvement, plus it's compatible with multi-user setups. However, it does have limitations/downsides: while the core brew functionality (e.g. installing, uninstalling, and updating packages) works smoothly, some other functionality runs into problems. (For example,
brew bundledoesn't work with this yet, though I have an idea and am working on it. It also doesn't support brew developer commands yet.)If there's interest, I'd certainly rather work with the Homebrew developers on this idea to have something along these lines upstreamed. Thoughts/feedback?
Beta Was this translation helpful? Give feedback.
All reactions