Skip to content

Commit f91f7a7

Browse files
thatnealpatelgopherbot
authored andcommitted
ssh/agent: prevent panic on malformed constraint
An attacker could supply a malformed Constraint that would trigger a panic in a serving agent, effectively causing denial of service. Thank you to Jakub Ciolek for reporting this issue. Fixes CVE-2025-47914 Fixes golang/go#76364 Change-Id: I195bbc68b1560d4f04897722a6a653a7cbf086eb Reviewed-on: https://go-review.googlesource.com/c/crypto/+/721960 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Roland Shoemaker <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent 2df4153 commit f91f7a7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ssh/agent/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func parseConstraints(constraints []byte) (lifetimeSecs uint32, confirmBeforeUse
203203
for len(constraints) != 0 {
204204
switch constraints[0] {
205205
case agentConstrainLifetime:
206+
if len(constraints) < 5 {
207+
return 0, false, nil, io.ErrUnexpectedEOF
208+
}
206209
lifetimeSecs = binary.BigEndian.Uint32(constraints[1:5])
207210
constraints = constraints[5:]
208211
case agentConstrainConfirm:

ssh/agent/server_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto"
99
"crypto/rand"
1010
"fmt"
11+
"io"
1112
pseudorand "math/rand"
1213
"reflect"
1314
"strings"
@@ -258,6 +259,12 @@ func TestParseConstraints(t *testing.T) {
258259
t.Errorf("got extension %v, want %v", extensions, expect)
259260
}
260261

262+
// Test Malformed Constraint
263+
_, _, _, err = parseConstraints([]byte{1})
264+
if err != io.ErrUnexpectedEOF {
265+
t.Errorf("got %v, want %v", err, io.ErrUnexpectedEOF)
266+
}
267+
261268
// Test Unknown Constraint
262269
_, _, _, err = parseConstraints([]byte{128})
263270
if err == nil || !strings.Contains(err.Error(), "unknown constraint") {

0 commit comments

Comments
 (0)