-
Notifications
You must be signed in to change notification settings - Fork 18k
os/user: user.Current() returns wrong user for NT AUTHORITY/SYSTEM #73471
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
Comments
Thanks for reporting, I can reproduce this issue, even not using PsExec but a plain Windows Service. Note that this only reproduces when the logged in user is system service account. If a normal user is specified, then the correct name is returned.
Window's GetUserNameW says that it returns the host name (in your case It looks like that the Windows ecosystem is moving into the hostname+$ direction, so the new behavior might be de desired one. For the record, this behavior change happened in CL 597255. It replaced a really slow and unreliable call to @alexbrainman @golang/windows thoughts? |
Many thanks @qmuntal for the quick investigation. I have to confess not being too familiar with Windows accounts, but chatgpt suggests that these are in fact different accounts (LocalSystem vs Machine Account). It appears they are related, in that LocalSystem can access network resources using the Machine Account, but they are distinct accounts with unique SIDs. |
Can't access the chatgpt prompt.
|
Apologies! Here it is: Excellent question, Pete — these two identities, Let’s break it down clearly: ✅
|
Account | SID | Description |
---|---|---|
NT AUTHORITY\SYSTEM | S-1-5-18 | The LocalSystem account used to run services with full local privilege |
$ | Varies per machine | The machine/computer account used for network authentication |
I don't have an opinion about what to choose here. I am stuck in the past together with
It is actually changed in CL 605135 after some reverts. And you can keep existing code, and just hard code some user names based on the account SIDs (if SIDs are correct). You can also add new tests to the Up to you. Alex |
Go version
go version go1.24.2 windows/amd64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
The output of
whoami
was:nt authority\system
The output of the go program was:
WORKGROUP\pmoore$
.What did you expect to see?
I expected to see output of both
whoami
and the go program to bent authority\system
.The text was updated successfully, but these errors were encountered: