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

Allow NTLM authentication without a password #371

Merged
merged 6 commits into from Apr 21, 2022
Merged

Allow NTLM authentication without a password #371

merged 6 commits into from Apr 21, 2022

Conversation

nodauf
Copy link
Contributor

@nodauf nodauf commented Apr 20, 2022

Actually, the function UnauthenticatedBind allows an anonymous or a username without password with a SimpleBindRequest.

This PR implements the same feature for an NTLMBind with the help of NTLMUnauthenticatedBind

Copy link
Member

@cpuschma cpuschma left a comment

Choose a reason for hiding this comment

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

Thank you for your PR 👍

v3/bind.go Outdated
// authenticated or otherwise validated by the LDAP server.
//
// See https://tools.ietf.org/html/rfc4513#section-5.1.2 .
// See https://tools.ietf.org/html/rfc4513#section-6.3.1 .
Copy link
Member

Choose a reason for hiding this comment

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

May you please update/add links for the NTLM anonymous request? Maybe refer to this PDF from Microsoft, for example section "3.2.5.1.2 Server Receives an AUTHENTICATE_MESSAGE from the Client"

https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-NLMP/%5BMS-NLMP%5D.pdf

Copy link
Member

Choose a reason for hiding this comment

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

You forgot to update the comment for v3 😅, @nodauf

v3/bind.go Outdated
@@ -442,6 +445,24 @@ func (l *Conn) NTLMBind(domain, username, password string) error {
return err
}

// NTLMUnauthenticatedBind performs an unauthenticated bind.
//
// A username may be provided for trace (e.g. logging) purpose only, but it is normally not
Copy link
Member

@cpuschma cpuschma Apr 20, 2022

Choose a reason for hiding this comment

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

https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-NLMP/%5BMS-NLMP%5D.pdf

[...] If the user name and response are empty, the server authenticates the client as the ANONYMOUS user...

In the same document, see section "3.3.2 NTLM v2 Authentication" the pseudo code for the ServerChallenge:

If (User is set to "" && Passwd is set to "") <--
    -- Special case for anonymous authentication
    Set NtChallengeResponseLen to 0
    Set NtChallengeResponseMaxLen to 0
    Set NtChallengeResponseBufferOffset to 0
    Set LmChallengeResponse to Z(1)
[...]

I interpret that for a anonymous NTLM bind the username must be empty. I don't have an Active Directory server at hand as I'm on vacation, so I can't confirm the behaviour :/

Can someone confirm this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not notice that paper. The results of my tests are below:

  • A username with flag Password Not Required and an empty password (or the hash for empty password): A successful logon and I was able to use my ldap connection to retrieve information
  • A blank username and password: The error parsing ntlm-challenge: Anonymous authentication not supported is returned

Copy link
Member

@cpuschma cpuschma Apr 20, 2022

Choose a reason for hiding this comment

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

Thank you for your tests, @nodauf !
It seems anonymous NTLM authentications aren't supported by the Go NTLM library:

//ProcessChallenge crafts an AUTHENTICATE message in response to the CHALLENGE message
//that was received from the server
func ProcessChallenge(challengeMessageData []byte, user, password string) ([]byte, error) {
	if user == "" && password == "" {
		return nil, errors.New("Anonymous authentication not supported")
	}

May you update the comment of the function and remove these lines, as atleast a username is required for the NTLM challenge to succeed?

// A username may be provided for trace (e.g. logging) purpose only, but it is normally not
// authenticated or otherwise validated by the LDAP server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for taking the time to look. The comments have been updated (in both root folder and v3 😅 )

@johnweldon johnweldon merged commit 898ed3e into go-ldap:master Apr 21, 2022
cpuschma pushed a commit to clementblaise/ldap that referenced this pull request Apr 25, 2022
* Allow NTLM authentication without a password
m-vinc pushed a commit to m-vinc/ldap that referenced this pull request Jun 15, 2022
* Allow NTLM authentication without a password
inv2004 pushed a commit to inv2004/ldap that referenced this pull request Jan 17, 2023
* Allow NTLM authentication without a password
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.

None yet

3 participants