# CVE-2026-41197: Brillig: Heap corruption in foreign call results with nested tuple arrays

- Severity: Critical 9.3 (CVSS:4.0, scored by GitHub_M) `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.41%, higher than 37% of CVEs (2026-12-01)
- Published: 2026-04-21T20:16:09.000Z
- Modified: 2026-06-17T10:46:18.790Z
- Also known as: GHSA-jj7c-x25r-r8r3
- Weaknesses: CWE-131
- SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total
- Assigned by: GitHub_M

## Description

Noir is a Domain Specific Language for SNARK proving systems that is designed to use any ACIR compatible proving system, and Brillig is the bytecode ACIR uses for non-determinism. Noir programs can invoke external functions through foreign calls. When compiling to Brillig bytecode, the SSA instructions are processed block-by-block in `BrilligBlock::compile_block()`. When the compiler encounters an `Instruction::Call` with a `Value::ForeignFunction` target, it invokes `codegen_call()` in `brillig_call/code_gen_call.rs`, which dispatches to `convert_ssa_foreign_call()`. Before emitting the foreign call opcode, the compiler must pre-allocate memory for any array results the call will return. This happens through `allocate_external_call_results()`, which iterates over the result types. For `Type::Array` results, it delegates to `allocate_foreign_call_result_array()` to recursively allocate memory on the heap for nested arrays. The `BrilligArray` struct is the internal representation of a Noir array in Brillig IR. Its `size` field represents the semi-flattened size, the total number of memory slots the array occupies, accounting for the fact that composite types like tuples consume multiple slots per element. This size is computed by `compute_array_length()` in `brillig_block_variables.rs`. For the outer array, `allocate_external_call_results()` correctly uses `define_variable()`, which internally calls `allocate_value_with_type()`. This function applies the formula above, producing the correct semi-flattened size. However, for nested arrays, `allocate_foreign_call_result_array()` contains a bug. The pattern `Type::Array(_, nested_size)` discards the inner types with `_` and uses only `nested_size`, the semantic length of the nested array (the number of logical elements), not the semi-flattened size. For simple element types this works correctly, but for composite element types it under-allocates. Foreign calls returning nested arrays of tuples or other composite types corrupt the Brillig VM heap. Version 1.0.0-beta.19 fixes this issue.

(As written by CVE List.)

## Affected

- noir-lang noir: < 1.0.0-beta.19
- brillig (crates.io): before 1.0.0-beta.19

## Every score

- GitHub_M: CVSS:4.0 9.3 Critical `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`
- GitHub: CVSS:4.0 Critical `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`

## References

- <https://github.com/noir-lang/noir/security/advisories/GHSA-jj7c-x25r-r8r3> (web)
- <https://github.com/noir-lang/noir/releases/tag/v1.0.0-beta.19> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-41197> (advisory)
- <https://github.com/noir-lang/noir> (package)

## Sources

- CVE List: [CVE-2026-41197](https://www.cve.org/CVERecord?id=CVE-2026-41197), CVE Terms of Use, modified 2026-04-25
- GitHub Advisory Database: [GHSA-jj7c-x25r-r8r3](https://github.com/advisories/GHSA-jj7c-x25r-r8r3), CC-BY-4.0, modified 2026-05-05
- NVD: [CVE-2026-41197](https://nvd.nist.gov/vuln/detail/CVE-2026-41197), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2026-41197 · Whole record: https://cve.day/CVE-2026-41197.json · Rebuilt by cve.day 2026-11-25T22:59:19.369Z
