Skip to content
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/ssh: ssh client hangs on waitting for the openConfirm message. #50604

Open
ChiWu-Zero opened this issue Jan 14, 2022 · 2 comments
Open

x/crypto/ssh: ssh client hangs on waitting for the openConfirm message. #50604

ChiWu-Zero opened this issue Jan 14, 2022 · 2 comments
Labels
NeedsInvestigation
Milestone

Comments

@ChiWu-Zero
Copy link

@ChiWu-Zero ChiWu-Zero commented Jan 14, 2022

  • overview

The hang problem arises when using the library, the ssh client key code in file ssh/mux.go:

open := channelOpenMsg{
	ChanType:         chanType,
	PeersWindow:      ch.myWindow,
	MaxPacketSize:    ch.maxIncomingPayload,
	TypeSpecificData: extra,
	PeersID:          ch.localId,
}
if err := m.sendMessage(open); err != nil {
	return nil, err
}

switch msg := (<-ch.msg).(type) {
case *channelOpenConfirmMsg:
	return ch, nil
case *channelOpenFailureMsg:
	return nil, &OpenChannelError{msg.Reason, msg.Message}
default:
	return nil, fmt.Errorf("ssh: unexpected packet in response to channel open: %T", msg)
}

The process hangs on the line of "switch msg := (<-ch.msg).(type) ",it may loss the OpenConfirm msg because of the sshd server or the net status.
Maybe we should add the timeout when waitting for the confirm msg.

select {
case data := <-ch.msg:
	switch msg := data.(type) {
	case *channelOpenConfirmMsg:
		return ch, nil
	case *channelOpenFailureMsg:
		return nil, &OpenChannelError{msg.Reason, msg.Message}
	default:
		return nil, fmt.Errorf("ssh: unexpected packet in response to channel open: %T", msg)
	}
case <-time.After(aliveTime):
	return nil, fmt.Errorf("ssh: the confirm message maybe lost")
}
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 19, 2022

This doesn't seem to be a proposal, taking it out of the proposal process.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation label Jan 19, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 19, 2022

CC @golang/security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

3 participants