HistoryEditJSON (OSV)

RUSTSEC-2020-0059

MutexGuard::map can cause a data race in safe code

Reported
Issued
Package
futures-util (crates.io)
Type
Vulnerability
Categories
Keywords
#concurrency #memory-corruption #memory-management
Aliases
References
CVSS Score
4.7 MEDIUM
CVSS Details
Attack vector
Local
Attack complexity
High
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H
Patched
  • >=0.3.7
Unaffected
  • <0.3.2
Affected Functions
Version
futures_util::lock::MutexGuard::map
  • >=0.3.2

Description

Affected versions of the crate had a Send/Sync implementation for MappedMutexGuard that only considered variance on T, while MappedMutexGuard dereferenced to U.

This could of led to data races in safe Rust code when a closure used in MutexGuard::map() returns U that is unrelated to T.

The issue was fixed by fixing Send and Sync implementations, and by adding a PhantomData<&'a mut U> marker to the MappedMutexGuard type to tell the compiler that the guard is over U too.

Advisory available under CC0-1.0 license.