Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…
EPSS 0.0%top 94%

CVE-2026-41197: CWE-131: Incorrect Calculation of Buffer Size in noir-lang noir

0
Critical
VulnerabilityCVE-2026-41197cvecve-2026-41197cwe-131
Published: Thu Apr 23 2026 (04/23/2026, 00:35:37 UTC)
Source: CVE Database V5
Vendor/Project: noir-lang
Product: noir

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.

CVSS v4.0

Score 9.3critical

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vuln. Confidentiality
High
Vuln. Integrity
High
Vuln. Availability
High
Subsq. Confidentiality
None
Subsq. Integrity
None
Subsq. Availability
None
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

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 04/30/2026, 08:04:31 UTC

Technical Analysis

Noir-lang's noir compiler incorrectly calculates the memory allocation size for nested arrays returned by foreign function calls when compiling to Brillig bytecode. The bug arises because the allocation function uses the semantic length of nested arrays instead of the semi-flattened size that accounts for composite element types consuming multiple memory slots. This under-allocation causes heap corruption in the Brillig VM when nested arrays of tuples or other composite types are returned. The vulnerability is tracked as CWE-131 (Incorrect Calculation of Buffer Size) and has a CVSS 4.0 score of 9.3, indicating critical severity. The issue is resolved in noir version 1.0.0-beta.19.

Potential Impact

Heap corruption in the Brillig VM can occur when foreign calls return nested arrays of composite types due to under-allocation of memory. This can lead to undefined behavior, potential crashes, or other memory safety issues within the noir-lang environment. The vulnerability is exploitable remotely without authentication and requires no user interaction, increasing its risk.

Mitigation Recommendations

Upgrade noir-lang noir to version 1.0.0-beta.19 or later, where this buffer size calculation bug is fixed. No other mitigations are indicated. Patch status is not explicitly stated in the vendor advisory, but the fix is included in the specified version.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2026-04-18T02:51:52.973Z
Cvss Version
4.0
State
PUBLISHED
Remediation Level
null

Threat ID: 69e9707c87115cfb68522138

Added to database: 4/23/2026, 1:06:04 AM

Last enriched: 4/30/2026, 8:04:31 AM

Last updated: 6/6/2026, 12:37:30 PM

Views: 131

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses