{"id":"CVE-2021-4239","aliases":["EUVD-2022-7529","GHSA-6cr6-fmvc-vw2p","GHSA-g9mp-8g3h-3c5c","GO-2022-0425","UBUNTU-CVE-2021-4239"],"status":"published","title":"Weak encryption and denial of service in github.com/flynn/noise","description":"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.","severity":{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-08","score":0.00378,"percentile":0.32003,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-311"],"published":"2022-02-15T01:57:18Z","modified":"2026-10-17T12:56:16Z","fixes":[{"ecosystem":"Go","package":"github.com/flynn/noise","fixed_in":["1.0.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"Go","package":"github.com/flynn/noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.0.0"}]}]},{"source":"ghsa","ecosystem":"Go","package":"github.com/flynn/noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.0.0"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/flynn/noise","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.0"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/flynn/noise","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.0"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/flynn/noise","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.0"}]}]},{"source":"osv","ecosystem":"Ubuntu:22.04:LTS","package":"golang-github-flynn-noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.0.0-2"]},{"source":"osv","ecosystem":"Ubuntu:24.04:LTS","package":"golang-github-flynn-noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.0.0-2"]},{"source":"osv","ecosystem":"Ubuntu:25.10","package":"golang-github-flynn-noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.1.0-1"]},{"source":"osv","ecosystem":"Ubuntu:26.10","package":"golang-github-flynn-noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.1.0-1"]},{"source":"osv","ecosystem":"Ubuntu:26.04:LTS","package":"golang-github-flynn-noise","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.1.0-1"]}],"products":[{"vendor":"github.com/flynn/noise","product":"github.com/flynn/noise"},{"vendor":"noiseprotocol","product":"noise"}],"references":[{"url":"https://github.com/flynn/noise/pull/44","tags":["x_transferred","Patch","Third Party Advisory","web","fix","report"]},{"url":"https://pkg.go.dev/vuln/GO-2022-0425","tags":["x_transferred","Patch","Vendor Advisory","web","report"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4239","tags":["advisory"]},{"url":"https://github.com/flynn/noise/commit/2499bf1bad239a8316c32932a993642350b3afdb","tags":["web"]},{"url":"https://github.com/advisories/GHSA-6cr6-fmvc-vw2p"},{"url":"https://github.com/flynn/noise/security/advisories/GHSA-g9mp-8g3h-3c5c","tags":["web"]},{"url":"https://github.com/advisories/GHSA-g9mp-8g3h-3c5c"},{"url":"https://github.com/flynn/noise","tags":["package"]},{"url":"https://ubuntu.com/security/CVE-2021-4239","tags":["report"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2021-4239","tags":["report"]}],"sources":{"cve":[{"id":"CVE-2021-4239","title":"Weak encryption and denial of service in github.com/flynn/noise","description":"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.","status":"published","published":"2022-12-27T21:13:53.59Z","modified":"2025-04-14T16:59:43.688Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"adp"}],"updated_at":"2026-11-02T14:33:08.045407Z"}],"euvd":[{"id":"EUVD-2022-7529","description":"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.","status":"published","published":"2022-12-27T21:13:53Z","modified":"2025-04-14T16:59:43Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"updated_at":"2026-11-02T20:52:33.465211Z"}],"ghsa":[{"id":"GHSA-6cr6-fmvc-vw2p","title":"Noise vulnerable to denial of service","description":"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.","status":"published","published":"2022-12-28T00:30:23Z","modified":"2023-02-09T21:41:25Z","cvss":[{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:H","level":"high"}],"cwes":["CWE-311"],"updated_at":"2026-11-02T14:36:44.81167Z"},{"id":"GHSA-g9mp-8g3h-3c5c","title":"flynn/noise has improper nonce handling yielding potential state DoS","description":"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\u003csup\u003e64\u003c/sup\u003e (~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","status":"published","published":"2022-02-15T01:57:18Z","modified":"2023-08-29T20:07:15Z","updated_at":"2026-11-02T14:37:01.345964Z"}],"nvd":[{"id":"CVE-2021-4239","description":"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.","status":"published","published":"2022-12-27T22:15:12.123Z","modified":"2026-06-17T04:19:19.82Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"primary"},{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"secondary"}],"cwes":["CWE-311"],"updated_at":"2026-11-02T14:07:07.323379Z"}],"osv":[{"id":"GHSA-6cr6-fmvc-vw2p","title":"Noise vulnerable to denial of service","description":"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.","status":"published","published":"2022-12-28T00:30:23Z","modified":"2023-11-08T04:07:06.025033Z","cvss":[{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:H","level":"high"}],"cwes":["CWE-311"],"updated_at":"2026-11-02T15:46:39.618611Z"},{"id":"UBUNTU-CVE-2021-4239","description":"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.","status":"published","published":"2022-12-27T22:15:00Z","modified":"2026-10-17T12:56:16.017662829Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"},{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"updated_at":"2026-11-02T15:54:29.220315Z"},{"id":"GHSA-g9mp-8g3h-3c5c","title":"flynn/noise has improper nonce handling yielding potential state DoS","description":"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\u003csup\u003e64\u003c/sup\u003e (~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","status":"published","published":"2022-02-15T01:57:18Z","modified":"2023-11-08T04:07:06.025033Z","updated_at":"2026-11-02T15:46:47.472172Z"},{"id":"GO-2022-0425","title":"Weak encryption and denial of service in github.com/flynn/noise","description":"The Noise protocol implementation suffers from weakened cryptographic security after encrypting 2^64 messages, and a potential denial of service attack.\n\nAfter 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.\n\nIn 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.","status":"published","published":"2022-02-15T01:57:18Z","modified":"2024-05-20T16:03:47Z","updated_at":"2026-11-02T15:47:00.918515Z"}]}}
