GHSA-7p92-x423-vwj6: Github.com/consensys/gnark Plonk Verifier KZG Multi Point Vulnerability

CRITICAL
Published
Advisory Summary

GHSA-7p92-x423-vwj6 is a CRITICAL plonk verifier kzg multi point vulnerability (General Security Weakness) affecting Github.com/consensys/gnark libraries in the Go ecosystem. The issue involves plonk verifier kzg multi point verification. Remediation is available by upgrading affected packages to version 0.9.1.

GHSA-7p92-x423-vwj6 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-7p92-x423-vwj6
Severity CRITICAL
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Github.com/consensys/gnark
Package Ecosystem Go
Published Date
Last Updated

How to Fix GHSA-7p92-x423-vwj6

To remediate this vulnerability, upgrade all affected Github.com/consensys/gnark dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/consensys/gnark fixed: 0.9.1
Upgrade github.com/consensys/gnark to 0.9.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/consensys/gnark

How to Check if You Are Affected

To determine whether your application is affected by GHSA-7p92-x423-vwj6, inspect your project dependencies for Github.com/consensys/gnark:

inspect dependencies for github.com/consensys/gnark

Analyze the terminal output to locate any version of Github.com/consensys/gnark in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Github.com/consensys/gnark, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The vulnerability allows a third party to derive a valid proof from a valid initial tuple {proof, public_inputs}, corresponding to the same public inputs as the initial proof. It is due to a randomness being generated using a small part of the scratch memory describing the state, allowing for degrees of freedom in the transcript. Note that the impact is limited to the PlonK verifier smart contract. ### Patches We still use a hash function on some data to have a pseudo rng, but instead of hashing the first 32 bytes of the state ( ` let random := mod(keccak256(state, 0x20), r_mod)` ) we hash the whole state at this point of the verifier as if it was a Fiat Shamir transcript: ``` mstore(mPtr, mload(add(state, STATE_FOLDED_DIGESTS_X))) mstore(add(mPtr, 0x20), mload(add(state, STATE_FOLDED_DIGESTS_Y))) mstore(add(mPtr, 0x40), calldataload(add(aproof, PROOF_BATCH_OPENING_AT_ZETA_X))) mstore(add(mPtr, 0x60), calldataload(add(aproof, PROOF_BATCH_OPENING_AT_ZETA_Y))) mstore(add(mPtr, 0x80), calldataload(add(aproof, PROOF_GRAND_PRODUCT_COMMITMENT_X))) mstore(add(mPtr, 0xa0), calldataload(add(aproof, PROOF_GRAND_PRODUCT_COMMITMENT_Y))) mstore(add(mPtr, 0xc0), calldataload(add(aproof, PROOF_OPENING_AT_ZETA_OMEGA_X))) mstore(add(mPtr, 0xe0), calldataload(add(aproof, PROOF_OPENING_AT_ZETA_OMEGA_Y))) mstore(add(mPtr, 0x100), mload(add(state, STATE_ZETA))) mstore(add(mPtr, 0x120), mload(add(state, STATE_GAMMA_KZG))) let random := staticcall(gas(), 0x2, mPtr, 0x140, mPtr, 0x20) ``` ### Workarounds In the function `batch_verify_multi_points`, the variable `random` (corresponding to `u` in the paper, step 12 of the [plonk](https://eprint.iacr.org/2019/953.pdf) verification process) should depend on `state_folded_digests_x`, `state_folded_digests_y`, `proof_grand_product_commitment_x`, `proof_grand_product_commitment_y` and `state_zeta` (by hashing those values for instance).

GHSA-7p92-x423-vwj6 Affected Github.com/consensys/gnark Versions

1 component(s)
Fixed Versions:
0.9.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/consensys/gnark
Go
< 0.9.1
0.9.1

References

Frequently Asked Questions

What is GHSA-7p92-x423-vwj6?
GHSA-7p92-x423-vwj6 is a security vulnerability in Github.com/consensys/gnark involving Plonk verifier KZG multi point verification under General Security Weakness.
Which Github.com/consensys/gnark versions are affected?
Affected versions include releases prior to 0.9.1 across affected packages: github.com/consensys/gnark.
What version fixes GHSA-7p92-x423-vwj6?
Upgrading to 0.9.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/consensys/gnark affected?
Yes, github.com/consensys/gnark is affected in releases prior to 0.9.1. Upgrade your dependency to 0.9.1 or later.
What CWE is associated with GHSA-7p92-x423-vwj6?
GHSA-7p92-x423-vwj6 is classified under General Security Weakness.
How can I check Go dependencies for GHSA-7p92-x423-vwj6?
Run the dependency tree command: 'inspect dependencies for github.com/consensys/gnark'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7p92-x423-vwj6",
  "modified" : "2023-10-17T14:24:16Z",
  "published" : "2023-10-17T14:24:16Z",
  "aliases" : [ ],
  "summary" : "Plonk verifier KZG multi point verification",
  "details" : "### Impact\n\nThe vulnerability allows a third party to derive a valid proof from a valid initial tuple {proof, public_inputs}, corresponding to the same public inputs as the initial proof. It is due to a randomness being generated using a small part of the scratch memory describing the state, allowing for degrees of freedom in the transcript.\n\nNote that the impact is limited to the PlonK verifier smart contract.\n\n### Patches\n\nWe still use a hash function on some data to have a pseudo rng, but instead of hashing the first 32 bytes of the state (\n` let random := mod(keccak256(state, 0x20), r_mod)` )\n\nwe hash the whole state at this point of the verifier as if it was a Fiat Shamir transcript:\n```\n        mstore(mPtr, mload(add(state, STATE_FOLDED_DIGESTS_X)))\n        mstore(add(mPtr, 0x20), mload(add(state, STATE_FOLDED_DIGESTS_Y)))\n        mstore(add(mPtr, 0x40), calldataload(add(aproof, PROOF_BATCH_OPENING_AT_ZETA_X)))\n        mstore(add(mPtr, 0x60), calldataload(add(aproof, PROOF_BATCH_OPENING_AT_ZETA_Y)))\n        mstore(add(mPtr, 0x80), calldataload(add(aproof, PROOF_GRAND_PRODUCT_COMMITMENT_X)))\n        mstore(add(mPtr, 0xa0), calldataload(add(aproof, PROOF_GRAND_PRODUCT_COMMITMENT_Y)))\n        mstore(add(mPtr, 0xc0), calldataload(add(aproof, PROOF_OPENING_AT_ZETA_OMEGA_X)))\n        mstore(add(mPtr, 0xe0), calldataload(add(aproof, PROOF_OPENING_AT_ZETA_OMEGA_Y)))\n        mstore(add(mPtr, 0x100), mload(add(state, STATE_ZETA)))\n        mstore(add(mPtr, 0x120), mload(add(state, STATE_GAMMA_KZG)))\n        let random := staticcall(gas(), 0x2, mPtr, 0x140, mPtr, 0x20)\n```\n\n### Workarounds\n\nIn the function `batch_verify_multi_points`, the variable `random` (corresponding to `u` in the paper, step 12 of the [plonk](https://eprint.iacr.org/2019/953.pdf) verification process) should depend on `state_folded_digests_x`, `state_folded_digests_y`, `proof_grand_product_commitment_x`, `proof_grand_product_commitment_y` and `state_zeta` (by hashing those values for instance).\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/consensys/gnark"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Consensys/gnark/security/advisories/GHSA-7p92-x423-vwj6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Consensys/gnark/commit/3421eaa7d544286abf3de8c46282b8d4da6d5da0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Consensys/gnark"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-17T14:24:16Z",
    "nvd_published_at" : null
  }
}