HistoryEdit

RUSTSEC-2021-0030

move_elements can double-free objects on panic

Reported
Issued
Package
scratchpad (crates.io)
Type
Vulnerability
Categories
Keywords
#memory-safety #double-free
Aliases
Details
https://github.com/okready/scratchpad/issues/1
CVSS Score
9.8 CRITICAL
CVSS Details
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Patched
  • >=1.3.1
Affected Functions
Version
scratchpad::SliceMoveSource::move_elements
  • <1.3.1

Description

Affected versions of scratchpad used ptr::read to read elements while calling a user provided function f on them.

Since the pointer read duplicates ownership, a panic inside the user provided f function could cause a double free when unwinding.

The flaw was fixed in commit 891561bea by removing the unsafe block and using a plain iterator.