CVE-2021-20197
NixOS vulnerability analysis and mitigation

Overview

CVE-2021-20197 affects GNU binutils version 2.35 and earlier, specifically impacting utilities including ar, objcopy, strip, and ranlib. The vulnerability was discovered in late 2020 and publicly disclosed in March 2021. The issue involves an open race window when writing output in these utilities, which could allow an unprivileged user to gain ownership of arbitrary files through a symlink when these utilities are run as a privileged user (NVD, Sourceware Bug).

Technical details

The vulnerability stems from a security flaw in the smartrename function within binutils/rename.c. The function performs chown and chmod operations on the target pathname rather than using fchown/fchmod on the file descriptor, creating a race condition. The issue has a CVSS v3.1 base score of 6.3 (Medium) with the vector CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N. The vulnerability is classified under CWE-59 (Improper Link Resolution Before File Access) and CWE-362 (Race Condition) (NVD, [Sourceware Bug](https://sourceware.org/bugzilla/showbug.cgi?id=26945)).

Impact

When these utilities are run as a privileged user, typically as part of a script updating binaries across different users, an unprivileged user can exploit the race condition to gain ownership of arbitrary files through a symlink. In worst-case scenarios involving multiple racing file replacements, it could potentially be used to chmod arbitrary root-owned files with SUID permissions (Sourceware Bug).

Mitigation and workarounds

The issue was fixed in GNU binutils versions after 2.35 through multiple patches that modified the smartrename function to use file descriptors instead of pathnames for permission operations. The fix includes using fchown/fchmod on file descriptors and ensuring proper handling of file states through the entire operation ([Sourceware Bug](https://sourceware.org/bugzilla/showbug.cgi?id=26945)).

Additional resources


SourceThis report was generated using AI

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management