The vulnerability lies in the golang.org/x/crypto/ssh/agent package, where the server component does not properly validate the length of incoming messages when adding a new identity. The analysis of the patch commit f91f7a7c31bf90b39c1de895ad116a2bacc88748 reveals the root cause.
The function agent.parseConstraints is responsible for parsing constraints associated with a new SSH key. One of these constraints, agentConstrainLifetime, is expected to be followed by a 4-byte unsigned integer. The vulnerable code directly attempted to read these 4 bytes (binary.BigEndian.Uint32(constraints[1:5])) without first checking if the input constraints slice was long enough. If an attacker sends a specially crafted message where the constraints slice is shorter than 5 bytes (e.g., just []byte{agentConstrainLifetime}), this operation results in an out-of-bounds read, triggering a panic.
This vulnerable function is called by agent.(*server).serveAgent, which is the main loop handling client requests. When serveAgent receives an agentAddIdentity request, it extracts the constraints from the message and passes them directly to parseConstraints. Therefore, an attacker can trigger the panic by connecting to the SSH agent and sending a malformed 'add identity' request, leading to a denial of service as the agent's request-handling goroutine crashes. The fix was to add a length check in parseConstraints before attempting to read the lifetime value.