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

NTLMChallengeBind: avoid panic #305

Merged
merged 2 commits into from
Mar 30, 2021
Merged

Conversation

georgmu
Copy link
Contributor

@georgmu georgmu commented Jan 21, 2021

if ntlmsspChallenge is empty or shorter than 7 bytes, the '[:7]' will cause a panic:

panic(0xbe1a40, 0xc00013ec60)
	runtime/panic.go:969 +0x1b9
github.com/go-ldap/ldap/v3.(*Conn).NTLMChallengeBind(0xc0002da300, 0xc000382d80, 0x0, 0x0, 0x0)
	github.com/go-ldap/ldap/v3@v3.2.4/bind.go:489 +0xf46
github.com/go-ldap/ldap/v3.(*Conn).NTLMBind(...)
	github.com/go-ldap/ldap/v3@v3.2.4/bind.go:441

Thus, avoid the panic by doing a length check.

This was tested against an LDAP server not supporting NTLM authentication. After the change, I get an expected error:

LDAP Result Code 7 "Auth Method Not Supported": unknown authentication method

if ntlmsspChallenge is empty or shorter than 7 bytes, the '[:7]' will cause a panic

Thus, avoid the panic by doing a length check.
@stefanmcshane stefanmcshane merged commit 89fb9d1 into go-ldap:master Mar 30, 2021
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.

2 participants