Skip to content

Skip MAC negotiation when an AEAD cipher is selected - #2722

Open
yahavsass wants to merge 1 commit into
paramiko:mainfrom
yahavsass:fix-aead-no-mac-negotiation
Open

yahavsass wants to merge 1 commit into
paramiko:mainfrom
yahavsass:fix-aead-no-mac-negotiation

Conversation

@yahavsass

Copy link
Copy Markdown

Transport._parse_kex_init raised IncompatiblePeer ("no acceptable macs") whenever the two sides' MAC lists had no overlap, even when the negotiated cipher is an AEAD (aes*[email protected]). AEAD ciphers authenticate packets themselves, and draft-miller-sshm-aes-gcm (the rules OpenSSH and others use in place of RFC 5647's) says MAC negotiation MUST be skipped in that case and that failing to agree on a MAC MUST NOT cause connection failure. Peers sending an empty MAC list alongside AES-GCM were therefore unreachable.

Only require an agreed MAC, per direction, when that direction's cipher is not AEAD, and stop looking up MAC parameters for AEAD ciphers when activating the inbound/outbound cipher (the MAC may now be unset).

Non-AEAD ciphers still fail without a shared MAC; a test covers this.

Fixes #2491.

Additional information:
AEAD ciphers (aes*[email protected]) authenticate packets themselves, so a
separate MAC isn't needed. Per draft-miller-sshm-aes-gcm, when an AEAD cipher
is selected "MAC negotiation MUST be skipped" and failing to agree on a MAC
"MUST NOT cause connection failure". Paramiko instead raised IncompatiblePeer
("no acceptable macs") for peers that send an empty/disjoint MAC list.

References:

Non-AEAD ciphers still require a shared MAC; there's a test for that.

Transport._parse_kex_init raised IncompatiblePeer ("no acceptable macs")
whenever the two sides' MAC lists had no overlap, even when the negotiated
cipher is an AEAD (aes*[email protected]). AEAD ciphers authenticate packets
themselves, and draft-miller-sshm-aes-gcm (the rules OpenSSH and others use
in place of RFC 5647's) says MAC negotiation MUST be skipped in that case
and that failing to agree on a MAC MUST NOT cause connection failure. Peers
sending an empty MAC list alongside AES-GCM were therefore unreachable.

Only require an agreed MAC, per direction, when that direction's cipher is
not AEAD, and stop looking up MAC parameters for AEAD ciphers when
activating the inbound/outbound cipher (the MAC may now be unset).

Non-AEAD ciphers still fail without a shared MAC; a test covers this.

Fixes paramiko#2491.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KEznjXd8oFYDG6RiwXtZuE
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.

[BUG] - Exception "Incompatible ssh server (no acceptable mac)" with cipher [email protected] when server sends empty list of MAC algos

1 participant