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

openbsd.ftpd

openbsd.ftpd
Posted Dec 22, 2000
Site openbsd.org

OpenBSD Security Advisory - A one byte buffer overflow bug in ftpd(8) allows remote attackers to execute arbitrary code as root provided they can create a directory.

tags | remote, overflow, arbitrary, root
systems | openbsd
SHA-256 | 0dbdf75b4723fe8bfe9ab6d31f303c851e38ba61ac63eb3664deef47a6b5ed86

openbsd.ftpd

Change Mirror Download
----------------------------------------------------------------------------

OpenBSD Security Advisory

December 18, 2000

Single-byte buffer overflow vulnerability in ftpd

----------------------------------------------------------------------------

SYNOPSIS

A relatively obscure one-byte buffer overflow bug present in ftpd(8) turns
out to be a serious problem, yielding remote users root access under
certain conditions. For a system to be vulnerable, ftpd must have been
explicitly enabled by the administrator (OpenBSD ships with it OFF by
default) and the attacker must have write access to at least one directory.
Therefore, anonymous read-only FTP servers are safe (we recommend applying
the patch regardless, of course). Non-anonymous FTP administrators should
seriously consider using a more secure transport like SSH.

A fix for this problem was committed on December 4th. OpenBSD developers
became aware of a publicly available exploit on December 17th.

----------------------------------------------------------------------------

AFFECTED SYSTEMS

This vulnerability affects OpenBSD versions through 2.8. FreeBSD is
reportedly not vulnerable. NetBSD is vulnerable to the same bug and a patch
was applied to their tree on December 14th.

----------------------------------------------------------------------------

TECHNICAL DETAILS

The offending code is as follows:

char npath[MAXPATHLEN];
int i;

for (i = 0; *name != '\0' && i < sizeof(npath) - 1; i++, name++) {
npath[i] = *name;
if (*name == '"')
npath[++i] = '"';
}
npath[i] = '\0';

In <sys/param.h>, MAXPATHLEN is defined to be 1024 bytes. The for()
construct here correctly bounds variable `i' to be < 1023, such that when
the loop has ended, no byte past npath[1023] may be written with '\0'.
However, since `i' is also incremented in the nested statements here,
it can become as large as 1024, and npath[1024] is past the end of the
allocated buffer space.

----------------------------------------------------------------------------

RESOLUTION

OpenBSD does not ship with ftpd enabled by default. If you are using it,
disable it until you are fixed by editing /etc/inetd.conf and restarting
the inetd(8) daemon.

Then, apply the fix below to your OpenBSD 2.8 source tree. The patch is also
available at https://www.openbsd.org/errata.html (005).

----------------------------------------------------------------------------

REFERENCES

The original bug report,

https://www.geocrawler.com/lists/3/OpenBSD/254/75/4767480/

Security and errata,

https://www.openbsd.org/security.html
https://www.openbsd.org/errata.html

Olaf Kirch discusses one-byte overruns in a post to BUGTRAQ in 1998 with
subject "The poisoned NUL byte",

https://www.securityfocus.com/archive/1/10884

----------------------------------------------------------------------------

CREDITS

This vulnerability was first reported to OpenBSD Kristian Vlaardingerbroek
through the bugs@openbsd.org mailing list. Kristian acknowledged in a later
post that it was Ronald (a.k.a. Scrippie) who originally found the bug.

The fix provided in the original bug report is incorrect. Credit goes to
Jun-ichiro itojun Hagino <itojun@openbsd.org> for applying a safe fix to
the OpenBSD 2.8-current tree. This patch has also been applied to the
stable branch.

----------------------------------------------------------------------------

OPENBSD 2.8 PATCH

Apply by doing:
cd /usr/src
patch -p0 < 005_ftpd.patch

And then rebuild and install ftpd:
cd libexec/ftpd
make obj
make depend
make
make install

Index: libexec/ftpd/ftpd.c
===================================================================
RCS file: /cvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.79
diff -u -r1.79 ftpd.c
--- libexec/ftpd/ftpd.c 2000/09/15 07:13:45 1.79
+++ libexec/ftpd/ftpd.c 2000/12/05 17:06:29
@@ -1959,15 +1959,21 @@
replydirname(name, message)
const char *name, *message;
{
+ char *p, *ep;
char npath[MAXPATHLEN];
- int i;

- for (i = 0; *name != '\0' && i < sizeof(npath) - 1; i++, name++) {
- npath[i] = *name;
- if (*name == '"')
- npath[++i] = '"';
+ p = npath;
+ ep = &npath[sizeof(npath) - 1];
+ while (*name) {
+ if (*name == '"' && ep - p >= 2) {
+ *p++ = *name++;
+ *p++ = '"';
+ } else if (ep - p >= 1)
+ *p++ = *name++;
+ else
+ break;
}
- npath[i] = '\0';
+ *p = '\0';
reply(257, "\"%s\" %s", npath, message);
}
Login or Register to add favorites

File Archive:

November 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close