Closed psfrolov closed 3 months ago
Thanks for the PR, I'm assuming this is for NTLM support with an account with no password? Do you actually have an account with an empty password string or is it to support something like a Guest
account?
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
cba319d
) 99.96% compared to head (6d29547
) 99.96%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for the PR, I'm assuming this is for NTLM support with an account with no password? Do you actually have an account with an empty password string or is it to support something like a
Guest
account?
I have the same issue, but it is not with a user that has an empty password getting authenticated. Instead it is with the error handling when provided an empty password with the password being something else. Instead of the expected Unauthorized status, an OperationNotAvaiableError exception is thrown for the NTLM_USER_FILE environment variable not set.
I think for your problem it's better to just update the existing error to be clearer around what the problem is. The current error about the NTLM_USER_FILE
can certainly be confusing for people but I don't think actually doing the authentication process is a good idea when an empty string is provided. The only case where that might be ideal is when authenticating with an account that has an empty string as a password but honestly that's not a good idea to have in any case.
Totally agree with the bad form of having an empty password. But is it an empty password even allowed or may it possible start another type of authentication? I was remember in a distant past that the empty password might have triggered another mode of security. I was worried in that I catch the exception to handle it differently that I either break the case that someone may have an empty password or if there might be a case where the NTLM_USER_FILE is used and for some reason I hide the true exception.
But is it an empty password even allowed or may it possible start another type of authentication?
It's super confusing and I might even have this wrong but Windows does support a blank/empty password for a user. There's a policy which is enabled by default which limits logons with a blank/empty password to direct console logons only https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/accounts-limit-local-account-use-of-blank-passwords-to-console-logon-only. If this policy is disabled then people could theoretically authenticate with an empty string.
There's also a "Guest" logon which uses SMB but IIRC it uses any username with either an invalid or blank password. The guest logon also requires a policy to be configured to allow from a network logon https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/accounts-guest-account-status. Potentially the Guest
account requires you using the Guest
username as well but honestly I'm not aware of the full details there.
There's finally an anonymous logon support but IIRC that requires specific flags to be set in NTLM. Like blank password or guest accounts you explicitly need to enable the policy on the Windows host. I also don't know if it's app specific, i.e. SMB enables Anonymous logon or a Windows wide policy.
I think this PR does make sense though, it helps to distinguish between no password provided by empty password and people attempting to use NTLM_USER_FILE
would be very rare. The only part I'm not sure on is for Windows users where the default cache is going to be available by default. It would technically be a change in behaviour if an empty string is now treated as an explicit password vs right now where it uses the credential cache.
Hello!
I have the same issue in my local testing environment. So I'm waiting for the PR too :-)
@jborean93 do you mean something like this:
if password is None:
username = [Password(username=username, password=password)]
I also use empty password in my local development. I use this patch for workaround.
This is a fix for NTLM authentication for user account with no password. We encountered this regression in pywinrm after requests-ntlm was updated to 1.2.0.