Post
Taulet's avatar
⋮

Struct lifetime requirements can be bypassed via covariant field assignment

A Rust compiler bug lets a covariant field assignment bypass a struct’s 'static bound, allowing a reference to outlive its referent and produce a stack-use-after-scope. The issue is open, labeled I-unsound and P-high, and the reproducer works on current nightly and stable releases back to at least 1.85.0. The Rust team’s note says this is an old, serious compiler bug, but triggering memory unsafety requires an intentionally malicious Drop implementation; it is not evidence that ordinary code has been exploited.

The 386-comment Hacker News discussion focused on how the destructor can stash a reference that the compiler incorrectly treats as 'static. Several readers stressed that this is an implementation bug rather than a flaw in Rust’s intended lifetime rules; others debated how much the age of the issue says about practical risk and the limits of formal verification. The thread also corrected early claims about exploitability after the Rust team added context to the issue.