CVE-2021-29935

7.3 HIGH

📋 TL;DR

This vulnerability in the Rocket web framework for Rust allows use-after-free memory corruption when user-provided functions panic during URI formatting. Attackers could potentially execute arbitrary code or crash applications. Any Rust application using Rocket versions before 0.4.7 is affected.

💻 Affected Systems

Products:
  • Rocket web framework for Rust
Versions: All versions before 0.4.7
Operating Systems: All platforms running Rust applications
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using Rocket's uri::Formatter with custom 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 service disruption

🟠

Likely Case

Application crash causing denial of service, potentially leading to memory corruption that could be leveraged for further exploitation

🟢

If Mitigated

Limited impact with proper panic handling and memory safety controls, though crashes may still occur

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires triggering a panic in user-provided URI formatting functions, which may be difficult without application-specific knowledge

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.4.7 and later

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

Restart Required: Yes

Instructions:

1. Update Cargo.toml to specify rocket = "^0.4.7"
2. Run 'cargo update rocket'
3. Rebuild and redeploy your application
4. Restart all affected services

🔧 Temporary Workarounds

Avoid custom URI formatters

all

Remove or disable any custom user-provided functions in uri::Formatter usage

Review and modify Rocket application code to avoid custom URI formatting functions

Implement panic handlers

all

Add global panic handlers that prevent memory corruption on panic

Add std::panic::set_hook() with proper memory safety in main()

🧯 If You Can't Patch

  • Implement strict input validation for all URI formatting operations
  • Deploy application behind a WAF with memory corruption protection rules

🔍 How to Verify

Check if Vulnerable:

Check Cargo.lock or Cargo.toml for rocket version <0.4.7

Check Version:

grep -A2 'name = "rocket"' Cargo.lock | grep version

Verify Fix Applied:

Verify rocket version is >=0.4.7 in Cargo.lock and test URI formatting with panic scenarios

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with panic messages related to URI formatting
  • Memory access violation errors in application logs

Network Indicators:

  • HTTP requests with malformed URIs causing application termination

SIEM Query:

source="application.logs" AND ("panic" OR "use-after-free" OR "uri::Formatter")

🔗 References

📤 Share & Export