-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when a substituter is untrusted, give a solution in the warning message #6672
Comments
Just stumbled upon this, very odd user experience. Nix version: 2.10.3 |
Fix for me was to use nix/src/libexpr/flake/config.cc Line 38 in 9d860f3
substituters isn't a valid nix.conf value.
|
Summary: Most "documentation" you can find for nixConfig mentions use of `extra-substituters`, however, this seems to be incorrect. See: NixOS/nix#6672 (comment) This also removes the ``` warning: ignoring untrusted substituter 'https://comm.cachix.org' ``` output that you might see when doing any `nix` command. Test Plan: ``` nix develop # may get prompted about nixConfig values # assert "ignoring untrusted substituter 'https://comm.cachix.org'" doesn't appear ``` Reviewers: atul, varun, abosh, ashoat Reviewed By: atul, ashoat Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D5183
Summary: Most "documentation" you can find for nixConfig mentions use of `extra-substituters`, however, this seems to be incorrect. See: NixOS/nix#6672 (comment) This also removes the ``` warning: ignoring untrusted substituter 'https://comm.cachix.org' ``` output that you might see when doing any `nix` command. Test Plan: ``` nix develop # may get prompted about nixConfig values # assert "ignoring untrusted substituter 'https://comm.cachix.org'" doesn't appear ``` Reviewers: atul, varun, abosh, ashoat Reviewed By: atul, ashoat Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D5183
@jonringer I'm not sure this workaround has the same semantics. It looks like That said, it's not clear to me what the meaning is of an underprivileged user building a flake with custom |
An attempt at enabling the fuellabs nix cache via the flake's `nixConfig` attribute. The idea is to hopefully remove the need for adding cache info to the user's global config and ease usage slightly. From `nix help flake`: > nixConfig: a set of nix.conf options to be set when evaluating any > part of a flake. In the interests of security, only a small set of > whitelisted options (currently bash-prompt, bash-prompt-prefix, > bash-prompt-suffix, and flake-registry) are allowed to be set without > confirmation so long as accept-flake-config is not set in the global > configuration. Currently this doesn't seem to be working - I'm running into the same issue described here NixOS/nix#6672. Either the user has to be part of the "trusted-users" set (i.e. is allowed to specify new substituters) or the fuellabs cache already has to be part of the global `trusted-substituters` list, otherwise the fuellabs cache is ignored.
Summary: Use the legacy way to define an alternative binary cache. This avoids trying to rely on experimental flakeConfig feature which seem to need some time to stabilize, see NixOS/nix#6672 for more details. https://linear.app/comm/issue/ENG-2126 Test Plan: ``` # On a non-NixOS machines (nix.conf is readonly) cat /etc/nix/nix.conf # confirm it's missing "https://comm.cachix.org" as a substituter ./scripts/install_nix.sh # confirm "https://comm.cachix.org" is now a substituter ``` Reviewers: varun, atul Subscribers: ashoat, tomek, abosh Differential Revision: https://phab.comm.dev/D5561
Summary: Use the legacy way to define an alternative binary cache. This avoids trying to rely on experimental flakeConfig feature which seem to need some time to stabilize, see NixOS/nix#6672 for more details. https://linear.app/comm/issue/ENG-2126 Test Plan: ``` # On a non-NixOS machines (nix.conf is readonly) cat /etc/nix/nix.conf # confirm it's missing "https://comm.cachix.org" as a substituter ./scripts/install_nix.sh # confirm "https://comm.cachix.org" is now a substituter ``` Reviewers: varun, atul Reviewed By: atul Subscribers: ashoat, tomek, abosh Differential Revision: https://phab.comm.dev/D5561
Maybe a separate issue, but it seems you cannot successfully set Edit: It seems that this only happens from NixOS and not from some other OS just using the Nix package manager. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/ux-problems-with-flakes-and-custom-caches-substituters/23691/1 |
Random thoughts:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-09-nix-team-meeting-minutes-15/23951/1 |
Discussed in Nix team meeting on 2022-12-19: @rapenne-s: Please make a two-line warning that directs the user to Complete discussion
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-16-nix-team-meeting-minutes-17/24120/1 |
As a provider of nix services to my team, as soon as ^^ These are the true semantics (in the case of having Maybe that implies not recommending daemon mode for some use cases. |
Just add yourself as a trusted user and it works like you want. |
That's what I ended up doing, indeed. Not sure about the Nix-native UX on this topic, at this point. |
trusted-user = root @staff user_name_abc restart daemon maybe. |
For folks who are reading this and unsure how to restart nix-daemon:
Ideally it would auto-recognize config updates: #8939 |
On NixOS instead of editing
|
Caution DO NOT add your user to Add We should not recommend this for everyday use as it is a pretty severe security issue. |
Maybe these persons already have a passwordless sudo anyway, adding their user to trusted-users is just the cherry on the cake |
Regardless, we should not encourage it. |
@brainrake Thanks, I shouldn't have suggested that indeed: fixed my comment. I don't use |
Thanks for this heads up @brainrake!
ooc what's the difference between |
|
both are trusted :/ |
Hmm so are the nix.conf docs out of date? |
No. The name is misleading. |
the docs seem to indicate that they have different semantics but iiuc your comment implies that they do the same thing? |
Both are trusted. But |
Ahh... ok so to confirm my understanding:
Put another way, |
About right, except |
Can I somehow just hide this message? I'm using a flake that advertises a binary cache. But myself I don't use that cache, so I answer "don't use it", and "yes, remember that choice". I don't want to be bother about it anymore, yet on every build I have to see this warnings. |
It doesn't matter; the issue with adding "alternate s3cr3t root access" methods is that now anybody who wants to audit or change that needs to look in two different places. (Adding users to the |
First time Nix user here, and I didn't find the new warning message sufficient. In particular, I didn't see any mention in the More context, I assume this is a typical experience: I've never used Nix before, and just joined a new project that uses Nix. The project README tells me I need to run |
Why is this so? It doesn't seem reasonable, something that looks like a Nix-specific config should not have such a massive security side-effect. |
Since nobody's bothered to answer the above, I'll give it a try. I don't know the exact details here, but the issue is most likely that you're trusting all your subtituters to provide packages built to exactly the formula of each package, without you having any good way to verify that yourself (except to compare it with your own build, but doing that would make substituters pointless). That means you're trusting them not to provide a substitution that includes malicious code that might be run by root, or even malicious suid binaries. This general problem is not Nix-specific; it's the nature of downloading from the Internet binaries that someone else has built. |
Sure, but I don't see how that's relevant to making your user sudo without password as a side-effect. The trust issue applies to any configuration manager. When I run But since security isn't perfect, I don't run anything as root unless I have good reason to. If anything, trust should be a reason against liberally relaxing root privileges. Maybe I misunderstood your point, but this reasoning sounds like "if anything bad happens, we'll make sure it's as bad as it can possibly be". |
Just to be clear, by this I assume you mean, "can gain root access," not literally "sudo without password."
This same trust issue does not apply to Pip in this way, for two reasons.
Adding a different trusted-substituters for Nix, especially when it's running in the usual configuration of installing as root rather than as the user, is the same kind of thing as using
So you always install and run Nix in single-user mode? If that's the case, you're protected against such attacks. But then you also, IIRC, don't have a problem changing trusted-substituters without root access. But many people run Nix in daemon mode, and these people are taking actions as root when they install packages using Nix. And thus, correctly, they should not be able to get binary packages from arbitrary sources to be installed as root (and potentially run as root) without having root access themselves to say that the substituter is trusted. |
@agubelu To (partially) answer your question: A trusted user can craft and inject storepaths at their will, this way they could provide something that a NixOS would potentially link in a security-wrapper assuming it was a legit This attack is rather unlikely, and a certain config has to be targetted with it. @viperML once went through the process and attacked his own machine that way and succeeded. I thought he wrote a blog post about it, though I can not find it in his personal blog. As a sidenote: from what I understand, this attack is only relevant against NixOS and maybe nix-darwin, due to the security wrappers. |
@NobbZ the more concerning attack is local privilege escalation. Anyone in
or even
In addition, The attack works on any system running |
@agubelu @0cjs the reason is history. |
Describe the bug
When running a flakes program through
nix run
that is providing a substituter, the warnings messages in the current code are not really helpful.Steps To Reproduce
nix run github:tweag/nickel -- --help
y
to the multiple questions about a substituterwarning: ignoring untrusted substituter 'https://nickel.cachix.org'
Because you accept all the questions about trust, it's confusing to see the substituter is ignored because it is untrusted.
Expected behavior
I think the last warning message should add a solution:
[...], if you want to use this substituter, either add your user to the trusted-users list, or add the substituter to the trusted-substituters list in your Nix configuration.
nix-env --version
output : nix-env (Nix) 2.9.1Additional context
My user is not a trusted user and the substituter wasn't listed in the trusted-substituters. Setting one is enough to have the cache enabled.
The text was updated successfully, but these errors were encountered: