Date: Tue, 7 Jan 2003 17:08:15 +1000 (EST) From: Keyran Bayliss <k.bayliss@qut.edu.au> To: freebsd-security@FreeBSD.ORG Subject: (AUSCERT ESB-2003.0007) Pine Digital Security Advisory - Integer overflow in FreeBSD kernel (fwd) Message-ID: <20030107170645.B75677@danger.its.dias.qut.edu.au>
next in thread | raw e-mail | index | archive | help
Havn't seen anthing about it on this list yet.... can't see a patch on the site.... ?? K. ---------- Forwarded message ---------- Date: Tue, 07 Jan 2003 11:16:21 +1000 (EST) From: auscert@auscert.org.au To: auscert-subscriber@auscert.org.au Subject: (AUSCERT ESB-2003.0007) Pine Digital Security Advisory - Integer overflow in FreeBSD kernel -----BEGIN PGP SIGNED MESSAGE----- =========================================================================== AUSCERT External Security Bulletin Redistribution ESB-2003.0007 -- Pine Digital Security Advisory Integer overflow in FreeBSD kernel 07 January 2003 =========================================================================== AusCERT Security Bulletin Summary --------------------------------- Product: kernel Vendor: Pine Digital Security Operating System: FreeBSD Impact: Root Compromise Denial of Service Access Required: Existing Account - --------------------------BEGIN INCLUDED TEXT-------------------- - -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 - - ----------------------------------------------------------------------------- Pine Digital Security Advisory - - ----------------------------------------------------------------------------- Advisory ID : PINE-CERT-20030101 Authors : Joost Pol Vendor Informed : 2002-12-30 Issue date : 2003-01-06 Application : Kernel Version(s) : Various Platforms : FreeBSD Availability : http://www.pine.nl/press/pine-cert-20030101.txt - - ----------------------------------------------------------------------------- Synopsis While performing an audit for a customer, Pine Digital Security found an integer overflow in the FreeBSD kernel. Versions FreeBSD: RELENG_4 (aka -STABLE) : not vulnerable after 20021111 RELENG_5_0 (aka -CURRENT) : vulnerable in lseek(2) (199) All current -RELEASE versions : vulnerable in fpathconf(2) (192) OpenBSD/NetBSD: not vulnerable Impact Serious. This integer overflow could cause a system panic, resulting in a Denial-of-Service (DoS). Also, this could be used to escalate privileges or cause the system to disclose (sensitive) files. Description Inside the FreeBSD kernel each file (socket, device or regular file) opened is represented by a file structure (sys/file.h). Amongst other members this structure holds a reference counter (int f_count). This reference counter is increased by the fhold() function and decreased by the fdrop() function. (both in sys/file.h) For example, when a file is open(2)ed or dup(2)ed the reference counter is increased and when the file is close(2)ed again the reference counter is decreased. Once the reference counter reaches zero, the file structure itself is deallocated. Most system calls which perform (blocking) operations on a file will issue a fhold() call to prevent the file from being closed in the middle of an operation. Once the operation is finished the (extra) reference will be released again by issuing a fdrop() call. Inside the fpathconf(2) (192) system call we spotted a condition where a call to fdrop() is missing. When issueing a fpathconf(2) call on a socket it will return with an error condition but it will not release the extra file reference. Due to the missing fdrop() call inside the fpathconf(2) system call is it possible to overflow the reference counter of the file structure (int f_count). FreeBSD -CURRENT suffers from the same problem in another syscall. Exploitability Causing a system panic and privilege escalation have been confirmed. Exploitation of this bug will take time, depending on machine speed and system limits this could vary between hours and days. 1. System Panic A system panic can be caused by issuing around 2^31 calls to fpathconf(2) with a filedescriptor which references a socket. The reference counter (int f_count) will wrap to a negative value and this will cause a panic in close(2). 2. Privilege Escalation It is also possible (although more difficult) to gain root access using this bug. One would open(2) a socket and dup(2) it. One would then issue around 2^32 - 1 calls to fpathconf(2) causing the reference counter to wrap to 1. After closing the original filedescriptor the file structure will be deallocated. At this point the dup(2)ed file descriptor is still hanging around with a file structure pointing to unallocated memory. The final step, which is left as an excercise for the reader, is to have a sensitive file (like /etc/skeykeys) opened and allocated at the previously freed location. Once this happens the dup(2)ed file descriptor is still hanging around providing access to this file. This could result in the escalation of user privileges. Disclaimer Pine Digital Security does not release exploits. Although the missing fdrop() call in fpathconf(2) was noticed before by Nakamura Takayuki <tak@st.rim.or.jp> its impact was severely underestimated. Patches FreeBSD CVS should be updated. References http://www.pine.nl/press/pine-cert-20030101.txt file://usr/include/sys/file.h file://usr/src/sys/kern/kern_descrip.c file://usr/src/sys/kern/vfs_syscalls.c - -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (SunOS) iD8DBQE+GXVR0jbIKvNgu5MRAlEMAJ9hCd/HkUfUsVyriSXTv9YvAChfeQCgtoJo 0AlK0bqR4Qtq0YLZJxiPnFc= =8KfX - -----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 author's website 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/render.html?cid=1980 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 member emergencies only. -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv Comment: http://www.auscert.org.au/render.html?it=1967 iQCVAwUBPhqu7Ch9+71yA2DNAQHXKgP/eaCn13hYy348VjR+bFlFIecxvSFSnC2m up0fom96MkKt1U3pxNKt8Nnt9kk3PKGpCAmoHipQRJ+hV0P9w7IrFWIhv1RSf15l lSSeU4KQxor7zn6j1xPj25Tmtlov1xAFj8LsLrnbYYM8fMG3YoA0TNYI1VAMVDBU WDWAghBU0nI= =2UKi -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030107170645.B75677>