{"id":"GO-2025-4087","revision":null,"records":[{"revision":"f8304456bef7461d85864d903db3a9a4","observedAt":"2026-10-24T13:19:41.952+00:00","statement":{"source":"osv","id":"GHSA-fj2x-735w-74vq","aliases":["GO-2025-4087"],"title":"gnark-crypto allows unchecked memory allocation during vector deserialization","description":"The issue has been reported by @raefko from @fuzzinglabs. Excerpts from the report:\n> A critical vulnerability exists in the gnark-crypto library's\u00A0`Vector.ReadFrom()`\u00A0function that allows an attacker to trigger arbitrary memory allocation by crafting malicious input data. An attacker can cause the verifier to attempt allocating up to 128 GB of memory with a minimal malicious input, leading to out-of-memory crashes and denial of service.\n> ### **Root Cause**\n> \n> \n> The vulnerability stems from\u00A0**unchecked deserialization**\u00A0of attacker-controlled length fields in the gnark-crypto library's\u00A0`Vector.ReadFrom()`\u00A0function. The function reads a 4-byte unsigned integer from untrusted input and directly uses it to allocate memory without any validation or bounds checking.\n> \n> ### **Vulnerable Code Path**\n> \n> ```\n> User Input (Malicious Proof/Data)\n>          ↓\n> gnark Proof/Data Deserialization\n>          ↓\n> Vector.ReadFrom() (ecc/bn254/fr/vector.go:136-144)\n>   → sliceLen := binary.BigEndian.Uint32(buf[:4])   // ← ATTACKER-CONTROLLED\n>   → (*vector) = make(Vector, sliceLen)             // ← UNCHECKED ALLOCATION\n>          ↓\n> runtime.makeslice attempts 100+ GB allocation\n>          ↓\n> fatal error: runtime: out of memory → SIGABRT\n> \n> ```\n>\n> ### **Vulnerable Code**\n> \n> **File**:\u00A0[`gnark-crypto@v0.14.0+/ecc/bn254/fr/vector.go:136-144`](https://github.com/Consensys/gnark-crypto/blob/8310aae2de6104d3fe3610e3370b2bed10c63111/ecc/bn254/fr/vector.go#L136)\n> \n> The code reads a 4-byte big-endian unsigned integer (`sliceLen`) directly from the input stream and uses it to allocate a slice without any bounds checking or validation. Each element is 32 bytes (fr.Element for BN254 curve), so an attacker can request up to:\n> \n> **Maximum Allocation**:\u00A0`2^32 elements × 32 bytes = 137,438,953,472 bytes ≈ 128 GB`\n> \n> ## **Root Cause Analysis**\n> \n> The gnark-crypto library implements a generic serialization format for field element vectors. The format is:\n> \n> ```\n> [4 bytes: length (n)] [n × 32 bytes: elements]\n> ```\n> \n> The deserialization code\u00A0**trusts**\u00A0the length field implicitly without any validation. This is a classic\u00A0**integer-to-allocation vulnerability**\u00A0pattern, similar to issues that have affected many serialization libraries over the years.\n\n### Impact\n\nThe issue impacts users deserializing vectors directly from untrusted sources. In case of malicious input it would lead to OOM in case the server doesn't have sufficient memory (depending on the field, but could allocate from 32GB to 196GB).\n\n### Patches\n\nThe issue is patched in https://github.com/Consensys/gnark-crypto/pull/759. It will be backported to gnark-crypto v0.18 and v0.19.\n\n### Workarounds\n\nThe user could manually peek into the first 4 bytes of the serialized data to estimate if the header would allocate large amounts of memory.","state":0,"publishedAt":"2025-10-30T17:10:40+00:00","modifiedAt":"2026-09-10T03:50:29.7340089+00:00","affected":[{"ecosystem":"Go","name":"github.com/consensys/gnark-crypto","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.9.1"},{"kind":"fixed","version":"0.18.1"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"Go","name":"github.com/consensys/gnark-crypto","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.19.0"},{"kind":"fixed","version":"0.19.2"}]}],"versions":["0.19.0"],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/Consensys/gnark-crypto/security/advisories/GHSA-fj2x-735w-74vq","https://github.com/Consensys/gnark-crypto/pull/759","https://github.com/Consensys/gnark-crypto/commit/2e7bf9190a0aac896eeec3876c87c77a35661be7","https://github.com/Consensys/gnark-crypto","https://pkg.go.dev/vuln/GO-2025-4087"],"sourceUrl":"https://github.com/advisories/GHSA-fj2x-735w-74vq","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-fj2x-735w-74vq","identifiers":["GHSA-fj2x-735w-74vq","GO-2025-4087"]},"retained":false,"historicalAffected":[]},{"revision":"e1322b4b2d984abda92da51e6b2324f6","observedAt":"2026-10-24T13:19:41.952+00:00","statement":{"source":"osv","id":"GO-2025-4087","aliases":["GHSA-fj2x-735w-74vq"],"title":"Unchecked memory allocation during vector deserialization in github.com/consensys/gnark-crypto","description":"Unchecked memory allocation during vector deserialization in github.com/consensys/gnark-crypto","state":0,"publishedAt":"2025-11-05T18:41:07+00:00","modifiedAt":"2026-02-04T03:47:39.892431+00:00","affected":[{"ecosystem":"Go","name":"github.com/consensys/gnark-crypto","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.9.1"},{"kind":"fixed","version":"0.18.1"},{"kind":"introduced","version":"0.19.0"},{"kind":"fixed","version":"0.19.2"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[],"references":["https://github.com/Consensys/gnark-crypto/security/advisories/GHSA-fj2x-735w-74vq","https://github.com/Consensys/gnark-crypto/commit/2e7bf9190a0aac896eeec3876c87c77a35661be7","https://github.com/Consensys/gnark-crypto/pull/759"],"sourceUrl":"https://osv.dev/vulnerability/GO-2025-4087","license":"OSV · upstream source license applies","key":"osv:GO-2025-4087","identifiers":["GO-2025-4087","GHSA-fj2x-735w-74vq"]},"retained":false,"historicalAffected":[]}],"coverage":[{"source":"cisa-kev:global","scope":"Complete CISA KEV catalog; all vendors. Missing entries do not establish absence of exploitation.","generation":"2026-11-17T12:29:10.8384945+00:00","complete":true,"records":1781,"lastAttemptAt":"2026-11-17T12:29:10.8384945+00:00","lastSuccessAt":"2026-11-17T12:29:11.2236009+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:29:11.2236054+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"cve-program","scope":"Official CVE Program baseline and cumulative hourly delta; all vendors, published and rejected records","generation":"cve-30c3da459c38698a15d626d89e52e03e55e19fc45dae0e6d8d723cbf35472cf4-678459b37813f6016b4cd470ae34cbcaf42b54cf7267ac41a13248ada215396c","complete":true,"records":426323,"lastAttemptAt":"2026-11-17T12:26:07.8296975+00:00","lastSuccessAt":"2026-11-17T12:26:07.7388494+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:26:07.8296975+00:00","snapshotPublishedAt":"2026-11-17T12:23:12+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"euvd","scope":"Rolling EUVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global EUVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-8af4d5a35cb74233a1f97aea59ddbb2c","complete":false,"records":13840,"lastAttemptAt":"2026-11-17T12:33:01.5757221+00:00","lastSuccessAt":"2026-11-17T12:33:01.7258069+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:33:01.7258069+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"first-epss:nuget","scope":"FIRST EPSS for explicit CVE aliases in the collected public NuGet archive. Not a global EPSS backfill.","generation":"2026-11-17T12:29:10.8384945+00:00","complete":true,"records":1125,"lastAttemptAt":"2026-11-17T12:29:10.8384945+00:00","lastSuccessAt":"2026-11-17T12:29:11.2244247+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:29:11.2244251+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"nvd","scope":"Rolling NVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global NVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-d15d16b83ad840cfbaa595aa681482cc","complete":true,"records":13853,"lastAttemptAt":"2026-11-17T12:29:12.5430377+00:00","lastSuccessAt":"2026-11-17T11:30:08.713+00:00","error":null,"lastVerifiedAt":"2026-11-17T11:30:08.713+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13890,"expectedIdentifiers":13890,"failedIdentifiers":0},{"source":"osv:Go","scope":"Complete OSV Go ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"go-66941ff4149395c0d1a7082fb2226c4cd21c13f3179212d5083b3970d0d2aa5f","complete":true,"records":9958,"lastAttemptAt":"2026-11-17T12:29:10.3714094+00:00","lastSuccessAt":"2026-11-17T07:28:38.090533+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:29:10.3714094+00:00","snapshotPublishedAt":"2026-11-17T07:18:17+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:NuGet","scope":"Complete OSV NuGet ecosystem archive, including GitHub Advisory Database records; NuGet version matching only","generation":"nuget-f4424d7d4861b1af1404bd15abcb83f295dcd003412a9340ca99dc8200aa148a","complete":true,"records":2014,"lastAttemptAt":"2026-11-17T12:26:08.2189061+00:00","lastSuccessAt":"2026-11-13T19:57:08.2864435+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:26:08.2189061+00:00","snapshotPublishedAt":"2026-11-13T19:33:10+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:crates.io","scope":"Complete OSV crates.io ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"crates.io-5f9b762c8d9707349bf2314d182e55bec21d771dbccab0df7bdffa40d8f89f37","complete":true,"records":3166,"lastAttemptAt":"2026-11-17T12:29:10.7686739+00:00","lastSuccessAt":"2026-11-17T11:30:06.6446748+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:29:10.7686739+00:00","snapshotPublishedAt":"2026-11-17T10:33:20+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:npm","scope":"Complete OSV npm ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"npm-8f22981b5c0ea0f9e8c4f42ec7bb74e29dff690928fe1863462ed663a2f9d451","complete":true,"records":232595,"lastAttemptAt":"2026-11-17T12:29:10.2487266+00:00","lastSuccessAt":"2026-11-17T12:29:08.9627922+00:00","error":null,"lastVerifiedAt":"2026-11-17T12:29:10.2487266+00:00","snapshotPublishedAt":"2026-11-17T11:33:21+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null}]}