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

PostgreSQL plugin creates roles with password in clear text #6910

Closed
rafaelremondes opened this issue Jun 18, 2019 · 5 comments
Closed

PostgreSQL plugin creates roles with password in clear text #6910

rafaelremondes opened this issue Jun 18, 2019 · 5 comments

Comments

@rafaelremondes
Copy link

Hello

I am using the PostgreSQL plugin to create temporary credentials. The creation statement allows to set a password for the role newly created. However, in PostgreSQL, when creating a ROLE with password it is showed in clear test in logs.

Documentation in Postgres suggests that is possible to pass an hash using md5 or other function instead of clear text password.

https://www.postgresql.org/docs/current/sql-createrole.html

If the presented password string is already in MD5-encrypted or SCRAM-encrypted format, then it is stored as-is regardless of password_encryption (since the system cannot decrypt the specified encrypted password string, to encrypt it in a different format). This allows reloading of encrypted passwords during dump/restore.

So, could Vault store an hashed password instead of one in clear text?

Disabling the logs for the db user Vault uses to create the role would work but it would not be ideal as we would miss logs that might be important for debugging or auditing.

Thanks

@evkuzin
Copy link

evkuzin commented Jul 25, 2019

agreed, I have the same problem. When logs format == ddl - all passwords stored cleartext in log.

@ncabatoff
Copy link
Collaborator

Think we would need lib/pq#941 (or an equivalent from another library) to implement this.

@Neustradamus
Copy link

@rafaelremondes, @evkuzin, @ncabatoff: The lib/pq has SCRAM-SHA-256 support since a moment:

And you can see this PR here:

@aphorise
Copy link
Contributor

aphorise commented Sep 1, 2022

There's been a change to pgx from lib/pq as per the CHANGELOG.md release notes of 1.11.0

database & storage: Change underlying driver library from lib/pq to pgx. This change affects Redshift & Postgres database secrets engines, and CockroachDB & Postgres storage engines [GH-15343].

I'm curious if this is an issue still or relevant?

@rafaelremondes can you kindly confirm if you've retested since?

PS - @Neustradamus @evkuzin - any input from you folks on a retest would be welcome too.

@raymonstah
Copy link
Contributor

Hey folks, there's a fix for this in #19616 and should be released as a part of Vault 1.14.
You'll have to update your PostgreSQL configuration using the following:

    $ vault write database/config/my-postgresql-database \
        ... \
        password_authentication="scram-sha-256"

With the password_authentication set to scram-sha-256, passwords created by Vault will first hashed before sending them to PostgreSQL, which will store the hashed password as-is, preventing plaintext passwords from leaking in the logs.

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

7 participants