-
Notifications
You must be signed in to change notification settings - Fork 163
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
Inconsistent "permissions denied" using secrets in nix systemd-nspawn containers #697
Comments
I am wondering if it wasn't easier to have one age key that gets shared across containers. Than you can just have normal sops-nix running inside each container instead of having to write all this boiler code. |
Have you inspect the permissions of
Do look like in the container? Does this user have a fixed uid in the first place? Maybe it's null and gets not defined by nix but at runtime instead. |
It appears as though some specific nixos services have hardcoded ids. This explains why nginx is the only service I've tried that's been able to access its secrets. It looks like the user or uid doesn't exist when sops checks that variable. Files in I tried setting Is there a better way of setting a static uid that I'm missing? Could I just assign the id to 998 or is this value dynamic? Thanks for the help |
I'm tempted to get my partially working solution to work but if it turns out to be a dead end I think this is the best option.
I think this is a working version of injecting secrets through systemd. I'm not familiar enough with this method to understand the security implications but it also seems quite promising. |
There should be no issues with security. Systemd will load secrets into a tmpfs that never gets swapped and is only ever visible to the service - so it won't put data into unencrypted storage. |
I think there is little we can do if a user doesn't have uids that are visible from the nix on the host. Please use one of the other workarounds mentioned or assign fixed uids. |
I've been trying to use sops-nix to protect secrets used in containers. Unfortunately, I've run into an issue where they work in my nginx container but not the nextcloud example.
I added each key to its container using the method from these merged changes. I also mounted each key on the container to allow them access to the file.
Here's a nix file I import in my configuration.nix containing all relevant expressions:
When I build and run the containers, while both succeed in running, only the nginx container can access its secrets.
To test, I enter a container with:
sudo nixos-container root-login reverseproxy
Inside the container I run:
sudo -H -u nginx bash -c 'cat /run/secrets/reverseproxy/pub'
Output:
However, when I run the corresponding commands on the nextcloud container, I get permisssion denied:
sudo nixos-container root-login nextcloud
sudo -H -u nextcloud bash -c 'cat /run/secrets/adminpass'
Output:
The nginx secrets are ssl certificates while the nextcloud is a plaintext password.
I've seen alternative methods for this where you add files via
environment.etc.<filename>
but it seems like this might not leverage of some of sops-nix's security features. Let me know if this an incorrect assumption since I'm otherwise fine with this as a solution.Thanks for any help!
The text was updated successfully, but these errors were encountered: