Bug 2764 - Some Windows username get case-sensitive in sshd
Summary: Some Windows username get case-sensitive in sshd
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 7.2p2
Hardware: All Cygwin on NT/2k/Win7-11
: P1 major
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-25 04:33 AEST by Arvindo
Modified: 2021-04-23 15:11 AEST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arvindo 2017-08-25 04:33:17 AEST
Some windows 2012 users usernames get case-sensitive on Cygwin sshd

Version
Cygwin 2.5.1 and OpenSSH_7.2p2, OpenSSL 1.0.2h 3 May 2016
Some users work with any case username


Example:
Windows Active Directory Username: MyUser
SSH username not working: myUser

Here are the debug log statements

sshd debug log

debug1: KEX done
debug3: receive packet: type 5
debug3: send packet: type 6
debug3: receive packet: type 50
debug1: userauth-request for user myUser service ssh-connection method none
debug1: attempt 0 failures 0
debug2: parse_server_config: config reprocess config len 367
Login name myUser does not match stored username MyUser
Invalid user myUser from 10.175.2.139
input_userauth_request: invalid user myUser
debug2: input_userauth_request: try method none
Failed none for invalid user myUser from 10.175.2.139 port 64504 ssh2
debug3: userauth_finish: failure partial=0 next methods="publickey,password,keyboard-interactive"
debug3: send packet: type 51
debug3: receive packet: type 50
debug1: userauth-request for user myUser service ssh-connection method keyboard-interactive
debug1: attempt 1 failures 0
debug2: input_userauth_request: try method keyboard-interactive
debug1: keyboard-interactive devs 
debug1: auth2_challenge: user=myUser devs=
debug1: kbdint_alloc: devices ''
debug2: auth2_challenge_start: devices 
Failed keyboard-interactive for invalid user myUser from 10.175.2.139 port 64504 ssh2
debug3: userauth_finish: failure partial=0 next methods="publickey,password,keyboard-interactive"
debug3: send packet: type 51
debug3: receive packet: type 50
debug1: userauth-request for user myUser service ssh-connection method password
debug1: attempt 2 failures 1
debug2: input_userauth_request: try method password
Comment 1 Damien Miller 2017-09-08 09:05:20 AEST
What do you mean by "some usernames"? Being written for Unix first and foremost- OpenSSH treats all usernames with case-sensitivity internally, though the underlying operating system might have different rules.
Comment 2 Arvindo 2017-09-11 13:44:42 AEST
(In reply to Damien Miller from comment #1)
> What do you mean by "some usernames"? Being written for Unix first
> and foremost- OpenSSH treats all usernames with case-sensitivity
> internally, though the underlying operating system might have
> different rules.

Damien
Thanks for your response. You are absolutely right, I agree with your response, but we have this installed on windows server. Windows user names are case-insensitive, and we are able login with different username cases most of the time, but some usernames become case sensitive, and openSSH explicitly requires specific username case. This inconsistent behavior is causing us lot of problems. Is there a setting in sshd-config or somewhere where we can specify all usernames to be case-insensitive explicitly?
Comment 3 Jedd 2017-09-25 17:07:29 AEST
Hi Damien,

Thanks for replying. I can't agree with you more. The situation that Arvindo is describing happens in Cygwin installed in Windows. Here's a simple explanation on what we've experienced...

Initially, getpwnam will return the username in the case that it was supplied in e.g. "jediknight" will return "jediknight" or "Jedikight" will return "Jediknight" then several days or weeks after...getpwnam will start returning the username in a specific case e.g. "JEDIknight" which does not match active directory's (AD). If it matches active directory's then all is well since we will just consistently follow the case that was specified there. Weirder still it can change to "JediKnight", my guess is it has something to do with the Windows login but I don't exactly know how it happens. 

The thing is we don't generate "/etc/passwd" since we rely in Cygwin authenticating the user in AD. Although it is one workaround, the problem that we have with that is that if a new user was created by the client they might experience the issue again unless a new passwd is generated. The thing is we wanted to make it simple for them e.g. not generate passwd when they create a user.  

Anyways our idea is to have openssh have a flag to enable/disable username case sensitivity. By default it is case sensitive and it is applied under Cygwin ifdef. 

I created a pull request for you to review.

Thanks a lot!


Regards,

Jedd
Comment 4 Jedd 2017-09-25 17:10:42 AEST
Btw here's the pull request of our proposed feature

https://github.com/openssh/openssh-portable/pull/78
Comment 5 Arvindo 2017-10-24 05:04:43 AEDT
This causing us production issues, as users are unable to login with different username case.
Comment 6 Damien Miller 2018-02-10 16:54:22 AEDT
I don't think we'll add a configuration option for this, as it would need to touch quite a few more places or risk causing configuration-parsing ambiguity that could have security consequences (e.g. "Match user").

Cc'ing Corinna, who is one of the Cygwin developers and who will know much more about what is going on behind getpwnam().
Comment 7 Corinna Vinschen 2018-02-10 22:00:50 AEDT
Testing the username case-insensitive was discussed long ago
and we decided not to do that.  Check commit

https://github.com/openssh/openssh-portable/commit/acc9b29486dfd649dfda474e5c1a03b317449f1c

I don't know what's going on on your machine, but Cygwin does NOT
change usernames willy-nilly.  The username stored in Cygwin is
the one either returned by Windows via the WIn32 function
LookupAccountSidW, or it is the name as stored in /etc/passwd,
should this file exist and /etc/nsswitch.conf allows access
(which is the default).


Corinna
Comment 8 Damien Miller 2019-07-19 22:04:54 AEST
Corinna points out that this was indeed fixed:

In fact we *did* fix it in OpenSSH 8.0 so that usernames as well as groupnames are now matched case-insensitive on Cygwin, here's the list of commits:

  f02afa350afa Revert "[auth.c] On Cygwin, refuse usernames that have
differences in case"
  bed1d4369880 Revert unintended parts of previous commit.
  37638c752041 Cygwin: implement case-insensitive Unicode user and group name
matching
  daa7505aadca Use Cygwin-specific matching only for users+groups.
  a212107bfdf4 Replace alloca with xcalloc.
Comment 9 Damien Miller 2021-04-23 15:11:12 AEST
closing resolved bugs as of 8.6p1 release