A heap-based buffer overflow was found in the way sudo parses command line arguments. As per the researcher this vulnerability: - is exploitable by any local user (normal users and system users, sudoers and non-sudoers), without authentication (i.e., the attacker does not need to know the user's password); - was introduced in July 2011 (commit 8255ed69), and affects all legacy versions from 1.8.2 to 1.8.31p2 and all stable versions from 1.9.0 to 1.9.5p1, in their default configuration. This could lead to privilege escalation.
Created attachment 1748637 [details] Upstream patch
Created attachment 1748935 [details] New upstream patch (the first patch breaks -P option)
Created sudo tracking bugs for this issue: Affects: fedora-all [bug 1920618]
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.2 Advanced Update Support Via RHSA-2021:0226 https://access.redhat.com/errata/RHSA-2021:0226
This issue has been addressed in the following products: Red Hat Enterprise Linux 8.1 Extended Update Support Via RHSA-2021:0220 https://access.redhat.com/errata/RHSA-2021:0220
This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2021:0218 https://access.redhat.com/errata/RHSA-2021:0218
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.3 Advanced Update Support Via RHSA-2021:0225 https://access.redhat.com/errata/RHSA-2021:0225
This issue has been addressed in the following products: Red Hat Enterprise Linux 8.2 Extended Update Support Via RHSA-2021:0219 https://access.redhat.com/errata/RHSA-2021:0219
This issue has been addressed in the following products: Red Hat Enterprise Linux 6 Extended Lifecycle Support Via RHSA-2021:0227 https://access.redhat.com/errata/RHSA-2021:0227
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.4 Advanced Update Support Red Hat Enterprise Linux 7.4 Update Services for SAP Solutions Red Hat Enterprise Linux 7.4 Telco Extended Update Support Via RHSA-2021:0224 https://access.redhat.com/errata/RHSA-2021:0224
This issue has been addressed in the following products: Red Hat Enterprise Linux 7 Via RHSA-2021:0221 https://access.redhat.com/errata/RHSA-2021:0221
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.7 Extended Update Support Via RHSA-2021:0222 https://access.redhat.com/errata/RHSA-2021:0222
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.6 Extended Update Support Via RHSA-2021:0223 https://access.redhat.com/errata/RHSA-2021:0223
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s): https://access.redhat.com/security/cve/cve-2021-3156
External References: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt https://www.sudo.ws/alerts/unescape_overflow.html
Upstream patchset: https://github.com/sudo-project/sudo/commit/1f8638577d0c80a4ff864a2aad80a0d95488e9a8 https://github.com/sudo-project/sudo/commit/b301b46b79c6e2a76d530fa36d05992e74952ee8 https://github.com/sudo-project/sudo/commit/c4d384082fdbc8406cf19e08d05db4cded920a55
This issue was fixed upstream in version 1.9.5p2: https://www.sudo.ws/stable.html#1.9.5p2
Statement: This flaw does not affect the versions of sudo shipped with Red Hat Enterprise Linux 5, because the vulnerable code was not present in these versions.
This issue has been addressed in the following products: Red Hat Virtualization 4 for Red Hat Enterprise Linux 7 Via RHSA-2021:0395 https://access.redhat.com/errata/RHSA-2021:0395
This issue has been addressed in the following products: Red Hat Virtualization 4 for Red Hat Enterprise Linux 8 Via RHSA-2021:0401 https://access.redhat.com/errata/RHSA-2021:0401
Mitigation: Red Hat Product Security strongly recommends customers to update to fixed sudo packages once they are available. For customers who cannot update immediately, the following interim partial mitigation using systemtap is suggested: 1. Install required systemtap packages and dependencies: ``` systemtap yum-utils kernel-devel-"$(uname -r)" ``` Then for RHEL 7 install kernel debuginfo, using: ``` debuginfo-install -y kernel-"$(uname -r)" ``` Then for RHEL 8 & 6 install sudo debuginfo, using: ``` debuginfo-install sudo ``` 2. Create the following systemtap script: (call the file as sudoedit-block.stap) ``` probe process("/usr/bin/sudo").function("main") { command = cmdline_args(0,0,""); if (isinstr(command, "edit")) { raise(9); } } ``` 3. Install the script using the following command: (using root) ``` # nohup stap -g sudoedit-block.stap & ``` (This should output the PID number of the systemtap script) This script will cause the vulnerable sudoedit binary to stop working. The sudo command will still work as usual. The above change does not persist across reboots and must be applied after each reboot. Please consult How to make a systemtap kernel module load persistently across reboots? (https://access.redhat.com/solutions/5752521) to learn how to turn this into a service managed by initd. 4. Once the new fixed packages are installed, the systemtap script can be removed by killing the systemtap process. For example, by using: ``` # kill -s SIGTERM 7590 ``` (where 7590 is the PID of the systemtap process)