#lifetime #extend #bug #safe #behavior #free #life

lifetime-extender

This crate is published for a severe bug that allow user write safe code to extend the lifetime of any object, which is unacceptable since such behavior may easily leads to UAF, double free and many UB. This crate should NOT used in the real life, since it relies on a BUG, not a feature.

2 releases

0.1.1 Dec 12, 2023
0.1.0 Dec 11, 2023

#15 in #extend

31 downloads per month

Custom license

15KB
74 lines

A Very unsafe lifetime extender with only safe Rust

This crate is published for a severe bug that allow user write safe code to extend the lifetime of any object, which is unacceptable since such behavior may easily leads to UAF, double free and many UB. This crate should NOT used in the real life, since it relies on a BUG, not a feature.

Here, 2 functions are provided, one is extend, which could extend any borrow's lifetime to 'static (should be the longest lifetime), and another is the mutable version extend_mut, which could extend the mutable borrows. The former one may easily leads to UAF, and the second one

The crate uses !#[forbid(unsafe_code)] to ensure only safe rust is used.

All the functions are ZCA, which could be directly optimized out.

By default, all functions are hidden since you should use none of them. You could test them with the related feature (in case some of them is fixed and others have not.) Using the most dangerous i-can-do-whatever-the-fxxk-i-want feature gate would enable all the features.

No runtime deps

Features