CVE-2021-25902

7.5 HIGH

📋 TL;DR

This vulnerability in the glsl-layout Rust crate allows memory corruption through a double-free condition when a panic occurs during map_array operations. It affects any Rust application using glsl-layout versions before 0.4.0 for GPU shader layout management. Attackers could potentially exploit this to cause crashes or execute arbitrary code.

💻 Affected Systems

Products:
  • glsl-layout Rust crate
Versions: All versions before 0.4.0
Operating Systems: All platforms where Rust applications using glsl-layout run
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects Rust applications that explicitly use the glsl-layout crate for GPU shader layout management. Not all Rust applications are vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if the vulnerable application processes attacker-controlled shader data.

🟠

Likely Case

Application crash or denial of service when processing malformed shader inputs, potentially disrupting GPU-dependent services.

🟢

If Mitigated

Controlled crash with proper panic handling and memory isolation, limiting impact to the affected process only.

🌐 Internet-Facing: MEDIUM - Requires processing attacker-controlled shader data, which is common in web-based graphics applications but not all implementations.
🏢 Internal Only: LOW - Typically requires specialized shader input processing that's less common in internal-only applications.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires triggering a panic in map_array with specific conditions. While unauthenticated exploitation is possible if the application processes external shader data, reliable exploitation requires precise memory manipulation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.4.0

Vendor Advisory: https://rustsec.org/advisories/RUSTSEC-2021-0005.html

Restart Required: Yes

Instructions:

1. Update Cargo.toml to require glsl-layout >= 0.4.0
2. Run 'cargo update glsl-layout'
3. Rebuild and redeploy your application
4. Restart any running services using the updated application

🔧 Temporary Workarounds

Disable panic unwinding

all

Configure Rust to abort on panic instead of unwinding, preventing the double drop condition

Add to Cargo.toml: [profile.release] panic = 'abort'
Add to Cargo.toml: [profile.dev] panic = 'abort'

🧯 If You Can't Patch

  • Isolate the vulnerable application in a container or sandbox to limit potential damage
  • Implement input validation for shader data to prevent triggering the panic condition

🔍 How to Verify

Check if Vulnerable:

Check Cargo.lock or run 'cargo tree | grep glsl-layout' to see if version < 0.4.0 is used

Check Version:

cargo tree | grep glsl-layout

Verify Fix Applied:

Verify glsl-layout >= 0.4.0 appears in Cargo.lock after update

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with panic messages related to glsl-layout or map_array
  • Memory corruption errors in application logs

Network Indicators:

  • Unusual shader data uploads to graphics processing endpoints
  • Increased error rates in GPU-related services

SIEM Query:

source="application_logs" AND ("glsl-layout" OR "map_array" OR "double drop") AND severity=ERROR

🔗 References

📤 Share & Export