CVE-2021-28877

7.5 HIGH

📋 TL;DR

This vulnerability in Rust's standard library before version 1.51.0 allows memory safety violations when using nested Zip iterators. The bug causes the same index to be accessed multiple times, potentially leading to use-after-free or other memory corruption issues. Any Rust application using nested Zip iterators is affected.

💻 Affected Systems

Products:
  • Rust programming language standard library
Versions: All Rust versions before 1.51.0
Operating Systems: All operating systems running Rust
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects code using nested Zip iterators with the TrustedRandomAccess trait.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Memory corruption leading to arbitrary code execution, denial of service, or data corruption.

🟠

Likely Case

Application crashes or undefined behavior due to memory access violations.

🟢

If Mitigated

No impact if patched or if application doesn't use nested Zip iterators.

🌐 Internet-Facing: MEDIUM - Exploitation requires specific code patterns but could lead to RCE in vulnerable services.
🏢 Internal Only: MEDIUM - Similar risk profile but limited to internal network exposure.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: HIGH - Requires specific code patterns and understanding of Rust memory model.

Exploitation requires crafting specific iterator patterns to trigger the bug.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Rust 1.51.0 and later

Vendor Advisory: https://github.com/rust-lang/rust/pull/80670

Restart Required: Yes

Instructions:

1. Update Rust toolchain to version 1.51.0 or later using rustup. 2. Recompile all Rust applications with the updated toolchain. 3. Redeploy updated applications.

🔧 Temporary Workarounds

Avoid nested Zip iterators

all

Refactor code to avoid using nested Zip iterators that could trigger the bug.

🧯 If You Can't Patch

  • Implement input validation and sanitization for iterator operations
  • Use memory-safe alternatives to Zip iterators in critical code paths

🔍 How to Verify

Check if Vulnerable:

Check Rust version with: rustc --version. If version is below 1.51.0, check code for nested Zip iterator usage.

Check Version:

rustc --version

Verify Fix Applied:

Verify Rust version is 1.51.0 or higher: rustc --version. Test applications with previously problematic iterator patterns.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with memory access violations
  • Segmentation faults in Rust applications

Network Indicators:

  • Unusual application behavior after iterator operations

SIEM Query:

Process crashes with rustc or Rust application names

🔗 References

📤 Share & Export