GHSA-wgrg-5h56-jg27: Out-of-bounds write in nix :unistd::getgrouplist Vulnerability
HIGHGHSA-wgrg-5h56-jg27 is a HIGH :unistd::getgrouplist vulnerability (General Security Weakness) affecting Out-of-bounds write in nix libraries in the crates.io ecosystem. The issue involves :unistd::getgrouplist. Remediation is available by upgrading affected packages to version 0.20.2, 0.21.2, 0.22.2.
GHSA-wgrg-5h56-jg27 at a Glance
How to Fix GHSA-wgrg-5h56-jg27
To remediate this vulnerability, upgrade all affected Out-of-bounds write in nix dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade nix to 0.20.2
Upgrade nix to 0.21.2
Upgrade nix to 0.22.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for nix
How to Check if You Are Affected
To determine whether your application is affected by GHSA-wgrg-5h56-jg27, inspect your project dependencies for Out-of-bounds write in nix:
inspect dependencies for nix
Analyze the terminal output to locate any version of Out-of-bounds write in nix in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.20.2), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under General Security Weakness. In Out-of-bounds write in nix, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-wgrg-5h56-jg27 Affected Out-of-bounds write in nix Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nix
|
crates.io |
≥ 0.16.0
< 0.20.2
|
0.20.2
|
|
nix
|
crates.io |
≥ 0.21.0
< 0.21.2
|
0.21.2
|
|
nix
|
crates.io |
≥ 0.22.0
< 0.22.2
|
0.22.2
|
References
Frequently Asked Questions
What is GHSA-wgrg-5h56-jg27?
Which Out-of-bounds write in nix versions are affected?
What version fixes GHSA-wgrg-5h56-jg27?
Is nix affected?
What CWE is associated with GHSA-wgrg-5h56-jg27?
How can I check crates.io dependencies for GHSA-wgrg-5h56-jg27?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wgrg-5h56-jg27",
"modified" : "2022-06-17T00:13:59Z",
"published" : "2022-06-17T00:13:59Z",
"aliases" : [ ],
"summary" : "Out-of-bounds write in nix::unistd::getgrouplist",
"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 reqested user's 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.\n",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "nix"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.16.0"
}, {
"fixed" : "0.20.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "nix"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.21.0"
}, {
"fixed" : "0.21.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "nix"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.22.0"
}, {
"fixed" : "0.22.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nix-rust/nix/issues/1541"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nix-rust/nix"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0119.html"
} ],
"database_specific" : {
"cwe_ids" : [ ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-06-17T00:13:59Z",
"nvd_published_at" : null
}
}