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

Ensure that URL encoded passwords are properly redacted. #14744

Merged
merged 2 commits into from
Mar 29, 2022

Conversation

benashz
Copy link
Contributor

@benashz benashz commented Mar 28, 2022

Originally created under https://github.com/hashicorp/vault-enterprise/pull/2671

The URL password redaction operation did not handle the case where the
database connection URL was provided as a percent-encoded string, and
its password component contained reserved characters. It attempted to
redact the password by replacing the unescaped password in the
percent-encoded URL. This resulted in the password being revealed when
reading the configuration from Vault.

Given the follow URL configured in the DB secret engine:

sqlserver://sa:yourStrong%28%21%[email protected]:55002

On Vault read we would get:

vault read --format json tf-test-db-279243129191764308/config/db-6338640021812042769 | \
  jq -r .data.connection_details.connection_url
sqlserver://sa:yourStrong%28%21%[email protected]:55004

Which is unquoted to reveal the password:

vault read --format json tf-test-db-279243129191764308/config/db-6338640021812042769 | \
jq .data.connection_details.connection_url | python3 -c 'from urllib import parse; import sys; print(parse.unquote(sys.stdin.read()))'
"sqlserver://sa:yourStrong(!)[email protected]:55004"

The URL password redaction operation did not handle the case where the
database connection URL was provided as a percent-encoded string, and
its password component contained reserved characters. It attempted to
redact the password by replacing the unescaped password in the
percent-encoded URL. This resulted in the password being revealed when
reading the configuration from Vault.
@benashz benashz requested review from a team, mickael-hc, swenson and calvn and removed request for a team March 28, 2022 18:30
Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM;

I also like the fact that we aren't blindly replacing the password with ***** now, just in case the password appears elsewhere in the URL.

@vercel vercel bot temporarily deployed to Preview – vault March 29, 2022 13:40 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook March 29, 2022 13:40 Inactive
@benashz benashz merged commit 3aed787 into main Mar 29, 2022
@benashz benashz deleted the VAULT-5435/fix-db-url-password-redaction branch March 29, 2022 14:34
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

Successfully merging this pull request may close these issues.

3 participants