From: SecuriTeam <support@securiteam.com.>
To: [email protected]
Date: 19 Dec 2006 10:46:32 +0200
Subject: [UNIX] Sun Microsystems Solaris ld.so 'doprf()' Buffer Overflow Vulnerability
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20061219164601.419F7582A@mail.tyumen.ru.>
X-Virus-Scanned: antivirus-gw at tyumen.ru
X-Spam-Status: No, hits=2.011 tagged_above=2 required=5
tests=DATE_IN_PAST_06_12, MSGID_FROM_MTA_ID
X-Spam-Level: **
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
- - - - - - - - -
Sun Microsystems Solaris ld.so 'doprf()' Buffer Overflow Vulnerability
SUMMARY
Solaris is a UNIX operating system developed by Sun Microsystems. Local
exploitation of a buffer overflow vulnerability in ld.so could potentially
allow a non root user to execute arbitrary code as root.
DETAILS
Vulnerable Systems:
* Solaris 10 for both x86 and SPARC
ld.so is vulnerable to a buffer overflow in its internal doprf()
formatting function. A fixed size stack buffer is used to store the
precision padding characters when printing out a numerical format
specifier. The vulnerable code was taken from the OpenSolaris source, and
is as follows:
size_t
doprf(const char *format, va_list args, Prfbuf *prf)
{
char c;
char *bp = prf->pr_cur;
char *bufend = prf->pr_buf + prf->pr_len;
size_t bufsiz = prf->pr_len;
while ((c = *format++) != '\0') {
if (c != '%') {
PUTC(c);
} else {
int base = 0, flag = 0, width = 0, prec = 0;
size_t _i;
int _c, _n;
char *_s;
int ls = 0;
* snip *
if (base) {
1] char local[20];
const char *string =
MSG_ORIG(MSG_STR_HEXNUM);
size_t ssize = 0, psize = 0;
const char *prefix =
MSG_ORIG(MSG_STR_EMPTY);
u_longlong_t num;
* snip *
/*
* Convert the numeric value into a local
* string (stored in reverse order).
*/
_s = local;
2] do {
*_s++ = string[num % base];
num /= base;
ssize++;
} while (num);
/*
* Provide any precision or width padding.
*/
if (prec) {
/* LINTED */
_n = (int)(prec - ssize);
3] while (_n-- > 0) {
*_s++ = '0';
ssize++;
}
}
1) This is the stack buffer that will later be overflowed.
2) Here the given number is stored into the buffer. There is no chance
for an overflow here as the maximum number of digits in a long long int is
20 bytes.
3) However in this loop an attacker can freely overwrite the stack with
'0' (0x30) bytes.
This vulnerability would normally not be able to be triggered by a non
root user. The doprf() function is only supposed to be passed format
strings from a message file owned by root. However, when this
vulnerability is combined with the ld.so directory traversal vulnerability
any user can pass arbitrary format strings to the doprf() function.
Analysis:
Successful local exploitation allows an attacker to execute arbitrary code
as root on the affected host by running a setuid binary.
Exploitation is difficult due to the limited data value with which the
buffer can be overflowed. It is necessary to have valid memory mapped at
an address with a most significant byte of 0x30, for example 0x30fffff0.
In our tests on both x86 and SPARC architectures we were unable to achieve
this. With a different memory layout exploitation may be possible. On
x86, it also may be possible to overwrite the low byte of a saved frame
pointer if the registers are allocated in a different way.
Vendor Response:
Sun Microsystems has addressed this problem with new patches. More
information can be found in Sun Alert #102724. This alert can be found at:
<http://sunsolve.sun.com/search/document.do?assetkey=1-26-102724-1>
http://sunsolve.sun.com/search/document.do?assetkey=1-26-102724-1
Disclosure Timeline:
10/24/2006 - Initial vendor notification
10/27/2006 - Initial vendor response
12/12/2006 - Coordinated public disclosure
ADDITIONAL INFORMATION
The information has been provided by
<mailto:idlabs-advisories@idefense.com.> iDefense Labs Security Advisories.
The original article can be found at:
<http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=450>
http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=450
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: [email protected]
In order to subscribe to the mailing list, simply forward this email to: [email protected]
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.