GHSA-4q83-7cq4-p6wg `tokio::io::ReadHalf<T>::unsplit` is Unsound

Not scored Published

A soundness bug in Tokio's ReadHalf::unsplit can cause use-after-free if specific conditions are met, potentially allowing code execution.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Not stated
Victim action needed
Not needed
Fix
Available

What is GHSA-4q83-7cq4-p6wg?

GHSA-4q83-7cq4-p6wg is an use after free vulnerability in tokio, published on 11 Jan 2023.

Official description

tokio::io::ReadHalf&lt;T&gt;::unsplit can violate the Pin contract

The soundness issue is described in the tokio/issues#5372

Specific set of conditions needed to trigger an issue (a !Unpin type in ReadHalf) is unusual, combined with the difficulty of making any arbitrary use-after-free exploitable in Rust without doing a lot of careful alignment of data types in the surrounding code.

The tokio feature io-util is also required to be enabled to trigger this soundness issue.

Thanks to zachs18 reporting the issue to Tokio team responsibly and taiki-e and carllerche appropriately responding and fixing the soundness bug.

Tokio before 0.2.0 used futures 0.1 that did not have Pin, so it is not affected by this issue.

Which versions are affected by GHSA-4q83-7cq4-p6wg?

7 open source packages ship an affected version, including tokio.

PackageAffectedFixed in
tokio crates.ioFrom 0.2.01.18.5, 1.20.4, 1.24.2
tokio crates.ioFrom 0.2.01.18.5
tokio crates.ioFrom 0.2.01.18.5
tokio crates.ioFrom 1.19.01.20.4
tokio crates.ioFrom 1.19.01.20.4
tokio crates.ioFrom 1.21.01.24.2
1 more packages
tokio crates.ioFrom 1.21.01.24.2

How do I fix GHSA-4q83-7cq4-p6wg?

Upgrade tokio to a fixed version for your release line: 1.18.5, 1.20.4 or 1.24.2.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is GHSA-4q83-7cq4-p6wg being exploited?

There is no known exploitation of GHSA-4q83-7cq4-p6wg in the wild and no public exploit code.

Sources

Also known as RUSTSEC-2023-0005.

Is GHSA-4q83-7cq4-p6wg in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free