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

LDAP bind fail #3656

Closed
aprousas opened this issue Dec 6, 2017 · 12 comments
Closed

LDAP bind fail #3656

aprousas opened this issue Dec 6, 2017 · 12 comments
Milestone

Comments

@aprousas
Copy link

aprousas commented Dec 6, 2017

Environment:

  • Vault Version: v0.9.0 and v0.8.3
  • Operating System/Architecture: CentOS 7.2 x86_64

Vault Config File:

backend "file" {
  path = "secrets"
}

listener "tcp" {
  address = "0.0.0.0:8200"
  tls_disable = 1
}

disable_mlock = true

Vault LDAP Config

vault write auth/ldap/config url=URL \
                             binddn="cn=vault,ou=Users,dc=example,dc=com" \
                             bindpass=PASS \
                             userattr=sAMAccountName

Expected Behavior:

Authenticate user using LDAP auth backend.

Actual Behavior:

$ vault auth -method=ldap username=myuser
Password (will be hidden):
Error making API request.

URL: PUT http://0.0.0.0:8200/v1/auth/ldap/login/myuser
Code: 400. Errors:

* LDAP bind (service) failed: unable to read LDAP response packet: unexpected EOF

I have captured the communication between Vault and the LDAP server and noticed that there is a problem with the LDAP bind request.

Vault produces the following LDAP bind request (taken from Wireshark) :

