CVE-2021-45718

7.5 HIGH

📋 TL;DR

This vulnerability in the rusqlite Rust crate involves a use-after-free bug in the rollback_hook function, which could allow attackers to execute arbitrary code or cause a denial of service. It affects applications using vulnerable versions of the rusqlite library for SQLite database operations in Rust. The issue occurs when rollback hooks are improperly managed during transaction rollbacks.

💻 Affected Systems

Products:
  • rusqlite Rust crate
Versions: 0.25.x before 0.25.4, 0.26.x before 0.26.2
Operating Systems: All platforms supported by Rust (Linux, Windows, macOS, etc.)
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications that use the rollback_hook functionality. Applications not using this feature may not be vulnerable.

📦 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, potentially corrupting database transactions.

🟢

If Mitigated

Limited impact with proper memory safety controls and sandboxing in place.

🌐 Internet-Facing: MEDIUM - Exploitation requires specific conditions but could affect web services using rusqlite.
🏢 Internal Only: LOW - Primarily affects internal applications with controlled user access.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires triggering specific rollback hook conditions. No publicly available exploit code has been documented.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.25.4 or 0.26.2

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

Restart Required: Yes

Instructions:

1. Update Cargo.toml to specify rusqlite >=0.25.4 or >=0.26.2. 2. Run 'cargo update' to fetch the patched version. 3. Rebuild and redeploy your application.

🔧 Temporary Workarounds

Avoid rollback_hook usage

all

Temporarily disable or avoid using the rollback_hook functionality until patched.

Modify code to remove or comment out rollback_hook calls

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for database operations
  • Run application in a sandboxed environment with limited privileges

🔍 How to Verify

Check if Vulnerable:

Check Cargo.lock or run 'cargo tree | grep rusqlite' to see installed version.

Check Version:

grep rusqlite Cargo.lock

Verify Fix Applied:

Confirm rusqlite version is 0.25.4+ or 0.26.2+ in Cargo.lock after update.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with memory access violations
  • Unexpected process termination during database rollbacks

Network Indicators:

  • None specific - this is a local memory corruption vulnerability

SIEM Query:

Process termination events from applications using rusqlite with error codes indicating memory access violations

🔗 References

📤 Share & Export