Bug#158637: [dendler@idefense.com: iDEFENSE Security Advisory: Linuxconf locally exploitable buffer overflow]

2002-11-22 Thread Colin Watson
severity 158637 important
thanks

On Sat, Sep 21, 2002 at 02:38:55PM +0200, Michael Banck wrote:
> tags 158637 + patch
> thanks
> 
> As I stated, debian's linuxconf package should not be vulnerable, as it
> is not installed setuid root.
> 
> Nevertheless, I've backported the patch from the latest upstream
> version, which makes the exploit[1] fail even if you happen to set
> linuxconf setuid root.

Would you mind uploading this? linuxconf is orphaned, and nobody has yet
offered to maintain it.

Since, as you say, we don't install linuxconf setuid root, I've
downgraded the bug in the meantime.

Thanks,

-- 
Colin Watson  [EMAIL PROTECTED]



Bug#158637: [dendler@idefense.com: iDEFENSE Security Advisory: Linuxconf locally exploitable buffer overflow]

2002-09-21 Thread Michael Banck
tags 158637 + patch
thanks

As I stated, debian's linuxconf package should not be vulnerable, as it
is not installed setuid root.

Nevertheless, I've backported the patch from the latest upstream
version, which makes the exploit[1] fail even if you happen to set
linuxconf setuid root.

cheers,

Michael

-- 
http://www.securiteam.com/exploits/5CP0F0K8BW.html
diff -Naur linuxconf-1.28r3/translate/translat.cc 
linuxconf-1.28r4.orig/translate/translat.cc
--- linuxconf-1.28r3/translate/translat.cc  1999-12-13 04:18:48.0 
+0100
+++ linuxconf-1.28r4.orig/translate/translat.cc 2002-08-19 20:45:48.0 
+0200
@@ -85,6 +85,7 @@
}
 }
 static char *pterr = NULL;
+#define MAXERR_SIZE 2000
 /*
Print an error message and increment the err counter
 */
@@ -92,7 +93,7 @@
 {
va_list list;
va_start (list,msg);
-   pterr += vsprintf (pterr,msg,list);
+   pterr += vsnprintf (pterr,MAXERR_SIZE,msg,list);
va_end (list);
 }
 
@@ -196,13 +197,13 @@
Load the message dictionnary.
Terminate the application if any error.
 */
-int translat_load (
+static int translat_loaderr (
const char *basepath,   // Directory holding dictionnaries
const char *basename,   // base name of the dictionnary
// the language 
selection will supply
// the extension.
const char *lang,   // Suffix for the language
-   char *errmsg)   // Will contain the error message
+   char errmsg[MAXERR_SIZE])   // Will contain the 
error message
 {
int ret = -1;
errmsg[0] = '\0';
@@ -250,8 +251,8 @@
// the extension.
const char *lang)
 {
-   char errmsg[2000];
-   if (translat_load (basepath,basename,lang,errmsg)==-1){
+   char errmsg[MAXERR_SIZE];
+   if (translat_loaderr (basepath,basename,lang,errmsg)==-1){
fprintf (stderr,"%s",errmsg);
exit (-1);
}
@@ -298,10 +299,10 @@
}
const char *lang = deflang;
const char *lang_env = getenv(envlangvar);
-   if (lang_env != NULL) lang = lang_env;
+   if (lang_env != NULL && strlen(lang_env)<=5) lang = lang_env;
 
-   char errmsg[2000];
-   if (translat_load (basepath,basename,lang,errmsg)==-1){
+   char errmsg[MAXERR_SIZE];
+   if (translat_loaderr (basepath,basename,lang,errmsg)==-1){
if (strcmp(lang,"eng")!=0){
bool showerr = getenv ("SHOWDICERR")!=NULL;
if (showerr){


Bug#158637: [dendler@idefense.com: iDEFENSE Security Advisory: Linuxconf locally exploitable buffer overflow]

2002-08-28 Thread Matt Zimmerman
Package: linuxconf
Severity: grave
Tags: security

- Forwarded message from David Endler <[EMAIL PROTECTED]> -

Date: Wed, 28 Aug 2002 11:58:53 -0400
From: "David Endler" <[EMAIL PROTECTED]>
To: bugtraq@securityfocus.com, [EMAIL PROTECTED]
Subject: iDEFENSE Security Advisory: Linuxconf locally exploitable buffer 
overflow

 
iDEFENSE Security Advisory 08.28.2002
Linuxconf locally exploitable buffer overflow vulnerability

DESCRIPTION 

A vulnerability exists in linuxconf which if the 
LINUXCONF_LANG environment variable processes at least 964 
bytes of data, a buffer overflow occurs, thereby allowing an 
attacker to modify the return address of the function and 
execute arbitrary code with root permissions.  iDEFENSE has an 
exploit that allows a local user to launch a root shell on Red 
Hat Linux 7.3 by targeting the latest version of linuxconf 
1.28r3. 


ANALYSIS

According to the author of Linuxconf, Jacques Gelinas 
[EMAIL PROTECTED], "linuxconf picks the variable and uses it 
to format a path using snprintf. This works fine. In fact, the 
receiving buffer is PATH_MAX large so even a 1000 characters 
variable won't overflow it and even if this was the case, 
snprintf would do its work. 

Once the path is formatted, the corresponding file is opened. 
If the file do not exist, an error message is formatted in a 
string. This was the problem and sprintf was used instead of 
snprintf there.

There are two fixes. One is to use snprintf to format error 
message at this place and the other is to look for appropriate 
length for this variable (max 5 characters) immediately when it 
is found."


DETECTION

This vulnerability affects any version of linuxconf 
(essentially 6 years worth of distributions) that is installed 
setuid root.  Generally, the four ways in which this utility 
can be installed setuid are:

1.) Shipped by vendor (Red Hat does not ship linuxconf 
setuid, but Mandrake does as do other linux vendors)
2.) Installed by RPM from the main site 
(http://www.solucorp.qc.ca/linuxconf/) for each particular 
linux OS (installs setuid root by default)
3.) Installed by source code also from main site 
(http://www.solucorp.qc.ca/linuxconf/) but prompts for whether 
to install setuid root 
4.) Installed in ways 1, 2, or 3 and manually set to setuid 
root by the user for added functionality.


WORKAROUND

Remove the setuid bit from the linuxconf binary:

$ chmod u-s /bin/linuxconf


VENDOR RESPONSE

iDEFENSE immediately contacted Jacques Gelinas and he provided 
a source code patch.  iDEFENSE verified that the vulnerability 
is mitigated in the newer distribution (1.28r4) of linuxconf.  

An updated version (1.28r4) of linuxconf which addresses this 
vulnerability will be available on August 28, 2002 at
http://www.solucorp.qc.ca/linuxconf/ .

Affected Linux vendors will make updates available 
August 28th, 2002.


DISCLOSURE TIMELINE


August 9, 2002 - Exclusively disclosed to iDEFENSE
August 19, 2002 - Disclosed to Vendor
August 19, 2002 - Disclosed to iDEFENSE clients
August 21, 2002 - Announcement to [EMAIL PROTECTED]
August 28, 2002 - Coordinated public disclosure by Linux vendors,  
Linuxconf maintainer, and iDEFENSE


CREDIT

This issue was exclusively disclosed to iDEFENSE by Euan Briggs
([EMAIL PROTECTED])


http://www.idefense.com/contributor.html


- -dave


David Endler, CISSP
Director, Technical Intelligence
iDEFENSE, Inc.
14151 Newbrook Drive
Suite 100
Chantilly, VA 20151
voice: 703-344-2632
fax: 703-961-1071

[EMAIL PROTECTED]
www.idefense.com


- End forwarded message -

-- 
 - mdz