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

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** CRITICAL 9.3
- **CVSS:** 9.3 (v4.0, CNA) `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`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Attack requirements: None; Privileges required: None; User interaction: None; Confidentiality impact: High; Integrity impact: High; Availability impact: High; Confidentiality impact on other systems: None; Integrity impact on other systems: None; Availability impact on other systems: None
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.51% (percentile 37, 2026-11-26)
- **CWE:** CWE-131
- **Aliases:** GHSA-jj7c-x25r-r8r3
- **Published:** 2026-04-21T20:16:09.000Z
- **Modified:** 2026-06-17T10:46:18.790Z

## Who should check

- Projects that depend on crates.io package brillig (\< 1.0.0-beta.19)
- Anyone running noir-lang noir \< 1.0.0-beta.19

## 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.

## Affected and fixed versions

- crates.io `brillig`: affected \< 1.0.0-beta.19; fixed 1.0.0-beta.19 (osv)
- noir-lang noir: \< 1.0.0-beta.19 (cvelist)

## Mitigation

- Upgrade brillig to 1.0.0-beta.19 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-41197. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-41197.md
Affected: brillig < 1.0.0-beta.19
Fixed in: 1.0.0-beta.19

Steps:
1. Search this machine and project for brillig (crates.io), noir-lang noir: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-41197 being exploited?

There is no confirmed exploitation: CVE-2026-41197 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.51% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2026-41197?

Critical: CVSS 9.3 (v4.0, scored by CNA). Remote, no login needed.

### Which versions are affected by CVE-2026-41197?

brillig \< 1.0.0-beta.19.

### Is there a fix for CVE-2026-41197?

Yes. Fixed in 1.0.0-beta.19. Upgrade brillig to 1.0.0-beta.19 or later.

### How do I check if I'm affected by CVE-2026-41197?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

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

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-41197>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-jj7c-x25r-r8r3> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2026-41197> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-41197>