40 55 39 b6 21 67 00 0c 29 f2 4d 32 08 00 45 00    @U9.!g..).M2..E.
00 6b b9 70 40 00 40 06 b5 fe c0 a8 00 42 0a 00    .k.p@.@......B..
00 34 de 28 01 85 1e 11 a7 ac d9 50 f9 6c 80 18    .4.(.......P.l..
00 e5 cb 7b 00 00 01 01 08 0a 0b 83 1f 0b a8 f0    ...{............
e3 23 30 35 02 01 01 60 30 02 01 03 04 23 63 6e    .#05...`0....#cn
3d 76 61 75 6c 74 2c 6f 75 3d 55 73 65 72 73 2c    =vault,ou=Users,
64 63 3d 65 78 61 6d 70 6c 65 2c 64 63 3d 63 6f    dc=example,dc=co
6d 80 04 50 41 53 53 a0 00                         m..PASS..

I compared the above with a working scenario and I noted that in the working scenario there were no characters just after the "PASS". This made me think that in the above request the problem lies in the last two characters (a0 00) which they are the 'breaking space' and the 'null character'. Could this be the problem? If so, what is the way to work around it? Can anyone justify why these are there?

References:

Maybe it is related to issue #3402

@vishalnayak
Copy link
Member

vishalnayak commented Dec 7, 2017 via email

@aprousas
Copy link
Author

aprousas commented Dec 7, 2017

Hello @vishalnayak ,

Thank you for your quick response. I've tried supplying the bindpass in quotes but it failed again for the same reason. I've also experimented with multiple ldap configuration option values and combinations but all failed.

The LDAP bind requests which are produced by ldapsearch tool work fine and do not contain any extra characters after the "PASS".

It seems that Vault adds those extra characters, but I cannot figure out what causes this problem.

@vishalnayak
Copy link
Member

@aprousas It looks like the problem in the underlying library which Vault is using, go-ldap. I see that there is an issue (go-ldap/ldap#137) posted there which comes close to this.

@jefferai
Copy link
Member

jefferai commented Dec 7, 2017

I can't say for sure whether the control characters are incorrect or not, but I can successfully log in when those are present:

$ vault write auth/ldap/config url="ldap://ldap.forumsys.com" binddn="cn=read-only-admin,dc=example,dc=com" userdn="dc=example,dc=com" userattr=uid

$ vault auth -no-verify -method=ldap username=tesla password=password

Trace:

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 3c c0 7c 40 00 40 06 c7 ee c0 a8 0a 7d 36 c4   .<.|@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 7b 00 00 00 00 a0 02   .g....9.R{......
0030  72 10 b2 7f 00 00 02 04 05 b4 04 02 08 0a 96 e7   r...............
0040  1a 01 00 00 00 00 01 03 03 07                     ..........

0000  00 50 56 3a 95 44 f0 9f c2 15 a1 34 08 00 45 00   .PV:.D.....4..E.
0010  00 3c 00 00 40 00 30 06 98 6b 36 c4 b0 67 c0 a8   .<..@.0..k6..g..
0020  0a 7d 01 85 e0 b0 e4 f9 45 d0 39 df 52 7c a0 12   .}......E.9.R|..
0030  16 a0 a5 cd 00 00 02 04 05 b4 04 02 08 0a 72 23   ..............r#
0040  1c cb 96 e7 1a 01 01 03 03 06                     ..........

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 34 c0 7d 40 00 40 06 c7 f5 c0 a8 0a 7d 36 c4   .4.}@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 7c e4 f9 45 d1 80 10   .g....9.R|..E...
0030  00 e5 b2 77 00 00 01 01 08 0a 96 e7 1a 12 72 23   ...w..........r#
0040  1c cb                                             ..

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 67 c0 7e 40 00 40 06 c7 c1 c0 a8 0a 7d 36 c4   .g.~@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 7c e4 f9 45 d1 80 18   .g....9.R|..E...
0030  00 e5 b2 aa 00 00 01 01 08 0a 96 e7 1a 12 72 23   ..............r#
0040  1c cb 30 31 02 01 01 60 2c 02 01 03 04 1b 75 69   ..01...`,.....ui
0050  64 3d 74 65 73 6c 61 2c 64 63 3d 65 78 61 6d 70   d=tesla,dc=examp
0060  6c 65 2c 64 63 3d 63 6f 6d 80 08 70 61 73 73 77   le,dc=com..passw
0070  6f 72 64 a0 00                                    ord..

0000  00 50 56 3a 95 44 f0 9f c2 15 a1 34 08 00 45 00   .PV:.D.....4..E.
0010  00 34 59 1e 40 00 30 06 3f 55 36 c4 b0 67 c0 a8   .4Y.@.0.?U6..g..
0020  0a 7d 01 85 e0 b0 e4 f9 45 d1 39 df 52 af 80 10   .}......E.9.R...
0030  00 5b ea 95 00 00 01 01 08 0a 72 23 1c cf 96 e7   .[........r#....
0040  1a 12                                             ..

0000  00 50 56 3a 95 44 f0 9f c2 15 a1 34 08 00 45 00   .PV:.D.....4..E.
0010  00 42 59 1f 40 00 30 06 3f 46 36 c4 b0 67 c0 a8   .BY.@.0.?F6..g..
0020  0a 7d 01 85 e0 b0 e4 f9 45 d1 39 df 52 af 80 18   .}......E.9.R...
0030  00 5b a7 07 00 00 01 01 08 0a 72 23 1c cf 96 e7   .[........r#....
0040  1a 12 30 0c 02 01 01 61 07 0a 01 00 04 00 04 00   ..0....a........

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 34 c0 7f 40 00 40 06 c7 f3 c0 a8 0a 7d 36 c4   .4..@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 af e4 f9 45 df 80 10   .g....9.R...E...
0030  00 e5 b2 77 00 00 01 01 08 0a 96 e7 1a 22 72 23   ...w........."r#
0040  1c cf                                             ..

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 34 c0 80 40 00 40 06 c7 f2 c0 a8 0a 7d 36 c4   .4..@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 af e4 f9 45 df 80 11   .g....9.R...E...
0030  00 e5 b2 77 00 00 01 01 08 0a 96 e7 1a 23 72 23   ...w.........#r#
0040  1c cf                                             ..

0000  00 50 56 3a 95 44 f0 9f c2 15 a1 34 08 00 45 00   .PV:.D.....4..E.
0010  00 34 59 20 40 00 30 06 3f 53 36 c4 b0 67 c0 a8   .4Y @.0.?S6..g..
0020  0a 7d 01 85 e0 b0 e4 f9 45 df 39 df 52 b0 80 11   .}......E.9.R...
0030  00 5b ea 6d 00 00 01 01 08 0a 72 23 1c d6 96 e7   .[.m......r#....
0040  1a 23                                             .#

0000  f0 9f c2 15 a1 34 00 50 56 3a 95 44 08 00 45 00   .....4.PV:.D..E.
0010  00 34 c0 81 40 00 40 06 c7 f1 c0 a8 0a 7d 36 c4   .4..@.@......}6.
0020  b0 67 e0 b0 01 85 39 df 52 b0 e4 f9 45 e0 80 10   .g....9.R...E...
0030  00 e5 b2 77 00 00 01 01 08 0a 96 e7 1a 3f 72 23   ...w.........?r#
0040  1c d6                                             ..

@aprousas
Copy link
Author

aprousas commented Dec 7, 2017

@jefferai

I appreciate your feedback. I hear you. So you mean that those two characters are not the problem. But do you have an indication then what the problem might be? Sorry, but I'm complete lost here and i'm struggling to figure out what the case is. I hope you understand.

@vishalnayak

Thanks for your feedback, too.
I read the post you are referring, but I'm failing to see what the resolution is.
Do you have anything in mind or is it just a pending issue which has yet to be investigated and your recommendation is for me to follow this issue till resolution?

Waiting for your feedback

Best regards,
Apostolos

PS: I'm using an Active Directory Service in AWS , should you believe it could be an issue with the compatibility with the LDAP server

@jefferai
Copy link
Member

jefferai commented Dec 7, 2017

@aprousas any chance you can build Vault? I have a potential change to the go-ldap library, would be good to see if it fixes things for you.

@jefferai
Copy link
Member

jefferai commented Dec 7, 2017

If you can build and test the test-goldap-fix branch that would be great!

@aprousas
Copy link
Author

aprousas commented Dec 7, 2017

@jefferai I will try it and let you know about the results.

Thanks!

@jefferai
Copy link
Member

jefferai commented Dec 7, 2017

go-ldap/ldap#142 has been approved but not merged yet; #3625 was fixed by that change, so for sure I will make sure that either the updated lib or my patched version are in 0.9.1. Extra verification from you would be great as well.

@jefferai
Copy link
Member

jefferai commented Dec 7, 2017

@aprousas BTW your wireshark debugging was totally invaluable for solving this. Thanks so much for it!

@aprousas
Copy link
Author

aprousas commented Dec 8, 2017

@jefferai I've built Vault from test-goldap-fix branch and managed to bind to ldap and authenticate a user successfully.

Thank you for your help!

@jefferai
Copy link
Member

jefferai commented Dec 8, 2017

Great!

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

3 participants