Every CVE Search/ Get API key

CVE-2024-21530

Sequential calls of encryption API (`encrypt`, `wrap`, and `dump`) result in nonce reuse

4.5 MediumFix available

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object. Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Attack profile

How easy it is to exploit

Attack vector
Local
Complexity
High
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
Low
Integrity
Low
Availability
None

Exploit likelihood

0.14%Up 0.1 points since Oct 3, 2024
90%50%10%1%

What each source reports

CVE List Score used 4.5

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object. Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
CVE-2024-21530
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N/E:P
Weakness
CWE-323
Updated
2026-11-02
EUVDEUVD-2024-3124 4.5

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object. Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
EUVD-2024-3124
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N/E:P
Updated
2026-11-03
GitHub AdvisoriesGHSA-6878-6wc2-pf5h 4.5

Sequential calls of encryption API (`encrypt`, `wrap`, and `dump`) result in nonce reuse

Problem: Trying to create a new encrypted message with the same cocoon object generates the same ciphertext. It mostly affects MiniCocoon and Cocoon objects with custom seeds and RNGs (where StdRng is used under the hood).

Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Cause: StdRng produces the same nonce because StdRng::clone resets its state.

Measure: Make encryption API mutable (encrypt, wrap, and dump).

Workaround: Create a new cocoon object with a new seed per each encryption.

How to Reproduce

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]

Workaround

For cocoon <= 0.3.3, create a new cocoon with a different seed per each encrypt/wrap/dump call.

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

// Another seed: &[2; 32].
let cocoon = MiniCocoon::from_password(b"password", &[2; 32]);
let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [53, 223, 209, 96, 130, 99, 209, 108, 83, 189, 123, 81, 19, 1]
Record
GHSA-6878-6wc2-pf5h
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Updated
2026-11-02
GitHub AdvisoriesGHSA-r2jw-c95q-rj29 6.3

Duplicate Advisory: cocoon Reuses a Nonce, Key Pair in Encryption

Duplicate Advisory

This advisory has been withdrawn because it is a duplicate of GHSA-6878-6wc2-pf5h. This link is maintained to preserve external references.

Original Description

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object.

Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
GHSA-r2jw-c95q-rj29
CVSS 4.0
6.3 MediumCVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Weakness
CWE-323
Updated
2026-11-02
NVD 4.5

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object. Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
CVE-2024-21530
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Weakness
CWE-323
Updated
2026-11-02
OSV 4.5

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object. Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
CVE-2024-21530
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N/E:P
Weakness
CWE-323
Updated
2026-11-02
OSVGHSA-6878-6wc2-pf5h 4.5

Sequential calls of encryption API (`encrypt`, `wrap`, and `dump`) result in nonce reuse

Problem: Trying to create a new encrypted message with the same cocoon object generates the same ciphertext. It mostly affects MiniCocoon and Cocoon objects with custom seeds and RNGs (where StdRng is used under the hood).

Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Cause: StdRng produces the same nonce because StdRng::clone resets its state.

Measure: Make encryption API mutable (encrypt, wrap, and dump).

Workaround: Create a new cocoon object with a new seed per each encryption.

How to Reproduce

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]

Workaround

For cocoon <= 0.3.3, create a new cocoon with a different seed per each encrypt/wrap/dump call.

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

// Another seed: &[2; 32].
let cocoon = MiniCocoon::from_password(b"password", &[2; 32]);
let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [53, 223, 209, 96, 130, 99, 209, 108, 83, 189, 123, 81, 19, 1]
Record
GHSA-6878-6wc2-pf5h
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Updated
2026-11-02
OSVGHSA-r2jw-c95q-rj29 6.3

Duplicate Advisory: cocoon Reuses a Nonce, Key Pair in Encryption

Duplicate Advisory

This advisory has been withdrawn because it is a duplicate of GHSA-6878-6wc2-pf5h. This link is maintained to preserve external references.

Original Description

Versions of the package cocoon before 0.4.0 are vulnerable to Reusing a Nonce, Key Pair in Encryption when the encrypt, wrap, and dump functions are sequentially called. An attacker can generate the same ciphertext by creating a new encrypted message with the same cocoon object.

Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Record
GHSA-r2jw-c95q-rj29
CVSS 4.0
6.3 MediumCVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Weakness
CWE-323
Updated
2026-11-02
OSVRUSTSEC-2023-0068 4.5

Sequential calls of encryption API (`encrypt`, `wrap`, and `dump`) result in nonce reuse

Problem: Trying to create a new encrypted message with the same cocoon object generates the same ciphertext. It mostly affects MiniCocoon and Cocoon objects with custom seeds and RNGs (where StdRng is used under the hood).

Note: The issue does NOT affect objects created with Cocoon::new which utilizes ThreadRng.

Cause: StdRng produces the same nonce because StdRng::clone resets its state.

Measure: Make encryption API mutable (encrypt, wrap, and dump).

Workaround: Create a new cocoon object with a new seed per each encryption.

How to Reproduce

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]

Workaround

For cocoon <= 0.3.3, create a new cocoon with a different seed per each encrypt/wrap/dump call.

let cocoon = MiniCocoon::from_password(b"password", &[1; 32]);
let mut data1 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data1)?;

// Another seed: &[2; 32].
let cocoon = MiniCocoon::from_password(b"password", &[2; 32]);
let mut data2 = "my secret data".to_owned().into_bytes();
let _ = cocoon.encrypt(&mut data2)?;

// data1: [23, 217, 251, 151, 179, 62, 85, 15, 253, 92, 192, 112, 200, 52]
// data2: [53, 223, 209, 96, 130, 99, 209, 108, 83, 189, 123, 81, 19, 1]
Record
RUSTSEC-2023-0068
CVSS 3.1
4.5 MediumCVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
cocoon
crates.io
before 0.4.0
0.4.0
cocoon
crates.io
0.0.0-0 up to 0.4.0
0.4.0

History

History
RecordedChangedSources
affected
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2024-21530 is a medium vulnerability (CVSS 4.5) in Cocoon, published October 15, 2023. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.14%, the 3rd percentile. Fixed in cocoon 0.4.0.

References

Show 5 moreShow less
MoveEnter Open