SecurityTracker.com
Keep Track of the Latest Vulnerabilities
with SecurityTracker!
    Home    |    View Topics    |    Search    |    Contact Us    |    Help    |   

SecurityTracker
Archives


Welcome to SecurityTracker!
 
Click to Sign Up
Sign Up
Sign Up for Your FREE Weekly SecurityTracker E-mail Alert Summary
Instant Alerts
Buy our Premium Vulnerability Notification Service to receive customized, instant alerts
Affiliates
Put SecurityTracker Vulnerability Alerts on Your Web Site -- It's Free!
Partners
Become a Partner and License Our Database or Notification Service
Report a Bug
Report a vulnerability that you have found to SecurityTracker
bugs
@
securitytracker.com

Sign Up!





Category:  Application (Generic)  >  sredird Vendors:  InfoTecna s.r.l.
sredird LogMsg() Format String Bug and HandleCPCCommand() Buffer Overflow May Let Remote Users Execute Arbitrary Code
SecurityTracker Alert ID:  1011038
SecurityTracker URL:  http://securitytracker.com/id?1011038
CVE Reference:  GENERIC-MAP-NOMATCH   (Links to External Site)
Date:  Aug 24 2004
Impact:  Execution of arbitrary code via network, Root access via network, User access via network
Version(s): 2.2.1
Description:  Two vulnerabilities were reported in sredird. A remote user can gain root access on the target system.

Max Vozeler reported that there is a format string flaw in the LogMsg() function in 'sredird.c'. User-supplied data can be passed to the LogMsg() function without a formatting string by the HandleCPCCommand() function. A remote user can cause arbitrary code to be executed with the privileges of the sredird process. On some distributions, this may be root privileges.

It is also reported that there is a stack overflow in the HandleCPCCommand() function. A remote user may be able to trigger the overflow to execute arbitrary code.

Impact:  A remote user can execute arbitrary code with the privileges of sredird.
Solution:  No upstream solution was available at the time of this entry.

A fix is pending for sredird on Debian GNU/Linux.

Vendor URL:  www.ibiblio.org/pub/Linux/system/serial/sredird-2.2.1.tar.gz (Links to External Site)
Cause:  Boundary error, Input validation error, State error
Underlying OS:  Linux (Any), UNIX (Any)
Reported By:  Max Vozeler <max@hinterhof.net>
Message History:   None.


 Source Message Contents

Date:  Fri, 20 Aug 2004 20:00:22 +0200
From:  Max Vozeler <max@hinterhof.net>
Subject:  sredird: remote root vulnerabilities

 
 
Package: sredird
Version: 2.2.1-1
Severity: critical
Tags: patch
 
Hi,
 
these bugs still apply.
 
Cheers,
Max
 
-- 
308E81E7B97963BCA0E6ED889D5BD511B7CDA2DC
 
----- Forwarded message from Max Vozeler <max@hinterhof.net> -----
 
From: Max Vozeler <max@hinterhof.net>
To: russell@coker.com.au
Cc: team@security.debian.org
Subject: sredird vulnerabilities
Date: Fri, 30 Jul 2004 14:52:24 +0200
User-Agent: Mutt/1.5.6+20040523i
 
Hi Russell,
 
[ CCing Security Team for vulns in the testing version ]
 
there are two bugs in sredird that can introduce security problems,
potentially leading to a remote root compromise. Affected in Debian is
the testing/unstable sredird 2.2.1-1.
 
Feel free to forward this info as you like. Unless you want me to delay
disclosure to the BTS for some reason, or the fixed package has already
entered testing by then, I'll file +security bugs in 10 days or so.
 
There are two bugs:
 
LogMsg() format string bug
--------------------------
 
sredird-2.2.1/sredird.c:
 
   458	/* Generic log function with log level control. Uses the same log levels
   459	of the syslog(3) system call */
   460	void LogMsg(int LogLevel, const char * const Msg)
   461	  {
   462	    if (LogLevel <= MaxLogLevel)
   463	      syslog(LogLevel,Msg);
   464	  }
 
The log buffer in Msg is given to syslog() as format control string. This
can lead to overwriting of any memory locations in case the content of Msg
is controllable by an attacker. There is in fact one such place where the
input to LogMsg() is constructed from data as supplied by the client:
 
  1365	/* Handling of COM Port Control specific commands */
  1366	void HandleCPCCommand(BufferType *SockB, int PortFd, unsigned char * Command, size_t CSize)
  1367	  {
  1368	    char LogStr[TmpStrLen];
  1369	    char SigStr[TmpStrLen];
 
  ..
 
  1376	    /* Check wich command has been requested */
  1377	    switch (Command[3])
  1378	      {
  1379	        /* Signature */
  1380	        case TNCAS_SIGNATURE:
 
  ..
 
  1391	              /* Received client signature */
  1392	              strncpy(SigStr,(char *) &Command[4],CSize - 6);
  1393	              sprintf(LogStr,"Received client signature: %s",SigStr);
  1394	              LogMsg(LOG_INFO,LogStr);
 
The canonical fix would be to add an explicit "%s" format string to the
syslog() call in LogMsg(). (See attached sredird-log-fmt.diff)
 
HandleCPCCommand() stack overflow
---------------------------------
 
Affected is the last chunk of code in HandleCPCCommand() shown above.
LogStr is not large enough to store the largest possible output from
sprintf(). CSize is limited to 254 by the caller, minus 6, makes a max.
SigStr length of 248 bytes. After the sprintf() with 27 or so non-format
characters, the output can grow to
 
  27 + 248 = 275 bytes
  
.. which is too much for LogStr[255], by 20 bytes or so. This may be 
enough to overwrite precious stuff on the stack like saved eip depending
on stack layout.
 
Why not just replace it with snprintf()? This would solve this problem
for good. See attached patch sredird-hcpcc-bof.diff for example.
 
(There should be a LogStr[sizeof(LogStr)-1] = 0; after the snprintf in
the patch which I forgot to add)
 
Cheers,
Max
 
-- 
308E81E7B97963BCA0E6ED889D5BD511B7CDA2DC
 
--- sredird.c.orig	2004-05-01 21:45:49.000000000 +0200
+++ sredird.c	2004-05-01 21:46:05.000000000 +0200
@@ -460,7 +460,7 @@
 void LogMsg(int LogLevel, const char * const Msg)
   {
     if (LogLevel <= MaxLogLevel)
-      syslog(LogLevel,Msg);
+      syslog(LogLevel,"%s",Msg);
   }
 
 /* Try to lock the file given in LockFile as pid LockPid using the classical
 
--- sredird.c.orig	2004-05-01 22:09:28.000000000 +0200
+++ sredird.c	2004-05-01 22:10:10.000000000 +0200
@@ -1390,7 +1390,7 @@
             {
               /* Received client signature */
               strncpy(SigStr,(char *) &Command[4],CSize - 6);
-              sprintf(LogStr,"Received client signature: %s",SigStr);
+              snprintf(LogStr,sizeof(LogStr)-1,"Received client signature: %s",SigStr);
               LogMsg(LOG_INFO,LogStr);
             }
         break;
 
 
 
 
----- End forwarded message -----
 


Go to the Top of This SecurityTracker Archive Page





Home   |    View Topics   |    Search   |    Contact Us   |    Help

Copyright 2004, SecurityGlobal.net LLC