-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Describe the bug
bonfire requires to store secrets directly into envvars, instead of reading them from files (whose paths can be stored into envvars).
systemd's documentation explains the problem well:
Note that environment variables are not suitable for passing secrets (such as passwords, key material, …) to service processes. Environment variables set for a unit are exposed to unprivileged clients via D-Bus IPC, and generally not understood as being data that requires protection. Moreover, environment variables are propagated down the process tree, including across security boundaries (such as setuid/setgid executables), and hence might leak to processes that should not have access to the secret data. Use LoadCredential=, LoadCredentialEncrypted= or SetCredentialEncrypted= (see below) to pass data to unit processes securely.
To Reproduce
Expected behavior
Secrets must be passed through files without their content ever going into the environment or command args.
Here's a list to consider for problematic envvars:
RELEASE_COOKIE, in_build/prod/rel/bonfire/bin/bonfirepassed toelixirthrough command args--cookie $RELEASE_COOKIEthen passed toerlthrough-setcookie $RELEASE_COOKIEwhich sadly disables reading it from$HOME/.erlang.cookieor$XDG_CONFIG_HOME/erlang/.erlang.cookie:
So apparently the only workaround for that envvar is to call elixir directly without using _build/prod/rel/bonfire/bin/bonfire.
ERLANG_COOKIE, looks like an alternativeRELEASE_COOKIEspecific tojustfile, different from_build/prod/rel/bonfire/releases/COOKIE, apparently not used whenMIX_ENV=prodSECRET_KEY_BASESIGNING_SALTENCRYPTION_SALTMAIL_KEYUPLOADS_S3_ACCESS_KEY_IDMAIL_PASSWORDMEILI_MASTER_KEYMAPBOX_API_KEYPOSTGRES_PASSWORDZENODO_CLIENT_IDZENODO_CLIENT_SECRETORCID_CLIENT_IDORCID_CLIENT_SECRETPIRATE_WEATHER_APIOTEL_LIGHTSTEP_API_KEYOTEL_HONEYCOMB_API_KEYAPPSIGNAL_PUSH_API_KEYOPEN_WEATHER_MAP_API_KEYDATABASE_URL, can contain the PostgreSQL password.AKISMET_API_KEYWEB_PUSH_PRIVATE_KEYGITHUB_TOKENTX_TOKENGITHUB_CLIENT_SECRETUPLOADS_S3_SECRET_ACCESS_KEY
Bonfire environment (please complete the following information):
- Running env: prod
- Running with Co-op Cloud and/or Docker?: none
- Running version (check on your instance's sidebar): 1.0.0
- Running flavour: social
- Running any extra/forked extensions:
Client device (please complete the following information):
- Device:
- OS: NixOS
- Browser
- Browser Version
Additional context
nix/module.nix uses EnvironmentFile= to avoid a bigger problem (the secrets would go into the Nix store in clear with Environment=):
Lines 40 to 52 in 43fae54
| environmentFile = mkOption { | |
| type = types.nullOr types.path; | |
| default = null; | |
| description = '' | |
| environment file for secret environment variables | |
| should contain | |
| SECRET_KEY_BASE | |
| SIGNING_SALT | |
| ENCRYPTION_SALT | |
| RELEASE_COOKIE | |
| ''; | |
| }; | |
| }; |
but the secrets still end up into the processes' environment.
The secrets must instead be loaded from files (passed to the processes with LoadCredential=/LoadEncryptedCredential= in the case of systemd).