-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/crypto: AcceptSecContext always given first outputToken from InitSecContext #43875
Comments
apparently nothing is done with the packet received from the client |
This fixes the case where AcceptSecContext is always called with the first token sent by the client instead of the most recently sent one. Fixes golang/go#43875
Change https://golang.org/cl/286252 mentions this issue: |
Could someone take a look at bodgit's PR? The issue continues to be present in the most recent release of go & x/crypto. |
thanks for the patch and sorry for all the time it took to respond. The patch in principle looks correct. Can you please provide a way to test this patch in a real usage scenario so we can double check it? Thank you! |
I have just open-sourced a portion of the internal project which was the motivation for the bug report in the first place (link) Running the example program currently looks like this: CLIENT g63Q: New Session
CLIENT: SPN: "HOST/0506TZ9SZ2"
CLIENT g63Q: InitSecContext("host@0506TZ9SZ2", [0], false): [129] true <nil>
SERVER JYUn: New Session
SERVER JYUn: SPN: "HOST/0506TZ9SZ2"
SERVER JYUn: AcceptSecContext([129]): [339] "" true <nil>
CLIENT g63Q: InitSecContext("host@0506TZ9SZ2", [339], false): [121] true <nil>
SERVER JYUn: AcceptSecContext([129]): [0] "" false negotiate.ServerContext.Update: The token supplied to the function is invalid
SERVER JYUn: DeleteSecContext(): <nil>
CLIENT g63Q: DeleteSecContext(): <nil>
panic: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none gssapi-with-mic], no supported methods remain
goroutine 1 [running]:
main.client({0xc000018630, 0x13}, {0xc00000eae0, 0xa})
C:/Users/jpenn/Downloads/chocolatey-management-master/sshsso/examples/main.go:141 +0x336
main.main()
C:/Users/jpenn/Downloads/chocolatey-management-master/sshsso/examples/main.go:193 +0x125
exit status 2 after updating go.mod to include the line running the program looks like this CLIENT Ar7Z: New Session
CLIENT: SPN: "HOST/0506TZ9SZ2"
CLIENT Ar7Z: InitSecContext("host@0506TZ9SZ2", [0], false): [129] true <nil>
SERVER 7KHT: New Session
SERVER 7KHT: SPN: "HOST/0506TZ9SZ2"
SERVER 7KHT: AcceptSecContext([129]): [339] "" true <nil>
CLIENT Ar7Z: InitSecContext("host@0506TZ9SZ2", [339], false): [121] true <nil>
SERVER 7KHT: GetUsername Error: negotiate.ServerContext.GetUsername: The function requested is not supported
SERVER 7KHT: Falling back to ImpersonateUser
SERVER 7KHT: Username(): "SYSTEM" <nil>
SERVER 7KHT: AcceptSecContext([121]): [29] "SYSTEM" false <nil>
CLIENT Ar7Z: InitSecContext("host@0506TZ9SZ2", [29], false): [0] false <nil>
CLIENT Ar7Z: GetMIC([97]): [16] <nil>
SERVER 7KHT: VerifyMIC([97], [16]): <nil>
AllowLogin(__, "SYSTEM")
&{transport:0xc00033c000 sshConn:{conn:0xc0000a2030 user:NT AUTHORITY\SYSTEM sessionID:[16 80 26 100 49 60 27 198 137 76 127 46 25 55 245 195 243 178 135 17 120 143 98 105 24 155 160 87 44 116 192 125] clientVersion:[83 83 72 45 50 46 48 45 71 111] serverVersion:[83 83 72 45 50 46 48 45 71 111]} mux:<nil>}
TrueUsername: "SYSTEM" ClaimedUsername: "SYSTEM"
SERVER 7KHT: DeleteSecContext(): <nil>
SERVER: New connection from "[fe80::2c45:f331:c01d:f57c%Ethernet]:30845"
CLIENT Ar7Z: DeleteSecContext(): <nil>
Hello NT AUTHORITY\SYSTEM |
@9072997 thank you! |
From what I've seen when using Kerberos, the Acceptor always creates just the one response token, even with mutual auth, so it's more theoretical that this issue could arise. @9072997 I noticed your example code is using the negotiate SSPI package; I'm fairly sure if you try and use that against something like OpenSSH it won't interoperate, (I think RFC 4462 section 7.3 applies here), which is why I ended up sending the SSPI maintainer a PR to add support for the additional Kerberos SSP package. I guess it's fine if you control both ends of the SSH connection though, and obviously it's helpful here to illustrate the bug. Just thought I'd mention it as an FYI! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe 1.15.7 to be the latest release, so yes?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
See this program.
This is a dumb and broken implementation of
GSSAPIServer
andGSSAPIClient
for use with crypto/ssh, but it exposes what I think is a bug. As I understand it,InitSecContext
andAcceptSecContext
should be called back-and-forth, each being given theoutputToken
of the other. This does not appear to be what is happening. Instead it looks likeAcceptSecContext
is always given the firstoutputToken
returned byInitSecContext
.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: