-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Read from config file to hide sensitive info from process list #474
Comments
This issue is similar to #277 and calls for the same solution: reading the secret from a configuration file instead. |
Ah that's too bad, thanks for the heads up. Which config file format would you like? I could do json or yaml or a plain |
I would go with the latter ( Also, it is the format used in |
Makes sense. Also should we add a special command line flag to pass the path of a configuration file, or expect the file to live in |
We should do both:
|
hardcoding the path in the binary is not a good idea, it should be a flag. |
@ruslantalpa reading the config file from a known location is just a convenience; I agree that the most important is to add support for the command line argument. |
Also, the minimum needed to solve this issue is to allow reading the JWT secret from a file. Since providing the secret as a text parameter is unsafe, we could deprecate or replace the current parameter and define a new parameter which reads the secret from a file instead. |
another solution could be this http://unix.stackexchange.com/questions/244353/why-can-i-list-other-users-process-without-root-permission |
@ruslantalpa Cool trick, thanks! This is a good workaround before fixing it properly with a configuration file. |
I just confirmed that |
Any news on when this might be resolved? FWIW: I'm a fan of the curl style syntax for providing a string param from a file; which is to parse the string passed to the arg and if it starts with a "@" then the arg is read as the file name containing the true value. for example:
p.s. I once again find myself hamstrung by the obscure choice of language for this project. I would happily contribute were postgrest written in something not requiring learning a new language. |
the more i think about this, the more i don't understand how this is a security issue. |
It is ridiculously presumptuous to say that every person who has shell access to a machine should have access to secret material. There is a reason why filesystems have permissions and systems support multiple users... Because not every user is entitled to all information. |
And there is a reason today the talk in tech is around aws/containers/unikernels for production and not the multiuser os paradigm from the 70's |
Currently the only values we need to hide from the process list are the postgresql password and the jwt secret. The password can be removed from the command line by using the .pgpass file. This leaves the jwt secret unprotected. In #495 we found that passing a jwt secret at the command line can mangle it when using binary values and concluded that we need to allow the jwt secret to be loaded from a file. This is another argument for getting it out of the command line arguments. @drawks I like your idea about the More generally I looked into just reading all parameters from a postgrest config file, but I think it requires removing the current optparse-applicative code which handles our command line arguments. That's because some of the postgrest arguments are marked as required, and I don't know how to tell the library that we got those arguments from another source (the config file) and that it doesn't have to complain if they are missing from the command line. So how about extending the jwt secret param to interpret the |
It works for me. It would break secrets starting with the '@' character however. |
I have implemented the In particular postgrest would have a single (optional) parameter for its configuration file path. As mentioned above it could have a default location if the parameter is not specified. Thoughts? |
(This issue got auto-closed by a comment in the PR which implemented |
That completely makes sense.
That sounds great. |
There are quite a few packages to evaluate.
From my brief inspection the configurator package looks most interesting. There is even a package to help me honor the XDG Base Directory spec for configuration file location. https://hackage.haskell.org/package/xdg-basedir |
when in doubt always go with BOS :) (but i don't think there is doubt) |
I just tried v0.4 and was surprised by the move to requiring a configuration file. It goes against the 12factorapp best practices, complicates the deployment via docker/kubernetes etc. I've also always liked it that the postgrest was a self contained, relocatable binary with no setup. Could we get back the ability to configure postgrest via the command line? |
You're right that it's less convenient for Docker. You have to map the config file into the container. It's also more complicated in the Heroku buildpack which I still need to update for the new version. Let me explain the reasons leading up to the switch and then we can figure out what makes sense to do. Originally, as this issue testifies, people wanted to hide secrets from the process list. Even passing in The next complicating factor is that the library we use to parse command line arguments considers each argument as either required or not. However when arguments are read from both the command line and a config file then they are only required on the command line when absent in the config. The parsing thing is fixable with some work, but I also considered that most other servers like Apache or Nginx use a config file so it felt normal to do things that way. I'm open to questioning the convention of course, but it is a common practice. The last point is that the jury seems to be out about this particular part of the twelve-factor app design.
Do those articles affect your opinion about the config file? |
I think there is some conflict between two sides: traditional deployment approaches and containers. For the former, it makes sense to have a config file for the deployment, security, and configuration update benefits. However, when deploying via containers, none of these arguments are relevant nor provide any benefit; the opposite, in fact. So, I think that the config file should be kept and supported for traditional deployments. But command line flags should also be an option for flexibility. As for containers, postgrest should try to read the uppercase configuration parameter name from the environment variables so a shell entrypoint script doesn't need to be written. |
In #826 I'm working on a scheme where the Docker container uses a config file that interpolates from environment variables, so you have an option to either map a custom config file into the container, or just to set environment vars as usual. Ran into a problem about parsing interpolated integers, but got a response about that today in the associated configurator-ng library. |
Ah, I missed that issue so I'll follow the progress there. Thanks. |
Fixes PostgREST#474, fixes PostgREST#495 when file is used
When the secret value starts with '@', the rest of the value is treated like the path to a file which contains the secret. This change allows to hide the secret from the command line, which solves issue PostgREST#474. Based on: commit 449480b Author: Joe Nelson <[email protected]> Date: Sat Sep 3 23:47:56 2016 -0700 Require JWT secret, remove default, optionally read from file Fixes PostgREST#474, fixes PostgREST#495 when file is used
Fixes PostgREST#474, fixes PostgREST#495 when file is used
The method suggested in the documentation, Hiding Password from Process List by setting an environment variable, leaves the value visible in
ps
listing, since the parameter$PASS
is expanded and replaced with its value before running the command.The text was updated successfully, but these errors were encountered: