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

misleading error "ldap operation failed: failed to bind as user" when password contains trailing newline #20439

Open
classabbyamp opened this issue Apr 30, 2023 · 3 comments
Labels

Comments

@classabbyamp
Copy link

classabbyamp commented Apr 30, 2023

Describe the bug

when passing a password from stdin, it may contain an extra trailing newline. this causes the error ldap operation failed: failed to bind as user, which is very misleading. However, the real issue is that it accepted the newline as part of the password.

To Reproduce

Note: while echo/printf are used here for ease of reproduction, this applies to anything that could pipe the password to stdin, like a password manager

Steps to reproduce the behavior:

$ echo mypassword | vault login -method=ldap username=myuser password=-
Error authenticating: Error making API request.

URL: PUT https://vault.s.voidlinux.org/v1/auth/ldap/login/abby
Code: 400. Errors:

* ldap operation failed: failed to bind as user

this is made clear by using -output-curl-string:

$ echo mypassword | vault login -output-curl-string -method=ldap username=myuser password=-
curl -X PUT -H "X-Vault-Request: true" -d '{"password":"mypassword\n"}' $VAULT_ADDR/v1/auth/ldap/login/myuser

Expected behavior

login from stdin works as intended:

$ printf mypassword | vault login -output-curl-string -method=ldap username=myuser password=-
curl -X PUT -H "X-Vault-Request: true" -d '{"password":"mypassword"}' $VAULT_ADDR/v1/auth/ldap/login/myuser
$ printf mypassword | vault login -method=ldap username=myuser password=- 
Success! You are now authenticated.

Environment:

  • Vault Server Version (retrieve with vault status): 1.12.1
  • Vault CLI Version (retrieve with vault version): 1.13.0
  • Server Operating System/Architecture: Void Linux x86_64

Vault server configuration file(s):

I am just a user, I did not set up this vault server.

@miagilepner
Copy link
Contributor

Thank you for submitting this request! Please note that you can also use echo -n in order to echo without a newline.

For others who are interested in this, please stick a 👍 on this issue. We’re currently developing an internal process to review and prioritize requests.

@classabbyamp
Copy link
Author

classabbyamp commented May 1, 2023

as I mentioned in the original report, echo was just for demonstration purposes, I'm not actually passing my password in plaintext with echo...

@classabbyamp classabbyamp changed the title "ldap operation failed: failed to bind as user" when password contains trailing newline misleading error "ldap operation failed: failed to bind as user" when password contains trailing newline May 1, 2023
@maxb
Copy link
Contributor

maxb commented May 2, 2023

This issue would be a delicate balance between not introducing unexpected data transformations in places that could break things for people, and making the CLI useful for ad-hoc use.

Unfortunately there probably is no single choice of behaviour that will make everyone happy here. It's possible that leaving things as is might be the least worst compromise.

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

No branches or pull requests

3 participants