CVE-2021-45719
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. update_hook has a use-after-free.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Use-after-free in rusqlite's update_hook due to incorrect lifetime bounds on closures, affecting versions 0.25.x before 0.25.4 and 0.26.x before 0.26.2.
Vulnerability
In the rusqlite crate for Rust, the update_hook function (under cfg(feature = "hooks")) registered a callback with an overly relaxed lifetime bound [2][4]. This allowed a closure that borrows stack-local data to be passed to update_hook, even though the closure could be invoked later by SQLite after the borrowed values have been dropped, leading to a use-after-free. The vulnerability affects versions 0.25.0 through 0.25.3 and 0.26.0 through 0.26.1 [2][4].
Exploitation
An attacker must provide a closure to update_hook that captures references to data on the stack, and then arrange for that stack data to go out of scope before the closure is called by SQLite [2][4]. This can occur when the closure is created in a function scope and the callback is invoked after the function returns [4]. The attacker does not need special network access or authentication; the exploitation depends on the program's control flow and the ability to trigger a database transaction that invokes the hook after the borrowed data is freed [2][4].
Impact
Successful exploitation results in a use-after-free memory corruption, which can lead to information disclosure, arbitrary code execution, or a program crash [2][4]. Since rusqlite is a low-level binding, the impact could be severe if the attacker controls the freed memory content [2].
Mitigation
Upgrade to rusqlite version 0.25.4 or 0.26.2, where the lifetime bounds were corrected [2][4]. If an immediate upgrade is not possible, avoid passing closures that borrow stack-local data to update_hook, and ensure that any captured data has a lifetime at least as long as the database connection [4]. No workaround exists that fully addresses the root cause without patching [2].
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-g87r-23vw-7f87ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-45719ghsaADVISORY
- 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.