ssh: prevent malformed exit-status panic
A malicious server can crash any client by sending a truncated exit-status payload, which triggers a panic in binary.BigEndian.Uint32. Change-Id: Iff4fe182b40210c99d46562f6c3b5ecf38bb98b4 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/780181 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicola Murino <nicola.murino@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
@@ -423,6 +423,9 @@ func (s *Session) wait(reqs <-chan *Request) error {
|
||||
for msg := range reqs {
|
||||
switch msg.Type {
|
||||
case "exit-status":
|
||||
if len(msg.Payload) < 4 {
|
||||
return errors.New("ssh: malformed exit-status request")
|
||||
}
|
||||
wm.status = int(binary.BigEndian.Uint32(msg.Payload))
|
||||
case "exit-signal":
|
||||
var sigval struct {
|
||||
|
||||
Reference in New Issue
Block a user