rustsec-2021-0119
Vulnerability from osv_rustsec
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.
{
"affected": [
{
"database_specific": {
"categories": [
"memory-corruption"
],
"cvss": null,
"informational": null
},
"ecosystem_specific": {
"affected_functions": null,
"affects": {
"arch": [],
"functions": [
"nix::unistd::getgrouplist"
],
"os": [
"linux",
"freebsd",
"android",
"netbsd",
"dragonfly",
"openbsd",
"fuchsia"
]
}
},
"package": {
"ecosystem": "crates.io",
"name": "nix",
"purl": "pkg:cargo/nix"
},
"ranges": [
{
"events": [
{
"introduced": "0.16.0"
},
{
"fixed": "0.20.2"
},
{
"introduced": "0.21.0-0"
},
{
"fixed": "0.21.2"
},
{
"introduced": "0.22.0-0"
},
{
"fixed": "0.22.2"
},
{
"introduced": "0.23.0-0"
},
{
"fixed": "0.23.0"
}
],
"type": "SEMVER"
}
],
"versions": []
}
],
"aliases": [
"CVE-2021-45707",
"GHSA-76w9-p8mg-j927",
"GHSA-wgrg-5h56-jg27"
],
"database_specific": {
"license": "CC0-1.0"
},
"details": "On certain platforms, if a user has more than 16 groups, the\n`nix::unistd::getgrouplist` function will call the libc `getgrouplist`\nfunction with a length parameter greater than the size of the buffer it\nprovides, resulting in an out-of-bounds write and memory corruption.\n\nThe libc `getgrouplist` function takes an in/out parameter `ngroups`\nspecifying the size of the group buffer. When the buffer is too small to\nhold all of the requested user\u0027s group memberships, some libc\nimplementations, including glibc and Solaris libc, will modify `ngroups`\nto indicate the actual number of groups for the user, in addition to\nreturning an error. The version of `nix::unistd::getgrouplist` in nix\n0.16.0 and up will resize the buffer to twice its size, but will not\nread or modify the `ngroups` variable. Thus, if the user has more than\ntwice as many groups as the initial buffer size of 8, the next call to\n`getgrouplist` will then write past the end of the buffer.\n\nThe issue would require editing /etc/groups to exploit, which is usually\nonly editable by the root user.",
"id": "RUSTSEC-2021-0119",
"modified": "2023-06-13T13:10:24Z",
"published": "2021-09-27T12:00:00Z",
"references": [
{
"type": "PACKAGE",
"url": "https://crates.io/crates/nix"
},
{
"type": "ADVISORY",
"url": "https://rustsec.org/advisories/RUSTSEC-2021-0119.html"
},
{
"type": "REPORT",
"url": "https://github.com/nix-rust/nix/issues/1541"
}
],
"related": [],
"severity": [],
"summary": "Out-of-bounds write in nix::unistd::getgrouplist"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.