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

Database password written to process list #2014

Closed
plockaby opened this issue Jul 12, 2020 · 6 comments
Closed

Database password written to process list #2014

plockaby opened this issue Jul 12, 2020 · 6 comments
Assignees
Milestone

Comments

@plockaby
Copy link

plockaby commented Jul 12, 2020

Environmental Info:
K3s Version: k3s version v1.18.4+k3s1 (97b7a0e)
Node(s) CPU architecture, OS, and Version: Linux pluto 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux

Cluster Configuration: one master, five workers
Describe the bug:
If you initialize a k3s cluster with database connection details in it those details are written directly to ps. For example:

$ curl -sfL https://get.k3s.io | sh -s - --datastore-endpoint=postgres://k3s:supersecret@localhost:5432/k3s
$ ps -ef | grep k3s
root       3799      1  8 Jul10 ?        04:32:08 /usr/local/bin/k3s server --datastore-endpoint=postgres://k3s:supersecret@localhost:5432/k3s

Steps To Reproduce:

  • Installed K3s: see the description above

Expected behavior:
I would expect, at a minimum, that the password would be replaced with asterisks in the ps output. It might also be great to be able to put the password into a configuration file rather than store it in the systemd configuration file.

Actual behavior:
The password is free to anyone to see who has any access to the system.

Additional context / logs:
I suppose that one such solution to this would be to put the postgres database password into a .pgpass file owned by root but that wouldn't work for mysql, I don't think.

@brandond
Copy link
Contributor

This is probably best addressed by either

  • using environment variables instead of command-line args
  • waiting for Add config file support #1899 and putting the datastore uri in the config file

@plockaby
Copy link
Author

Those are both good ideas and reasonable solutions but I don't think that they go far enough. As long as you accept a database URI on the command line, the application should venture to obscure the password from visibility. IMO this is actually a security issue but I did not see anywhere to submit security bugs.

@cjellick
Copy link
Contributor

FYI, You can submit security issues to [email protected], but no need to change or resubmit this issue since it is already in the open.

@brandond brandond self-assigned this Jul 14, 2020
@davidnuzik davidnuzik added this to the v1.19 - Backlog milestone Jul 20, 2020
brandond added a commit to brandond/k3s that referenced this issue Jul 27, 2020
This is related to k3s-io#2014.

Signed-off-by: Brad Davidson <[email protected]>
brandond added a commit to brandond/k3s that referenced this issue Jul 27, 2020
This is related to k3s-io#2014.

Signed-off-by: Brad Davidson <[email protected]>
brandond added a commit to brandond/k3s that referenced this issue Jul 27, 2020
This is related to k3s-io#2014.
Signed-off-by: Brad Davidson <[email protected]>
brandond added a commit to brandond/k3s that referenced this issue Jul 28, 2020
This is related to k3s-io#2014.
Signed-off-by: Brad Davidson <[email protected]>
brandond added a commit to brandond/k3s that referenced this issue Jul 28, 2020
This is related to k3s-io#2014.
Signed-off-by: Brad Davidson <[email protected]>
brandond added a commit to brandond/k3s that referenced this issue Jul 28, 2020
This is related to k3s-io#2014.

Signed-off-by: Brad Davidson <[email protected]>
@brandond
Copy link
Contributor

@plockaby does this work for you?

@plockaby
Copy link
Author

This is perfect. Thanks for looking into it so quickly!

@davidnuzik davidnuzik added [zube]: To Test kind/task Work not related to bug fixes or new functionality and removed [zube]: Peer Review labels Jul 29, 2020
@zube zube bot removed the kind/task Work not related to bug fixes or new functionality label Jul 29, 2020
@rancher-max
Copy link
Contributor

Validated using the current latest commit

This now just shows the server or agent command, without additional args:

$ curl -sfL https://get.k3s.io | INSTALL_K3S_COMMIT="6fcec6aea9fcb8d79c7020cdea217ac40ccac72c" sh -s - server --datastore-endpoint="mysql://user:pass@tcp(somedb:3306)/k3s"
$ ps -ef | grep k3s
root        4064       1 56 19:01 ?        00:00:09 /usr/local/bin/k3s server
ubuntu      4327    2047  0 19:01 pts/0    00:00:00 grep --color=auto k3s
root        4328    4096  0 19:01 ?        00:00:00 /var/lib/rancher/k3s/data/d8a1e0e2fcdb1dc0a99617cda153dee4de24891e3ba102a9c272ef52e5695db4/bin/unpigz -d -c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants