SEVERITY NOT PROVIDED

RUSTSEC-2026-0528: UB can be reached from safe code

Published 2026-11-12 · Updated 2026-11-13

Summary

The ref-swap crate contains unsound variance and missing null checks that can lead to use-after-free and undefined behavior reachable from safe code. All developers using vulnerable versions of the crate should update immediately.

Who is affected

Projects using `ref-swap` are affected due to incorrect variance in `RefSwap` and `OptionRefSwap` alongside unchecked null pointers in `OptionRefSwap::into_inner`. These issues can be triggered from safe code and may potentially result in use-after-free vulnerabilities under specific conditions.

Exploitability

The CVSS vector, base score, and EPSS are not documented. CISA KEV indicates active exploitation is not known.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
crates.io ref-swap >= 0.0.0-0, < 0.1.3 0.1.3 cargo update -p ref-swap --precise 0.1.3

FAQ

What packages are affected?

The crates.io package ref-swap is affected in versions introduced from 0.0.0-0 up to, but not including, 0.1.3.

How is the vulnerability fixed?

The fix makes `RefSwap` and `OptionRefSwap` invariant and changes `OptionRefSwap::into_inner` to return an option, available in version 0.1.3.

Is my project affected if it compiles with version 0.1.3?

No, if your project still compiles with version 0.1.3, then it is not affected by the unsoundness present in version 0.1.2.

Original advisory description
The variance of `RefSwap` and `OptionRefSwap` were incorrect, possibly allowing use-after-free. `OptionRefSwap::into_inner` did not check for null. The fix is to make `RefSwap` and `OptionRefSwap` invariant, and to change `OptionRefSwap::into_inner` to return an option. It is available in version 0.1.3. If your project still compiles with 0.1.3 then it is not affected by the unsoundness on version 0.1.2

References

Source records: RUSTSEC-2026-0528 (OSV.dev).