Brief Summary: Mesa 3D Graphics Library CVE-2026-40393, Out of Bounds Write via WebGPU Shader Input

A short review of CVE-2026-40393, a high severity out of bounds memory access in Mesa's WebGPU component caused by untrusted shader input controlling alloca size. Affected versions and mitigation guidance are covered.

CVE Analysis

5 min read

ZeroPath CVE Analysis
ZeroPath CVE Analysis

2026-04-12

Brief Summary: Mesa 3D Graphics Library CVE-2026-40393, Out of Bounds Write via WebGPU Shader Input
Experimental AI-Generated Content

This CVE analysis is an experimental publication that is completely AI-generated. The content may contain errors or inaccuracies and is subject to change as more information becomes available. We are continuously refining our process.

If you have feedback, questions, or notice any errors, please reach out to us.

[email protected]

Introduction

A memory corruption flaw in Mesa's WebGPU shader compiler allows a remote attacker to trigger an out of bounds write simply by serving a crafted web page to a Linux user. Because Mesa is the default graphics driver stack on virtually every Linux distribution, this vulnerability quietly affects a massive installed base of desktops, workstations, and embedded devices running browsers with WebGPU support.

Technical Information

Root Cause

The vulnerability resides in Mesa's NIR (New Intermediate Representation) compiler, specifically in how it handles function calls and memory allocation for shader processing. In affected versions, the number of fields used to determine the size of a stack allocation originates directly from the shader itself. Since shaders processed via WebGPU come from untrusted web content, this means an attacker controlled value dictates how much memory is allocated via alloca.

The alloca function allocates memory on the stack rather than the heap. When a shader provides a sufficiently large field count, the resulting alloca call overflows the stack frame, producing out of bounds memory access. The weakness is classified as CWE 787 (Out of bounds Write), reflecting the nature of the memory corruption.

This flaw was inadvertently introduced during a rework of function calls in commit c11833ab. The fix, implemented in commit 9017d37e, replaced the use of NIR_VLA (a variable length array macro) with STACK_ARRAY, which provides safe bounds on the allocation size.

Attack Flow

The attack scenario is straightforward and requires no authentication or special privileges:

  1. An attacker crafts a WebGPU shader containing an excessively large field count value.
  2. The attacker hosts this shader on a malicious web page or injects it into a compromised site.
  3. A victim on a Linux system with a vulnerable Mesa version navigates to the page using a browser with WebGPU enabled.
  4. The browser passes the shader to Mesa's NIR compiler for processing.
  5. The compiler reads the attacker controlled field count and uses it as the size argument for an alloca call.
  6. The oversized stack allocation results in out of bounds memory access, potentially allowing the attacker to corrupt adjacent stack memory.

The CVSS 3.1 base score of 8.1 (High) reflects the remote exploitability through the browser and the potential for significant impact through memory corruption.

Affected Systems and Versions

The following Mesa versions are affected:

Product LineVulnerable VersionsFixed VersionRelease Date
Mesa 25.xAll versions before 25.3.625.3.6February 19, 2026
Mesa 26.x26.0.026.0.1February 25, 2026

Any Linux distribution or embedded platform (including ChromeOS) shipping these Mesa versions with a WebGPU capable browser is potentially affected. Organizations should verify the exact Mesa version installed on their systems and confirm that downstream distribution packages have integrated the fix.

Vendor Security History

Mesa is a foundational open source project hosted by freedesktop.org, providing OpenGL, Vulkan, and now WebGPU implementations for Linux. Given its role as the primary GPU driver stack across desktop Linux, Wayland compositors, and embedded platforms like ChromeOS, it represents a high value target. The Mesa project maintains an active release calendar and demonstrated a rapid response to this disclosure, shipping fixes within weeks of the report. ChromeOS has already cherry picked the relevant commit to secure its environment.

References

Detect & fix
what others miss

Security magnifying glass visualization