Skip to content
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

GitLab (and few others) use nix store to keep passwords #18881

Closed
spinus opened this issue Sep 23, 2016 · 17 comments
Closed

GitLab (and few others) use nix store to keep passwords #18881

spinus opened this issue Sep 23, 2016 · 17 comments

Comments

@spinus
Copy link
Member

spinus commented Sep 23, 2016

Issue description

As far as I understand, all of those settings

secrets.db = mkOption {
end up in nix store.

Steps to reproduce

  1. Enable gitlab service in /etc/nixos/configuration.nix (services.gitlab.enable=true)
  2. Fill missing values to keep gitlab happy
    services.gitlab.databasePassword = "qqq";
    services.gitlab.secrets.secret ="Xxx";
    services.gitlab.secrets.otp ="Xxx";
    services.gitlab.secrets.db ="Xxx";

  1. cry

Should we have clear way to handle that?
Personally for own services I use paths to files with secrets (deployed usually with nixops, so it integrates nicely).

Should choose some clear way to define secrets like that and update the docs?

Technical details

  • System: since 2014
  • Nix version: not relevant
  • Nixpkgs version: since 2014
@knedlsepp
Copy link
Member

You might want to read through this: NixOS/nix#8

@spinus
Copy link
Member Author

spinus commented Sep 23, 2016

@knedlsepp I know this, but it has 4 years, and it can take another while before this will be implemented. I'm interested more about doing something now.
Using password/secret files could be that simple temporary solution.

@Jookia
Copy link
Contributor

Jookia commented Sep 24, 2016

I use paths to secrets at the moment, which works for containers too. Interestingly, there's no way to add files to the initramfs without putting it in store. Perhaps a topic for another issue, but a hook to copy stuff in to an initramfs when installing the bootloader seems like a good idea.

@jokogr
Copy link
Contributor

jokogr commented Oct 6, 2016

@spinus and @Jookia could you make an example of password / secret files for this particular case?

@spinus
Copy link
Member Author

spinus commented Oct 11, 2016

@arianvp
Copy link
Member

arianvp commented Jan 26, 2017

I am working on a patch to fix this for gitlab. I use nixops to deploy https://arianvp.me/ and because I think it's good for people as a learning resource, the entire thing is out in the open on github http://github.com/arianvp/arianvp.me

I use nixops secret management to provision secrets, as can seen here: https://github.com/arianvp/arianvp.me/blob/master/arianvp.me/services/nginx.nix#L15

However, currently gitlab module does not support reading secrets from file, but only from the nix expressions. Of course, all my nix expressions are open source, and I should not store secrets in git.

So I'm working on a patch that makes it possible to just specify the location of gitlabs secrets.yml instead of letting this be built into the nix store as I think this is a bad design choice.

@arianvp
Copy link
Member

arianvp commented Jan 26, 2017

This is a breaking change though, as it would break existing gitlab installs. Howabouts would I communicate that clearly?

@spinus
Copy link
Member Author

spinus commented Jan 26, 2017

@arianvp there is a function in nix which inform people about deprecated stuff. I'm not sure if there are any rules for nixos to keep compatibility between versions.

Less intrusive way of doing that would be to support two ways for one release and show deprecation message to people using function I mentioned (IMHO, probably someone from the core team could comment how to do that better).

@spinus spinus closed this as completed Jan 26, 2017
@spinus spinus reopened this Jan 26, 2017
@fpletz
Copy link
Member

fpletz commented Jan 26, 2017

@arianvp Looks interesting. Ping me if you need help.

@mguentner
Copy link
Contributor

More rather interesting modules that leak a lot of information to the 0444/0555 /nix/store 🙈 🙉 🙊

@joachifm
Copy link
Contributor

joachifm commented Feb 13, 2017

@mguentner cjdns is actually an example of a service that does not leak lots of secrets into the store ... it could easily be extended to also read the list of authorized password hashes at run-time as well, if reversing them was considered trivial (if you can demonstrate that, please file a bug).

(EDIT: I certainly hope they are hashes, at any rate, if not that'd be kind of awful ...)
(EDIT2: I was wrong, sorry)

@ghost
Copy link

ghost commented Feb 13, 2017 via email

@joachifm
Copy link
Contributor

@tohl I had assumed they were ... obviously I was wrong :)

@mguentner
Copy link
Contributor

NixOS is great but the filesystem design is inherently flawed. It completely undermines any security gained by having ACLs on filesystem nodes. It is doing that while making dangerous assumptions (i.e. all my config files can be public - 444/555!) and because at the time of writing (the idea of Nix dates back to 2003!), Linux had no other means of deduplicating content other than symlinks.

In the long run filesystems that support deduplication should be used (ZFS, btrfs, XFS, have I missed something?) or even writing something like a systemFS/NixFS that manages ACLs by user/pid/environment/context (think NSALinux with a fixed state) is thinkable. By moving high-value information out of the store, not all problems are solved yet. Since, by reading the nix-store alone, you know the whole system config (maybe sans the passwords/keys), plus the environment (other machines, routings, IPs). However, this is not an easy task since it challenges one of the core elements of Nix(OS): the Store...and thus a lot of other concepts should be checked before hacking a intermediate solution.

Although NixOS relies currently on systemd, security should not completely forgotten.


@joachifm Great. Thanks for creating an issue.

@nlewo
Copy link
Member

nlewo commented Feb 20, 2017

FYI, there is also an attempt to manage secrets in the openstack modules https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/openstack/common.nix#L24.
Basically, we let the user choose how the password is stored (currently in the store or in a file) and we provide helpers to replace them in configuration files at runtime.

rvl added a commit to rvl/nixpkgs that referenced this issue Mar 10, 2017
Added extra config options to allow reading passwords from file rather
than the world-readable nix store.

The full config.json file is created at service startup.

Relevant to NixOS#18881
Mic92 pushed a commit that referenced this issue Mar 12, 2017
Added extra config options to allow reading passwords from file rather
than the world-readable nix store.

The full config.json file is created at service startup.

Relevant to #18881
globin pushed a commit that referenced this issue Mar 13, 2017
Added extra config options to allow reading passwords from file rather
than the world-readable nix store.

The full config.json file is created at service startup.

Relevant to #18881

(cherry picked from commit f488b18)
@florianjacob
Copy link
Contributor

„Provide options for storing secrets outside the Nix store:“ #24288 collects all affected packages, tracks progress and provides information on how to do the transition for storing secrets outside of the nix store.

@domenkozar
Copy link
Member

For gitlab the PR that fixes this is in https://github.com/NixOS/nixpkgs/pull/31358/files and general issue for going on is in #24288

Closing.

adrianpk added a commit to adrianpk/nixpkgs that referenced this issue May 31, 2024
Added extra config options to allow reading passwords from file rather
than the world-readable nix store.

The full config.json file is created at service startup.

Relevant to NixOS#18881

(cherry picked from commit f488b18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests