CVE-2021-45718
Description
An issue was discovered in the rusqlite crate 0.25.x before 0.25.4 and 0.26.x before 0.26.2 for Rust. rollback_hook has a use-after-free.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A use-after-free vulnerability in rusqlite's rollback_hook function allows attackers to access freed memory under certain conditions.
Vulnerability
The rollback_hook function in the rusqlite crate for Rust (versions 0.25.x before 0.25.4 and 0.26.x before 0.26.2) has a use-after-free vulnerability. This issue arises because the lifetime bounds on closures passed to rollback_hook (and other similar hook functions) were too relaxed. If a closure referencing borrowed values on the stack is passed, it may allow access to objects on the stack after they have been dropped. This affects functions under the hooks feature, including commit_hook, rollback_hook, and update_hook, as well as functions under functions and collation features [1][2][4].
Exploitation
An attacker would need to craft a closure that references borrowed stack values and pass it to rollback_hook. When the closure is later invoked by SQLite, it may access memory that has already been freed, leading to a use-after-free condition. The attack requires the user to enable the hooks feature (or other impacted features) and trigger the callback after the referenced data is dropped. No authentication or network position is required as this is a library-level vulnerability exploitable through crafted application code [2][4].
Impact
Successful exploitation can lead to memory corruption, potentially allowing an attacker to read or write freed memory, causing undefined behavior, crashes, or in some cases arbitrary code execution. The impact depends on the specific usage context, but it compromises memory safety guarantees provided by Rust [2].
Mitigation
The vulnerability is fixed in rusqlite versions 0.25.4 and 0.26.2 [2][4]. Users should update to these or later versions. No workarounds are documented in the provided references. There is no evidence that this CVE is listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
rusqlitecrates.io | >= 0.25.0, < 0.25.4 | 0.25.4 |
rusqlitecrates.io | >= 0.26.0, < 0.26.2 | 0.26.2 |
Affected products
2- rusqlite/rusqlitedescription
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
5- github.com/advisories/GHSA-g4g4-3pqw-8m7fghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-45718ghsaADVISORY
- github.com/rusqlite/rusqlite/issues/1048ghsaWEB
- raw.githubusercontent.com/rustsec/advisory-db/main/crates/rusqlite/RUSTSEC-2021-0128.mdghsax_refsource_MISCWEB
- rustsec.org/advisories/RUSTSEC-2021-0128.htmlghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.