From ef9463d5a7c0e9fb77ba4edf8c3fb7359e0d397f Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Wed, 8 Dec 2021 16:28:00 -0800 Subject: [PATCH] Report `rusqlite` closure lifetime issue (#1117) --- crates/rusqlite/RUSTSEC-0000-0000.md | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 crates/rusqlite/RUSTSEC-0000-0000.md diff --git a/crates/rusqlite/RUSTSEC-0000-0000.md b/crates/rusqlite/RUSTSEC-0000-0000.md new file mode 100644 index 0000000..baab781 --- /dev/null +++ b/crates/rusqlite/RUSTSEC-0000-0000.md @@ -0,0 +1,42 @@ +```toml +[advisory] +id = "RUSTSEC-0000-0000" +package = "rusqlite" +date = "2021-12-07" +url = "https://github.com/rusqlite/rusqlite/issues/1048" +categories = ["memory-corruption"] +keywords = ["use-after-free", "incorrect-lifetime"] + +[affected.functions] + +# Under `cfg(feature = "functions")` +"rusqlite::Connection::create_scalar_function" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] +"rusqlite::Connection::create_aggregate_function" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] +"rusqlite::Connection::create_window_function" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] + +# Under `cfg(feature = "collation")` +"rusqlite::Connection::create_collation" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] + +# Under `cfg(feature = "hooks")` +"rusqlite::Connection::commit_hook" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] +"rusqlite::Connection::rollback_hook" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] +"rusqlite::Connection::update_hook" = [">= 0.25.0, < 0.25.4", ">= 0.26.0, < 0.26.2"] + +[versions] +patched = [">= 0.26.2", "0.25.4"] +unaffected = ["< 0.25.0"] +``` + +# Incorrect Lifetime Bounds on Closures in `rusqlite` + +The lifetime bound on several closure-accepting `rusqlite` functions (specifically, functions which register a callback to be later invoked by SQLite) was too relaxed. If a closure referencing borrowed values on the stack is was passed to one of these functions, it could allow Rust code to access objects on the stack after they have been dropped. + +The impacted functions are: + +- Under `cfg(feature = "functions")`: `Connection::create_scalar_function`, `Connection::create_aggregate_function` and `Connection::create_window_function`. +- Under `cfg(feature = "hooks")`: `Connection::commit_hook`, `Connection::rollback_hook` and `Connection::update_hook`. +- Under `cfg(feature = "collation")`: `Connection::create_collation`. + +The issue exists in all `0.25.*` versions prior to `0.25.4`, and all `0.26.*` versions prior to 0.26.2 (specifically: `0.25.0`, `0.25.1`, `0.25.2`, `0.25.3`, `0.26.0`, and `0.26.1`). + +The fix is available in versions `0.26.2` and newer, and also has been back-ported to `0.25.4`. As it does not exist in `0.24.*`, all affected versions should have an upgrade path to a semver-compatible release.