Skip to content

Fix sha1 hash input in GSS Group1 client-side kex completion#2576

Open
bysiber wants to merge 1 commit into
paramiko:mainfrom
bysiber:fix/kex-gss-sha1-bytes
Open

Fix sha1 hash input in GSS Group1 client-side kex completion#2576
bysiber wants to merge 1 commit into
paramiko:mainfrom
bysiber:fix/kex-gss-sha1-bytes

Conversation

@bysiber

@bysiber bysiber commented Feb 20, 2026

Copy link
Copy Markdown

Summary

Fix KexGSSGroup1._parse_kexgss_complete() to hash the exchange message bytes instead of its repr string.

Problem

The client-side handler for SSH_MSG_KEXGSS_COMPLETE in KexGSSGroup1 computes the exchange hash as:

H = sha1(str(hm)).digest()

hm is a Message object (a BytesIO subclass). On Python 3, str() on a BytesIO returns its repr string — something like "<_io.BytesIO object at 0x7f...>" — not the actual buffer content. Then sha1() raises TypeError because hashlib.sha1() requires bytes, not str.

The server-side handler in the same class at line 269 already uses the correct form:

H = sha1(hm.asbytes()).digest()

As do both handlers in KexGSSGex (lines 532 and 634).

Impact

GSS-API Group1 key exchange (gss-group1-sha1-*) always fails in client mode on Python 3 with an unhandled TypeError during the kex completion step.

Fix

Replace sha1(str(hm)) with sha1(hm.asbytes()), consistent with every other hash computation in the same file.

_parse_kexgss_complete in KexGSSGroup1 passes str(hm) to sha1(),
but hm is a Message (BytesIO subclass). On Python 3, str() on a
BytesIO returns its repr string, not the buffer content. Then
sha1() raises TypeError because it requires bytes, not str.

The server-side handler in the same class already uses the correct
form: sha1(hm.asbytes()).digest(). Apply the same fix here.
@bysiber bysiber force-pushed the fix/kex-gss-sha1-bytes branch from e4aa777 to 040c190 Compare February 20, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant