This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours

Bug 844442 (CVE-2012-3440)

Summary: CVE-2012-3440 sudo: insecure temporary file use in RPM %postun script
Product: [Other] Security Response Reporter: Tomas Hoger <thoger>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: dkopecek, jrusnack, security-response-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=moderate,public=20120807,reported=20120719,source=researcher,cvss2=5.6/AV:L/AC:H/Au:N/C:N/I:C/A:C,rhel-3/sudo=notaffected,rhel-4/sudo=notaffected,rhel-5/sudo=affected,rhel-6/sudo=notaffected,fedora-all/sudo=notaffected,cwe=CWE-367
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-07 13:43:54 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On: 844443, 844444    
Bug Blocks: 841858    

Description Tomas Hoger 2012-07-30 12:15:32 EDT
The sudo packages in Red Hat Enterprise Linux 5 contained a %postun script (executed during the package removal or upgrade) that created a temporary file insecurely.  The script did the following:

# Remove the "sudoers:" line from nsswitch.conf if it's not modified
if grep -q "^sudoers: files ldap$" ""/etc/nsswitch.conf""; then
   rm -f ""/var/tmp/nsswitch.conf.bak"" && \
   touch ""/var/tmp/nsswitch.conf.bak"" && \
   grep -v "^sudoers: files ldap$" ""/etc/nsswitch.conf"" > ""/var/tmp/nsswitch.conf.bak"" && \
   mv -f ""/var/tmp/nsswitch.conf.bak"" ""/etc/nsswitch.conf""
fi

There was a race condition between the removal of the temporary file and its re-creation using touch.  A local attacker could possibly use this to create nsswitch.conf.bak file or symlink after rm -f "/var/tmp/nsswitch.conf.bak" was run and cause the script to overwrite arbitrary file with the contents of the /etc/nsswitch.conf file, or make the script create /etc/nsswitch.conf file with attacker controlled content and permissions.  The attack would have to be executed during the sudo package upgrade or removal.

This problem was introduced in the sudo erratum RHSA-2012:0309 which was released in Red Hat Enterprise Linux 5.8:

https://rhn.redhat.com/errata/RHSA-2012-0309.html

The sudo packages in other Red Hat Enterprise Linux versions did not include this %postun script and were not affected this issue.
Comment 2 errata-xmlrpc 2012-08-07 12:54:03 EDT
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2012:1149 https://rhn.redhat.com/errata/RHSA-2012-1149.html