CVE-2021-30456

9.8 CRITICAL

📋 TL;DR

This vulnerability in the id-map Rust crate allows double-free memory corruption when a user-provided function panics during get_or_insert operations. Attackers could exploit this to execute arbitrary code or cause denial of service. Any Rust application using vulnerable versions of the id-map crate is affected.

💻 Affected Systems

Products:
  • id-map Rust crate
Versions: All versions through 2021-02-26
Operating Systems: All platforms running Rust applications
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects Rust applications that use the id-map crate and call get_or_insert with user-provided functions that can panic.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or ransomware deployment.

🟠

Likely Case

Application crash or denial of service due to memory corruption, potentially leading to data loss.

🟢

If Mitigated

Limited impact with proper memory safety controls and exploit mitigations like ASLR and stack canaries.

🌐 Internet-Facing: HIGH - Exploitable remotely if the vulnerable code handles untrusted input.
🏢 Internal Only: MEDIUM - Requires attacker access to internal systems or user interaction.

🎯 Exploit Status

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

Exploitation requires triggering a panic in user-provided function, which may be controllable via crafted input.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: id-map 0.4.0

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

Restart Required: Yes

Instructions:

1. Update Cargo.toml to require id-map >= 0.4.0. 2. Run 'cargo update' to fetch the fixed version. 3. Rebuild and redeploy your application.

🔧 Temporary Workarounds

Avoid panic-prone functions

all

Modify code to avoid using user-provided functions that can panic with get_or_insert.

Use catch_unwind

all

Wrap calls to get_or_insert with std::panic::catch_unwind to prevent panics from propagating.

🧯 If You Can't Patch

  • Isolate affected applications in containers or VMs with minimal privileges.
  • Implement strict input validation to prevent triggering panic conditions.

🔍 How to Verify

Check if Vulnerable:

Check Cargo.lock for id-map version <= 0.3.0 or run 'cargo tree | grep id-map'.

Check Version:

grep id-map Cargo.lock

Verify Fix Applied:

Verify id-map version >= 0.4.0 in Cargo.lock after update.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with double-free or memory corruption errors
  • Unexpected panic messages in logs

Network Indicators:

  • Unusual traffic patterns to services using id-map

SIEM Query:

source="application.logs" AND ("double free" OR "memory corruption" OR "panic")

🔗 References

📤 Share & Export