-
Notifications
You must be signed in to change notification settings - Fork 27
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
Credentials with dot ('.') in domain name are parsed improperly by get_enterprise_name #44
Comments
The code is already checking for an "@", |
The probelm of doing that of course is that it would then always recognize user@domain as an enterprise name, and will always fail to fill in the domain part ... What I do not understand is that you say the user is passing in "my.domain.fqdn\username" as the user name, and then somehow it is magically presented to gssapi as '[email protected]' ... what did that conversion? |
That said, I do see that this seem to cause issues, and given I do not think enterprise names are all that much used I think we can try to change the semantics here. But unclear how to change them to be compatible with krb5 so the same name could be used in fallback cases... |
In "net use" command the client uses "my.domain.fqdn\username" and inside SMB SecurityContext is it is split on two fields. After that it is re-assembled in the form of useratdom='[email protected]' |
And who reassembles it that way ? |
Is it code under your control? Or is something else ? |
In gssntlm_accept_sec_context we have useratdom who reassebles as "user@domain". |
Security context comes from SMB2 protocol directly to GSS layer (as a binary blob) without any modification. We don't have any control over that. |
Ah I see it now ... we can definitely change that reassembly to use different semantics (ie domain\username). If I do it that way I do not have to change the enterprise name detection code. |
I'm afraid that you can't change only internal format of 'useratdom' inside gssntlm_accept_sec_context and leave get_enterprise_name as is because the later relies on 'user@domain' format. Let's summarize possible intended variants.
And domain part can be one of:
Let's review the logic of current implementation for get_enterprise_name:
In case if user='username(slash)(at)gmail.com' and domain='something', Also in case if user='username' and domain='DOMAIN.FQDN', we assemble useratdom='DOMAIN.FQDN\username' and get_enterprise_name will not find (slash)(at) and will try to search for just (at) which is not present anymore due changed format. The logic will become even more weird if we take into account that (at) sign can be potentially used in user part several times! |
I did consider the case of domain.fqdn\username, and get_enterprise_name() behaves as intended, as this is not an enterprise name. Although in theory you can used any character in a netbios domain name using the @ character in the domain flat name will simply not be supported. As per MS documentation the '@' character is technically allowed in usernames, but will cause a lot of things to not work correctly including synchronization to things like Office 365 and similar. And in general will fail to work in GSSAPI. So in theory you can have a username of 'usern@me' but doing so will cause a lot of issues in general. Can you provide some interop testing as an smb client using such a strange concoction ? |
I can reproduce following use-cases:
For some reason I can't easily reproduce mixed variants, I'm getting errors from "net use" command. |
I updated PR #45 with a better get_enterprise_name() function that should handle your case as well as being more strict on truly bonker cases. Let me know if that helps. |
We use gssntlmssp for SMB server authentication with external user (both client and server are joined to AD, winbind is running).
When SMB user is using FQDN as domain name (with dots), gssntlmssp tries to authenticate wrong user and winbind fails the authentication.
Use-case:
Windows user is trying to map SMB drive manually via cmd.exe with custom '/user' parameter where domain is represented as FQDN:
net use x: \server_ip\share_name /user:my.domain.fqdn\username
We have the following problematic flow:
gssntlm_accept_sec_context -> gssntlm_import_name -> gssntlm_import_name_by_mech -> get_enterprise_name
On the level of gssntlm_accept_sec_context we have useratdom='[email protected]' and it is parsed by get_enterprise_name as whole username because it contains dots in domain name. I.e. gssntlmssp parses it
as domain=NULL and username='[email protected]'.
Expected behaviour is to parse it as domain='my.domain.fqdn' and username='username'.
Note - using FQDN as domain name is required in cases when short domain name is not unique in AD forest, for example
we have 'sales.us.mycompany.com' and 'sales.europe.mycompany.com'; in this case short domain name 'sales' is not unique and cannot be used.
In the code I see following commit related to this bug (see below). When the change is reverted, the issue is fixed.
I think that we need to handle "email address as username" use-case in other more safe way (check only for \@ in username, don't rely on dots in domain name) because dots in domain name is not "unlikely" but the required flow.
The text was updated successfully, but these errors were encountered: