MediumGHSA-45x7-px36-x8w8CVE-2023-48795GO-2023-2402PYSEC-2026-1758

Prefix Truncation Attack against ChaCha20-Poly1305 and Encrypt-then-MAC aka Terrapin

Published 18 Dec 2023 · Updated 10 Sept 2026

Is your project on an affected golang.org/x/crypto?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected packages

Affected
>=0.1.0 <0.17.0
Fixed in
0.17.0
Update to the fixed version for your release line, for example:go get golang.org/x/crypto@v0.17.0
Affected
>=2.5.0 <3.4.0
Fixed in
3.4.0
Update to the fixed version for your release line, for example:pip install 'paramiko>=3.4.0'
Affected
<0.0.0-20231218163308-9d2ee975ef9f
Fixed in
0.0.0-20231218163308-9d2ee975ef9f
Update to the fixed version for your release line, for example:go get golang.org/x/crypto@v0.0.0-20231218163308-9d2ee975ef9f

Details

Summary

Terrapin is a prefix truncation attack targeting the SSH protocol. More precisely, Terrapin breaks the integrity of SSH's secure channel. By carefully adjusting the sequence numbers during the handshake, an attacker can remove an arbitrary amount of messages sent by the client or server at the beginning of the secure channel without the client or server noticing it.

Mitigations

To mitigate this protocol vulnerability, OpenSSH suggested a so-called "strict kex" which alters the SSH handshake to ensure a Man-in-the-Middle attacker cannot introduce unauthenticated messages as well as convey sequence number manipulation across handshakes.

Warning: To take effect, both the client and server must support this countermeasure.

As a stop-gap measure, peers may also (temporarily) disable the affected algorithms and use unaffected alternatives like AES-GCM instead until patches are available.

Details

The SSH specifications of ChaCha20-Poly1305 (chacha20-poly1305@openssh.com) and Encrypt-then-MAC (*-etm@openssh.com MACs) are vulnerable against an arbitrary prefix truncation attack (a.k.a. Terrapin attack). This allows for an extension negotiation downgrade by stripping the SSH_MSG_EXT_INFO sent after the first message after SSH_MSG_NEWKEYS, downgrading security, and disabling attack countermeasures in some versions of OpenSSH. When targeting Encrypt-then-MAC, this attack requires the use of a CBC cipher to be practically exploitable due to the internal workings of the cipher mode. Additionally, this novel attack technique can be used to exploit previously unexploitable implementation flaws in a Man-in-the-Middle scenario.

The attack works by an attacker injecting an arbitrary number of SSH_MSG_IGNORE messages during the initial key exchange and consequently removing the same number of messages just after the initial key exchange has concluded. This is possible due to missing authentication of the excess SSH_MSG_IGNORE messages and the fact that the implicit sequence numbers used within the SSH protocol are only checked after the initial key exchange.

In the case of ChaCha20-Poly1305, the attack is guaranteed to work on every connection as this cipher does not maintain an internal state other than the message's sequence number. In the case of Encrypt-Then-MAC, practical exploitation requires the use of a CBC cipher; while theoretical integrity is broken for all ciphers when using this mode, message processing will fail at the application layer for CTR and stream ciphers.

For more details see https://terrapin-attack.com.

Impact

This attack targets the specification of ChaCha20-Poly1305 (chacha20-poly1305@openssh.com) and Encrypt-then-MAC (*-etm@openssh.com), which are widely adopted by well-known SSH implementations and can be considered de-facto standard. These algorithms can be practically exploited; however, in the case of Encrypt-Then-MAC, we additionally require the use of a CBC cipher. As a consequence, this attack works against all well-behaving SSH implementations supporting either of those algorithms and can be used to downgrade (but not fully strip) connection security in case SSH extension negotiation (RFC8308) is supported. The attack may also enable attackers to exploit certain implementation flaws in a man-in-the-middle (MitM) scenario.

Is GHSA-45x7-px36-x8w8 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected golang.org/x/crypto, and gives you the command that fixes it.

More advisories for golang.org/x/crypto

  • LowCVE-2026-78662Prevent DoS on deadlocked undecided channel in golang.org/x/crypto/ssh · 2 Sept 2026
  • LowCVE-2026-56855Prevent DoS on deadlocked established channel in golang.org/x/crypto/ssh · 2 Sept 2026
  • LowCVE-2026-56854Source-address critical option not enforced for non-public-key auth callbacks in golang.org/x/crypto/ssh · 28 Aug 2026
  • LowGO-2026-5932The golang.org/x/crypto/openpgp package is unmaintained, unsafe by design, and has known security issues · 7 Jul 2026
  • CriticalCVE-2026-46595golang.org/x/crypto: Invoking VerifiedPublicKeyCallback permissions skip enforcement · 25 Jun 2026
  • CriticalCVE-2026-42508golang.org/x/crypto vulnerable to auth bypass via unenforced @revoked status · 25 Jun 2026
All 57 advisories for golang.org/x/crypto

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.