what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

sredird.txt

sredird.txt
Posted Aug 26, 2004
Authored by Max Vozeler

sredird versions 2.2.1-1 and below suffer from a format string bug and a buffer overflow that may let remote users execute arbitrary code.

tags | advisory, remote, overflow, arbitrary
SHA-256 | b1e0ac8fc476c2edf91a769ccfb968ff2145d0af5c80f3a90373bbf293b01c15

sredird.txt

Change Mirror Download
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 -----


Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close