Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. nix
  4. ›
  5. GHSA-wgrg-5h56-jg27

GHSA-wgrg-5h56-jg27: Out-of-bounds write in nix::unistd::getgrouplist

June 17, 2022

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.

References

  • github.com/advisories/GHSA-wgrg-5h56-jg27
  • github.com/nix-rust/nix
  • github.com/nix-rust/nix/issues/1541
  • rustsec.org/advisories/RUSTSEC-2021-0119.html

Code Behaviors & Features

Detect and mitigate GHSA-wgrg-5h56-jg27 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 0.16.0 before 0.20.2, all versions starting from 0.21.0 before 0.21.2, all versions starting from 0.22.0 before 0.22.2

Fixed versions

  • 0.20.2
  • 0.21.2
  • 0.22.2

Solution

Upgrade to versions 0.20.2, 0.21.2, 0.22.2 or above.

Source file

cargo/nix/GHSA-wgrg-5h56-jg27.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:14:58 +0000.