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 package | Versions | Reported by |
|---|---|---|
| Unspecified product | n/a | CVE 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.0 | GitHub Advisory Database, RustSec Advisory Database |
| nix_project nix | from 0.16.0 before 0.20.2, from 0.21.0 before 0.21.2, from 0.22.0 before 0.22.2 | NVD |
All scores
| GitHub | 6.7medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H |
| GitHub | high rating | |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.5high CVSS:2.0 | AV: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
| https://rustsec.org/advisories/RUSTSEC-2021-0119.html | advisory, issue-tracking, third-party-advisory, web | |
| https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/nix/RUSTSEC-2021-0119.md | third-party-advisory, web | |
| https://github.com/advisories/GHSA-wgrg-5h56-jg27 | advisory, third-party-advisory | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-45707 | advisory | |
| https://github.com/nix-rust/nix/issues/1541 | report, web | |
| https://github.com/nix-rust/nix | package | |
| https://crates.io/crates/nix | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-45707 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-76w9-p8mg-j927 changed 2026-09-10 | CC-BY-4.0 |
| GitHub Advisory Database | GHSA-wgrg-5h56-jg27 changed 2026-09-10 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2021-0119 changed 2023-11-08 | CC0-1.0 |
| NVD | CVE-2021-45707 changed 2026-06-17 | Public domain |