You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix unsound lifetime extension in HRTB function pointer coercion
= Problem =
The compiler allowed unsound coercions from function items/pointers with
nested reference parameters to HRTB function pointers, enabling arbitrary
lifetime extension to 'static. This was demonstrated by the cve-rs exploit:
```rust
fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v }
// This coercion was allowed but unsound:
let f: for<'x> fn(_, &'x T) -> &'static T = foo;
```
The issue occurs because nested references like `&'a &'b ()` create an
implied outlives bound `'b: 'a`. When coercing to an HRTB function pointer,
this constraint was not validated, allowing the inner lifetime to be
extended arbitrarily.
0 commit comments