Linux CIFS NTLMSSP mount failing against win2k8
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 1277853910.2423.5.camel@ruth
Quoted 35 lines · On Wed, 30 Jun 2010 09:25:10 +1000 Andrew Bartlett…
Quoted 26 lines · Shirish Pargaonkar
Quoted 16 lines · Jeff Layton
I've been playing with NTLMSSP today in CIFS, and have run across a problem. The Session Setup using Raw NTLMSSP succeeds, but then afterward the tree connect fails with
STATUS_ACCESS_DENIED. The odd thing is that if authenticate as the same user using krb5, then it works fine. smbclient does SPNEGO encapsulated NTLMSSP and the tree connect it does works fine as well.Attached is a capture that shows two "mount attempts". The first one fails (that the Linux CIFS one). The second succeeds -- that's the Linux CIFS one.
The code I'm using is slightly modified so that the tree connect is closer to identical to what smbclient does. That doesn't get around the problem though. I assume that there must be something wrong with the session setup, but since it succeeds it seems like it ought to work...
Quoted 8 lines
Does anyone have any clue as to what the problem is? Or does anyone know how to make win2k8 tell me why it's refusing the tree connect? The event viewer seems to be pretty useless for this, but maybe I'm just not looking in the right place?
--
Jeff Layton <[email protected]>Quoted 7 lines
Jeff,
You can see if this code change,
cifs_MD5_update(&context, (char *)&key->data, 16);
insetead of
cifs_MD5_update(&context, (char *)&key->data, key->len);
in functioncifs_calculate_signature()works.
Quoted 5 lines
If I had some context, I would be able to advise if this is correct. If this is the application of the 'session key' to the SMB singing (the MD5 with the actual packet), then this is important, but only for Kerberos, not NTLMSSP, which for all versions returns a 16 byte key.
(dropping old linux-cifs-client list and adding new one to cc list)
Unfortunately, I haven't had time to spend on this in a while so I haven't really given it the time it deserves. My gut feeling is that there are enough questionable portions of this code in CIFS that it really needs an overhaul from "first principles" -- starting by making the encryption algorithms use the standard kernel crypto libs and a review of what NTLMSSP flags are being set in the negotation. Some of that may just be my lack of familiarity with the code, but a lot of the unicode conversion in smbencrypt.c looks questionable.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 46 lines · Jeff Layton
Quoted 35 lines · On Wed, 30 Jun 2010 09:25:10 +1000 Andrew Bartlett <[email protected]> wrote:
Quoted 26 lines · Shirish Pargaonkar
Quoted 16 lines · Jeff Layton
I've been playing with NTLMSSP today in CIFS, and have run across a problem. The Session Setup using Raw NTLMSSP succeeds, but then afterward the tree connect fails with
STATUS_ACCESS_DENIED. The odd thing is that if authenticate as the same user using krb5, then it works fine. smbclient does SPNEGO encapsulated NTLMSSP and the tree connect it does works fine as well.Attached is a capture that shows two "mount attempts". The first one fails (that the Linux CIFS one). The second succeeds -- that's the Linux CIFS one.
The code I'm using is slightly modified so that the tree connect is closer to identical to what smbclient does. That doesn't get around the problem though. I assume that there must be something wrong with the session setup, but since it succeeds it seems like it ought to work...
Quoted 8 lines
Does anyone have any clue as to what the problem is? Or does anyone know how to make win2k8 tell me why it's refusing the tree connect? The event viewer seems to be pretty useless for this, but maybe I'm just not looking in the right place?
--
Jeff Layton <[email protected]>Quoted 7 lines
Jeff,
You can see if this code change,
cifs_MD5_update(&context, (char *)&key->data, 16); insetead of
cifs_MD5_update(&context, (char *)&key->data,key->len); in functioncifs_calculate_signature()works.Quoted 5 lines
If I had some context, I would be able to advise if this is correct. If this is the application of the 'session key' to the SMB singing (the MD5 with the actual packet), then this is important, but only for Kerberos, not NTLMSSP, which for all versions returns a 16 byte key.
(dropping old linux-cifs-client list and adding new one to cc list)
Quoted 8 lines
Unfortunately, I haven't had time to spend on this in a while so I haven't really given it the time it deserves. My gut feeling is that there are enough questionable portions of this code in CIFS that it really needs an overhaul from "first principles" -- starting by making the encryption algorithms use the standard kernel crypto libs and a review of what NTLMSSP flags are being set in the negotation. Some of that may just be my lack of familiarity with the code, but a lot of the unicode conversion in
smbencrypt.clooks questionable.
I would like to make some simplifying assumptions, e.g. the number of NTLMSSP flags we use. For SMB2 it is easier because we can limit support to only
two auth mechanisms: krb5 in spnego and ntlmv2 in ntlmssp - and only one signing mechanism (the new SHA256 one), but for cifs we have old servers that won't support those.
The originals for a few key pieces of the old came from Samba, so it probably had some of the same problems with Unicode
that you noted. Converting the RC4-MD5-HMAC to kernel crypto libs is harder than it seems. Shirish had some trouble with the kernel crypto (as did I a few years ago when I tried it - the code got uglier/bigger using those interfaces).
The documentation for this is harder than it seems to wade through (due to lack of examples).
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 1277767520.2276.41.camel@ruth
Quoted 11 lines · Andrew Bartlett
Quoted 3 lines · Shirish Pargaonkar
When I look at Windows - Windows smb2 traces, the (16 bytes) signature looks nothing like
version (which is 1), ciphertext of 8 bytes of hmac-md5, sequence numberSMB2 SMB Signing does not use the NTLMSSP packet signing algorithm. Instead, like SMB, it takes the session key already calculated and applies a unique-to-SMB2 algorithm to it. This involves sha256 I think.
Quoted 7 lines
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Cisco Inc.
I have had luck with some kernel crypto apis while working on this code. I have been able to use arc4 and md5 hash apis successfully while not being able to figure out hmac-md5 apis and I had not even looked at sha, which I will.
What is confusing to me is, current cifs code using ntlmv2 within ntlmssp authenticates and signs against Windows 2003 server successfully/
But it does not against Windows 7 and Windows 2008 (I do not have a Windows Vista installation). I am currently changing to code and I am sure I would be able to authenticate using ntlmv2 within ntlmssp. singing is what is confusing.
With smb2 client also, I can authenticate against Windows 7 and Windows 2008 but signing fails.
So I am confused about what algorithm to use for cifs to sign against Windows 7 and Windows 2008 server for ntlmv2 within ntlmssp and what algorithm to use for smb2 to sign against a Windows 7 and Windows 2008 server for ntlmv2 within ntlmssp.
I have been reading and following MS-NLMP and
http://davenport.sourceforge.net/ntlm.html
Quoted 38 lines · Shirish Pargaonkar
Quoted 11 lines · Andrew Bartlett
Quoted 3 lines · Shirish Pargaonkar
When I look at Windows - Windows smb2 traces, the (16 bytes) signature looks nothing like
version (which is 1), ciphertext of 8 bytes of hmac-md5, sequence numberSMB2 SMB Signing does not use the NTLMSSP packet signing algorithm. Instead, like SMB, it takes the session key already calculated and applies a unique-to-SMB2 algorithm to it. This involves sha256 I think.
Quoted 7 lines
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Cisco Inc.I have had luck with some kernel crypto apis while working on this code. I have been able to use arc4 and md5 hash apis successfully while not being able to figure out hmac-md5 apis and I had not even looked at sha, which I will.
What is confusing to me is, current cifs code using ntlmv2 within ntlmssp authenticates and signs against Windows 2003 server successfully/
But it does not against Windows 7 and Windows 2008 (I do not have a Windows Vista installation). I am currently changing to code and I am sure I would be able to authenticate using ntlmv2 within ntlmssp. singing is what is confusing.
With smb2 client also, I can authenticate against Windows 7 and Windows 2008 but signing fails.
Quoted 7 lines
So I am confused about what algorithm to use for cifs to sign against Windows 7 and Windows 2008 server for ntlmv2 within ntlmssp and what algorithm to use for smb2 to sign against a Windows 7 and Windows 2008 server for ntlmv2 within ntlmssp.
I have been reading and following MS-NLMP and
http://davenport.sourceforge.net/ntlm.html
The trick here is only to follow these up to the point at which the master key is generated, not the signing or sealing keys. The master key (16 bytes) is the input the special SMB and SMB2 signing algorithms.
Andrew Bartlett
Signature · 3 lines
Andrew Bartlett http://samba.org/~abartlet/ Authentication Developer, Samba Team http://samba.org Samba Developer, Cisco Inc.