RustSec logo

HistoryEditJSON (OSV)

RUSTSEC-2026-0253

Potential use-after-free due to lack of panic safety in LruCache::pop()

Reported
Issued
Package
lru (crates.io)
Type
INFO Unsound
Categories
Keywords
#panic-safety #memory-safety #use-after-free #double-free
References
Patched
  • >=0.18.2

Description

LruCache::pop() in lru was not panic-safe. If the Drop implementation of a stored key panics during pop(), self.detach() is never called, leaving dangling pointers in the internal doubly-linked list.

A subsequent cache operation that triggers eviction can then dereference these dangling pointers:

Impact

Both types of undefined behavior can be invoked in safe Rust, but only if unwinding panics are enabled and std::panic::catch_unwind is used with key types that have potentially-panicking Drop implementations.

Fix

Fixed in lru 0.18.2 by detaching the node from the linked list before freeing it and dropping the key (lru-rs#238).

Advisory available under CC0-1.0 license.