From 859421ee09a383ea13cfe3caa00de380ac936ee0 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:17:27 +0800 Subject: [PATCH] fix: handle XShell 8 extended handshake (trailing key name) --- app/xshell.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/xshell.go b/app/xshell.go index 555d15c..473558b 100644 --- a/app/xshell.go +++ b/app/xshell.go @@ -96,8 +96,10 @@ func xshellHandshake(conn net.Conn, cookie string) error { if int(initMsg.Length) != len(cookie) { return fmt.Errorf("xagent: invalid cookie length") } - if int(initMsg.Length) < len(initMsg.Cookie) { - return fmt.Errorf("xagent: invalid message length") + // Newer XShell (8) may append extra data (e.g. a key name) after the cookie + // in the handshake frame; keep only the first Length bytes. + if len(initMsg.Cookie) > int(initMsg.Length) { + initMsg.Cookie = initMsg.Cookie[:initMsg.Length] } cookieRemain := make([]byte, int(initMsg.Length)-len(initMsg.Cookie))