GitHub Advisoryadvisory · crates.io

GHSA-76w9-p8mg-j927 Out-of-bounds Write in nix

MEDIUM Published 2022-01-06 Modified 2024-02-21 Official page ↗
Aliases
CVE-2021-45707
Ecosystem
crates.io
Packages
nix
Severity
Moderate
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
Weaknesses
CWE-787
Reviewed
2022-01-05

Affected packages

• crates.io nix: >= 0.16.0, < 0.20.2 → fixed in 0.20.2 • crates.io nix: >= 0.21.0, < 0.21.2 → fixed in 0.21.2 • crates.io nix: >= 0.22.0, < 0.22.2 → fixed in 0.22.2

Description

On certain platforms, if a user has more than 16 groups, the nix::unistd::getgrouplist function will call the libc getgrouplist function with a length parameter greater than the size of the buffer it provides, resulting in an out-of-bounds write and memory corruption. The libc getgrouplist function takes an in/out parameter ngroups specifying the size of the group buffer. When the buffer is too small to hold all of the requested user's group memberships, some libc implementations, including glibc and Solaris libc, will modify ngroups to indicate the actual number of groups for the user, in addition to returning an error. The version of nix::unistd::getgrouplist in nix 0.16.0 and up will resize the buffer to twice its size, but will not read or modify the ngroups variable. Thus, if the user has more than twice as many groups as the initial buffer size of 8, the next call to getgrouplist will then write past the end of the buffer. The issue would require editing /etc/groups to exploit, which is usually only editable by the root user.

Related

Alias · CVE (1)

  • CVE-2021-45707 An issue was discovered in the nix crate 0.16.0 and later before 0.20.2, 0.21.x before 0.21.2, and 0.22.x before 0.22.2 for Rust. vulnerability

Weakness · CWE (1)

  • CWE-787 Out-of-bounds Write weakness

References