CVE-2021-45707
JSON

9.8critical

Out-of-bounds Write in nix

Severity
9.8critical CVSS:3.1 by NVD
Exploit likelihood
1.69% (higher than 78% of CVEs)
Published
Last changed
Assigned by
mitre
Also known as
GHSA-76w9-p8mg-j927GHSA-wgrg-5h56-jg27RUSTSEC-2021-0119

Description

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. unistd::getgrouplist has an out-of-bounds write if a user is in more than 16 /etc/groups groups.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
nix (crates.io)from 0.16.0 before 0.20.2, from 0.21.0 before 0.21.2, from 0.22.0 before 0.22.2, from 0.21.0-0 before 0.21.2, from 0.22.0-0 before 0.22.2, from 0.23.0-0 before 0.23.0GitHub Advisory Database, RustSec Advisory Database
nix_project nixfrom 0.16.0 before 0.20.2, from 0.21.0 before 0.21.2, from 0.22.0 before 0.22.2NVD

All scores

GitHub6.7medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
GitHubhigh rating
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

What each source says

CVE List

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. unistd::getgrouplist has an out-of-bounds write if a user is in more than 16 /etc/groups groups.

GitHub Advisory Database

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.

GitHub Advisory Database

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 reqested 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.

RustSec Advisory Database

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.

NVD (es)

Se ha descubierto un problema en las cajas nix versión 0.16.0 y posteriores antes de la versión 0.20.2, 0.21.x antes de la versión 0.21.2 y 0.22.x antes de la versión 0.22.2 para Rust. unistd::getgrouplist tiene una escritura fuera de límites si un usuario está en más de 16 grupos /etc/groups.

References

Sources

SourceRecordLicence
CVE ListCVE-2021-45707 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-76w9-p8mg-j927 changed 2026-09-10CC-BY-4.0
GitHub Advisory DatabaseGHSA-wgrg-5h56-jg27 changed 2026-09-10CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0119 changed 2023-11-08CC0-1.0
NVDCVE-2021-45707 changed 2026-06-17Public domain