Elektrine lite

← Feed

@balsoft@lemmy.ml

Post #4326633

2026-08-01 21:09 UTC

Assuming you’re talking about Nix the package manager, Nothing is actually “installed as root”, except for stuff that the root user installs themselves. The Nix Store (where all the “derivations”/packages are stored) can be thought of more as a cache, just because a package is there doesn’t mean it’s used anywhere. Users don’t get to choose the cache “key” (i.e. the directory name in /nix/store) either - it is determined by all the build instructions and dependencies needed to build the package, and Nix doesn’t (well, at the very least shouldn’t) give users any control about the package build process after it starts. When users install something, Nix fetches or builds that package into /nix/store - which doesn’t affect other users in any way - and then just symlinks that particular package into some user-owned directory in their $PATH (e.g. $HOME/.local/share/nix/profiles/default or so), which also doesn’t affect root or other users in any way. So, basically, if some user installs malware only they are affected - the fact that it’s also in the shared /nix/store is irrelevant since there’s nothing in other user’s profiles or $PATH or whatever that references it in any way. The most likely vulnerability is something like this: The attacker guesses the nix store path of some package that root will use in the future (e.g. glibc from a more up-to-date Nixpkgs version compared to what root currently uses) - note that users can’t replace a derivation that’s already in the store, so they need to guess a future derivation path The attacker forces Nix to build that package from source instead of fetching from a trusted substituter The attacker finds a way to breach Nix’s sandbox during the build and inject their own backdoor into the resulting package ← this is the difficult part, there are currently no such known sandbox holes The attacker then waits until root starts using that package in the store, at which point the backdoor becomes actively ran as root. I must add that this is theoretical and I don’t think has ever happened in practice on a multi-user system. Sorry, I’m pretty bad at explaining stuff, hopefully it makes some sense :)

Replies (1)

  • @ranzispa@mander.xyz 2026-08-02 01:24

    Hello, thank you for the in depth explanation! I am not very familiar with nix, and yes I’m talking about the package manager. I have installed NixOs recently to toy around with it and see whether it could be a good solution to certain problems we have. I have determined that NixOs itself is not mature enough for what we need, but I do see value in the nix package manager that other solutions do not offer. Regarding the 4 points you raise I’m not too worried about hash squatting, I guess there’s no way around it, but other ways of managing packages have way worse flaws than that. I do want my users to be able to build packages. In most cases I imagine we’ll use pre built packages, but often packages available are not optimized for certain architectures. How does the nix sandbox work? Just so I know what I’m working with. Do you know where I can read about it? Does root actively run installed packages at any point? If that is the case I’d be a bit wary to use nix for this purpose.

    Open ##4326632