Protect yourself against future threats.
-----BEGIN PGP SIGNED MESSAGE----- =========================================================================== AUSCERT External Security Bulletin Redistribution ESB-2001.309 -- NetBSD Security Advisory 2001-009 Race condition between sugid-exec and ptrace(2) 25 July 2001 =========================================================================== AusCERT Security Bulletin Summary --------------------------------- Product: kernel Vendor: NetBSD Operating System: NetBSD Impact: Root Compromise Access Required: Existing Account - --------------------------BEGIN INCLUDED TEXT-------------------- - -----BEGIN PGP SIGNED MESSAGE----- NetBSD Security Advisory 2001-009 ================================= Topic: Race condition between sugid-exec and ptrace(2) Version: All official releases up to and including 1.5 Severity: Local user may gain superuser privileges Fixed: NetBSD-current: June 15, 2001 NetBSD-1.5 branch: June 17, 2001 (1.5.1 includes the fix) NetBSD-1.4 branch: July 19, 2001 Abstract ======== A race condition between the setuid/setgid handling in the execve(2) system call and the ptrace(2) system call can allow a local user to cause a setuid-root executable to execute arbitrary code as the superuser. Technical Details ================= The execve(2) system call causes a process to begin execution of a new program image. This system call has a facility known as sugid, which allows certain programs to run with the user and/or group ID indicated by the file system permissions. This facility is used by, e.g. the su(1) program to allow certain users to gain superuser privileges. Once a process uses the sugid facility, it is marked as having done so, in order for other kernel facilities to make decisions based on this information. The ptrace(2) system call is a debugging facility. It provides the means for debuggers, such as gdb(1), to access the memory and registers of another process. The kernel allows a process to ptrace(2) another process only if they are owned by the same user ID, or if the tracing process has superuser privileges. If a process was exec'd using sugid, tracing of that process is disallowed unless done by the superuser. The execve(2) code contains a check to skip sugid processing if a process is currently being traced by ptrace(2). However, in vulnerable systems, two problems exist: * The check for a traced process in the sugid-exec code is performed too early. The check is made before the new executable image is opened, which may block. * The marking of a process as sugid happens too late. The process is marked as sugid after a call which allocates memory. The memory allocation may block. While the process exec'ing the new program image is asleep in either of these two places, another process owned by the same user can ptrace(2) the process. Once attached to the sugid process, the attacker can modify the sugid process's memory image and modify the program counter register, allowing the attacker to execute arbitrary code. Solutions and Workarounds ========================= Kernel sources must be updated and a new kernel built and installed. The instructions for updating your kernel sources depend upon which particular NetBSD release you are running. * NetBSD-current: Systems running NetBSD-current dated from before 2001-06-15 should be upgraded to NetBSD-current dated 2001-06-15 or later. The following source directories need to be updated from the netbsd-current CVS branch (aka HEAD): src/sys/compat/netbsd32 src/sys/kern Alternatively, apply the following patch (with potential offset differences): ftp://ftp.netbsd.org/pub/NetBSD/security/patches/SA2001-009-ptrace-1.5.patch * NetBSD 1.5: Systems running NetBSD 1.5 dated from before 2001-06-17 should be upgraded from NetBSD 1.5 sources dated 2001-06-17 or later. The following source directories need to be updated from the netbsd-1-5 CVS branch: src/sys/compat/netbsd32 src/sys/kern Alternatively, apply the following patch (with potential offset differences): ftp://ftp.netbsd.org/pub/NetBSD/security/patches/SA2001-009-ptrace-1.5.patch NetBSD 1.5.1 is not vulnerable. * NetBSD 1.4, 1.4.1, 1.4.2, 1.4.3: It is believed the 1.4 versions are vulnerable to this issue, but a working exploit could not be produced. The following is recommended action for 1.4 systems. Systems running NetBSD 1.4 dated from before 2001-07-19 should be upgraded from NetBSD 1.4 sources dated 2001-07-19 or later. The following source directory needs to be updated from the netbsd-1-4 CVS branch: src/sys/kern Alternatively, apply the following patch (with potential offset differences): ftp://ftp.netbsd.org/pub/NetBSD/security/patches/SA2001-009-ptrace-1.4.patch Once the kernel sources have been updated, rebuild the kernel, install it, and reboot. For more information on how to do this, see: http://www.netbsd.org/Documentation/kernel/#building_a_kernel Thanks To ========= Georgi Guninski for pointing out that the problem existed on the Bugtraq mailing list. Artur Grabowski for some initial discussion about the problem. Jason R. Thorpe for investigating and fixing the problem. Bill Sommerfeld for additional discussion and code review. Revision History ================ 2001-07-20 Initial revision More Information ================ An up-to-date PGP signed copy of this release will be maintained at ftp://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2001-009.txt.asc Information about NetBSD and NetBSD security can be found at http://www.NetBSD.ORG/ and http://www.NetBSD.ORG/Security/. Copyright 2001, The NetBSD Foundation, Inc. All Rights Reserved. $NetBSD: NetBSD-SA2001-009.txt,v 1.9 2001/07/20 01:14:34 lukem Exp $ - -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (NetBSD) Comment: For info see http://www.gnupg.org iQCVAwUBO1eSDj5Ru2/4N2IFAQH40gP/bIylOl0aB3J3quxc27DxDv2Qtri6rUql FKIyGqxkT+Bjeem3mJSYMWPCDRbZrcgxJdZopphbwe05DYLi06rAE56SmVFWsOLA 9UDPKfFoFUVah1j/VKiLuGtRoxQn2TCrQWy5k30thaRM+iQs29ahVRaLgyhEOjXQ BhC+i1tM4SY= =kdL7 - -----END PGP SIGNATURE----- - --------------------------END INCLUDED TEXT-------------------- You have received this e-mail bulletin as a result of your organisation's registration with AusCERT. The mailing list you are subscribed to is maintained within your organisation, so if you do not wish to continue receiving these bulletins you should contact your local IT manager. If you do not know who that is, please send an email to auscert@auscert.org.au and we will forward your request to the appropriate person. This security bulletin is provided as a service to AusCERT's members. As AusCERT did not write the document quoted above, AusCERT has had no control over its content. The decision to use any or all of this information is the responsibility of each user or organisation, and should be done so in accordance with site policies and procedures. NOTE: This is only the original release of the security bulletin. It may not be updated when updates to the original are made. If downloading at a later date, it is recommended that the bulletin is retrieved directly from the original authors to ensure that the information is still current. Contact information for the authors of the original document is included in the Security Bulletin above. If you have any questions or need further information, please contact them directly. Previous advisories and external security bulletins can be retrieved from: http://www.auscert.org.au/Information/advisories.html If you believe that your system has been compromised, contact AusCERT or your representative in FIRST (Forum of Incident Response and Security Teams). Internet Email: auscert@auscert.org.au Facsimile: (07) 3365 7031 Telephone: (07) 3365 4417 (International: +61 7 3365 4417) AusCERT personnel answer during Queensland business hours which are GMT+10:00 (AEST). On call after hours for emergencies. -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv Comment: ftp://ftp.auscert.org.au/pub/auscert/AUSCERT_PGP.key iQCVAwUBO16dLSh9+71yA2DNAQHaxQP+J2fdQ/Z4NwmTfoxXoxT/1WxAg9P6c19y ZxwHZIIhNfRxA5hOvGtGJqm0EAqyrdI7h4UZExdnbo5GJsds30gBNPlINAiG1Yvm yypM/LNFrjICfCoFD0njxVU0op/kN5LesibbXqzkQAkIWQFHoEdYKqX6UWycWPM4 UeOJFE7lyJU= =TVxh -----END PGP SIGNATURE-----