# CVE-2024-45040: gnark's commitments to private witnesses in Groth16 as implemented break zero-knowledge property

> Attackers can deduce private witness values in Groth16 proofs if values are small, compromising zero-knowledge privacy in gnark library.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Sep 2024
- **Updated:** 6 Sep 2024
- **Also known as:** GHSA-9xcg-3q8v-7fq6, GO-2024-3123

## What is CVE-2024-45040?

CVE-2024-45040 is a medium-severity vulnerability in Consensys gnark, published on 6 Sep 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. Prior to version 0.11.0, commitments to private witnesses in Groth16 as implemented break the zero-knowledge property. The vulnerability affects only Groth16 proofs with commitments. Notably, PLONK proofs are not affected. The vulnerability affects the zero-knowledge property of the proofs - in case the witness (secret or internal) values are small, then the attacker may be able to enumerate all possible choices to deduce the actual value. If the possible choices for the variables to be committed is large or there are many values committed, then it would be computationally infeasible to enumerate all valid choices. It doesn't affect the completeness/soundness of the proofs. The vulnerability has been fixed in version 0.11.0. The patch to fix the issue is to add additional randomized value to the list of committed value at proving time to mask the rest of the values which were committed. As a workaround, the user can manually commit to a randomized value.

Weakness: CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor)

## Which versions are affected by CVE-2024-45040?

3 open source packages ship an affected version, including github.com/consensys/gnark. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/consensys/gnark` | Go | All versions | 0.11.0 |
| `github.com/consensys/gnark` | Go | All versions | 0.11.0 |
| `github.com/consensys/gnark` | Go | All versions | 0.11.0 |

Products: Consensys Gnark-Crypto.

## How do I fix CVE-2024-45040?

Upgrade github.com/consensys/gnark to 0.11.0 or later.

## Is CVE-2024-45040 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-45040 exists.

## Other vulnerabilities in Consensys gnark

- [CVE-2023-44273](https://insights.sbomify.com/CVE-2023-44273/): Duplicate Advisory: Consensys gnark-crypto allows Signature Malleability (critical 9.8)
- [CVE-2024-45039](https://insights.sbomify.com/CVE-2024-45039/): gnark's Groth16 commitment extension unsound for more than one commitment (medium 6.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-45040 and fix it if it is affected.

What it is: CVE-2024-45040 is a medium-severity vulnerability in Consensys gnark, published on 6 Sep 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-45040 exists.

Affected packages and fixed versions:
- github.com/consensys/gnark (Go): affected all versions; fixed in 0.11.0
- github.com/consensys/gnark (Go): affected all versions; fixed in 0.11.0
- github.com/consensys/gnark (Go): affected all versions; fixed in 0.11.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-45040/ (Markdown: https://insights.sbomify.com/CVE-2024-45040/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-45040
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-45040
- OSV: https://osv.dev/vulnerability/CVE-2024-45040

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-45040/
Summaries are generated and may contain mistakes; the official description above is the record.
