{"id":"CVE-2021-4239","aliases":["CVE-2021-4239","GHSA-6cr6-fmvc-vw2p","GHSA-g9mp-8g3h-3c5c","GO-2022-0425"],"related":[],"kind":"vulnerability","state":"published","title":"Weak encryption and denial of service in github.com/flynn/noise","summary":"The Noise protocol implementation suffers from weakened cryptographic security after encrypting 2^64 messages, and a potential denial of service attack. After 2^64 (~18.4 quintillion) messages are encrypted with the Encrypt function, the nonce counter will wrap around, causing multiple messages to be encrypted with the same key and nonce. In a separate issue, the Decrypt function increments the nonce state even when it fails to decrypt a message. If an attacker can provide an invalid input to the Decrypt function, this will cause the nonce state to desynchronize between the peers, resulting in a failure to encrypt all subsequent messages.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"The Noise protocol implementation suffers from weakened cryptographic security after encrypting 2^64 messages, and a potential denial of service attack. After 2^64 (~18.4 quintillion) messages are encrypted with the Encrypt function, the nonce counter will wrap around, causing multiple messages to be encrypted with the same key and nonce. In a separate issue, the Decrypt function increments the nonce state even when it fails to decrypt a message. If an attacker can provide an invalid input to the Decrypt function, this will cause the nonce state to desynchronize between the peers, resulting in a failure to encrypt all subsequent messages.","source":"cvelist"},{"lang":"en","text":"Noise is a Go implementation of the Noise Protocol Framework. The Noise protocol implementation suffers from weakened cryptographic security after encrypting 2^64 messages, and a potential denial of service attack. After 2^64 (~18.4 quintillion) messages are encrypted with the Encrypt function, the nonce counter will wrap around, causing multiple messages to be encrypted with the same key and nonce. In a separate issue, the Decrypt function increments the nonce state even when it fails to decrypt a message. If an attacker can provide an invalid input to the Decrypt function, this will cause the nonce state to desynchronize between the peers, resulting in a failure to encrypt all subsequent messages.","format":"markdown","source":"ghsa"},{"lang":"en","text":"The Go package `github.com/flynn/noise`, a [Noise Protocol](https://noiseprotocol.org/) implementation, has two bugs in nonce handling in versions prior to v1.0.0.\n\n### Issue 1: Potential nonce overflow\n\nIf 2<sup>64</sup> (~18.4 quintillion) or more messages are encrypted with `Encrypt` after handshaking, the nonce counter will wrap around, causing multiple messages to be encrypted with the same key and nonce, resulting in a potentially catastrophic weakening of the security properties of the symmetric cipher.\n\nThis has been resolved in the patched version by returning `ErrMaxNonce` from the `CipherState` `Encrypt` and `Decrypt` methods before the reserved maximum nonce is reached. If this error is encountered, the program should handshake again to start with a fresh `CipherState`.\n\n### Issue 2: Potential denial of service via invalid ciphertext\n\nIf an attacker sends an invalid ciphertext into one peer's `Decrypt`, the nonce is incremented unconditionally. This causes a desync of the `CipherState` due to a nonce mismatch between the peers, resulting in a failure to decrypt all subsequent messages. A new handshake will be required to establish a new `CipherState`.\n\nThis has been resolved in the patched version by returning authentication errors from `Decrypt` before incrementing the nonce. \n\n### Patches\n\nFixed in https://github.com/flynn/noise/pull/44, tagged as v1.0.0.\n\n### Acknowledgements\n\nThese issues were discovered during [an audit](https://www.bamsoftware.com/software/dnstt/cure53-turbotunnel-2021.pdf) of a user of this package ([dnstt](https://www.bamsoftware.com/software/dnstt/)). Thanks to UC Berkley for commissioning the audit, and to David Fifield and Nathan Brown for their collaboration on the fixes. The fixed issues are noted in the audit as:\n\n* UCB-02-003 Potential nonce overflow in Noise protocol\n* UCB-02-006 DoS due to unconditional nonce increment","format":"markdown","source":"ghsa"},{"lang":"es","text":"La implementación del protocolo Noise sufre de seguridad criptográfica debilitada después de cifrar 2^64 mensajes y un posible ataque de denegación de servicio. Después de cifrar 2^64 (~18,4 quintillones) de mensajes con la función Encrypt , el contador nonce se ajustará, lo que provocará que se cifren varios mensajes con la misma clave y nonce. En un tema aparte, la función Decrypt incrementa el estado nonce incluso cuando no logra descifrar un mensaje. Si un atacante puede proporcionar una entrada no válida a la función Decrypt, esto hará que el estado nonce se desincronice entre los pares, lo que resultará en un fallo al cifrar todos los mensajes posteriores.","source":"nvd"}],"published":"2022-02-15T01:57:18.000Z","modified":"2026-06-17T04:19:19.820Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:H","score":7.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"rating","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-311"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"1.0.0","status":"affected"}],"vendor":"github.com/flynn/noise","product":"github.com/flynn/noise","package":"github.com/flynn/noise","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"Go","package":"github.com/flynn/noise","purl":"pkg:golang/github.com/flynn/noise","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"Go","package":"github.com/flynn/noise","purl":"pkg:golang/github.com/flynn/noise","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"Go","package":"github.com/flynn/noise","purl":"pkg:golang/github.com/flynn/noise","source":"go"},{"ranges":[],"vendor":"noiseprotocol","product":"noise","cpe":"cpe:2.3:a:noiseprotocol:noise:-:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/flynn/noise/pull/44","tags":["fix","patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://pkg.go.dev/vuln/GO-2022-0425","tags":["patch","vendor-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4239","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/flynn/noise/commit/2499bf1bad239a8316c32932a993642350b3afdb","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/flynn/noise","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/flynn/noise/security/advisories/GHSA-g9mp-8g3h-3c5c","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"Go","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2025-04-14T16:59:11.062Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-4239","url":"https://www.cve.org/CVERecord?id=CVE-2021-4239","licence":"CVE Terms of Use","modified":"2025-04-14T16:59:43.688Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6cr6-fmvc-vw2p","url":"https://github.com/advisories/GHSA-6cr6-fmvc-vw2p","licence":"CC-BY-4.0","modified":"2023-11-08T04:07:06.025Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g9mp-8g3h-3c5c","url":"https://github.com/advisories/GHSA-g9mp-8g3h-3c5c","licence":"CC-BY-4.0","modified":"2023-11-08T04:07:06.025Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2022-0425","url":"https://pkg.go.dev/vuln/GO-2022-0425","licence":"CC-BY-4.0","modified":"2024-05-20T16:03:47.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-4239","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4239","licence":"Public domain","modified":"2026-06-17T04:19:19.820Z"}],"updatedAt":"2026-11-25T22:58:08.021Z","epss":{"score":0.00378,"percentile":0.33845,"date":"2026-12-01T12:00:22.000Z"}}