CVE-2021-45707: Critical severity nix vulnerability

Published Dec 26, 2021
·
Updated

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.

Other sources

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

Affected Software

6 affected componentsFixes available
rust/nix>=0.22.0<0.22.2
0.22.2
rust/nix>=0.16.0<0.20.2
0.20.2
rust/nix>=0.21.0<0.21.2
0.21.2
Nix Project Nix Rust>=0.16.0<0.20.2
Nix Project Nix Rust>=0.21.0<0.21.2
Nix Project Nix Rust>=0.22.0<0.22.2

Event History

Dec 26, 2021
CVE Published
via MITRE·09:48 PM
Data Sourced
via MITRE·09:48 PM
Description
Dec 27, 2021
Data Sourced
via NVD·12:15 AM
DescriptionSeverityWeaknessAffected Software
Jan 6, 2022
Advisory Published
via GitHub·10:07 PM

Frequently Asked Questions

1

What is the severity of CVE-2021-45707?

CVE-2021-45707 has been classified as a moderate severity vulnerability.

2

How do I fix CVE-2021-45707?

To fix CVE-2021-45707, you should update the nix crate to versions 0.20.2, 0.21.2, or 0.22.2 or later.

3

What causes CVE-2021-45707?

CVE-2021-45707 is caused by an out-of-bounds write in the unistd::getgrouplist function when a user is in more than 16 groups.

4

Which versions of nix are affected by CVE-2021-45707?

CVE-2021-45707 affects nix crate versions from 0.16.0 to below 0.20.2, 0.21.x below 0.21.2, and 0.22.x below 0.22.2.

5

What are the implications of CVE-2021-45707?

The implications of CVE-2021-45707 include potential denial of service or security risks due to unexpected memory access.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203