2009 11 Ssh Injection

Mirror of:
http://www.core-sdi.com/advisories/ssh-advisory.htm at 2001-06-25
Mirror from:
http://web.archive.org/web/20010625055846/http://www.core-sdi.com/advisories/ssh-advisory.htm

[code]

CORE SDI S.A. Security Advisory

Buenos Aires, Argentina <http://www.core-sdi.com>

June 11th, 1998

SSH INSERTION ATTACK

This advisory addresses a vulnerability present in the ssh software package that allows an attacker to execute arbitrary commands on the ssh server or otherwise subvert an encrypted ssh channel with arbitrary data.

Problem description

SSH (secure shell) is a program that provides strong authentication and secure communications over insecure channels.
its widely used for logging in to remote computers, file transfers and tunneling of other protocols over the encrypted comunications channel.
All communications are automatically and transparently encrypted. Encryption is also used for integrity checking purposes although current implementations rely on a 32 bit cyclic redundancy check to perform integrity checks after the decryption of an incoming packet.
Encryption is done using one of a list of supported algorithms that is exchanged between client and server.
Upon conection establishment client and server perform a protocol negotiation that includes mutual authentication, selection of a cipher supported by both ends for subsequent communications and of a session key to be used with the cipher. encryption is then turned on using the selected cipher and session key, all further communications are encrypted.

Currently supported ciphers are:

- blowfish

bruce schneier's block cipher using a 128 bit key

- idea

a 128 bit block cipher

- des

The data encryption standard 56-bit block cipher

- triple des (3des)

A three-key triple-des algorithm with an effective key lenght of 112 bits.

- arcfour

An rc4 compatible stream cipher using a 128 bit key the use of these algorithms in cbc (cipher block chaining) or cfb (cipher feedback 64 bits) modes with the crc-32 integrity check allows to perform a known plaintext attack (with as few as 16 bytes of known plaintext) that permits the insertion of encrypted packets with any choosen plaintext in the client to server stream that will subvert the integrity checks on the server and decrypt to the given plaintext, thus allowing an attacker to execute arbitrary commands on the server.
The attack is equally feasible on the server to client stream, although it just gives the ability to send arbitrary data the user's terminal. the implications of such an attack are probably not as severe as an attack to the server side of the connection but must be taken in consideration in the process of applying fixes.

Technical details

After the protocol identification phase, where the server sends a plaintext string specifiying its the protocol and software versions, all communication is done encapsulating data in a packet format described as 'the binary packet protocol' [1]

The packet layout is as follows:

32 24 16 8 0

+--+-—+-+-—+

| data length (bytes) |

+--+-—+-+-—+

| 1 to 8 bytes of padding |

= =

+--+-—+-+-—+

| type | |

+--+ +

| |

= data =

| |

+--+-—+-+-—+

| crc-32 |

+--+-—+-+-—+

Data length: length in bytes of the given packet, not including the length field and padding padding : 8 - (length mod 8) bytes of random data, putting random data at the beginning of the packet is an effort to make known plaintext attacks more difficult.

packet type: an 8-bit unsigned byte.

data : length - 5 data bytes

crc-32 : the four 8-bit check bytes, msb first. the crc is

Computed before any encryption encryption is done on the padding+type+data+crc fields, the length field is never encrypted. The encrypted portion of the packet has a length that is always a multiple of 8 bytes.
Knowning certain characteristics of the cipher modes being used, i.e. cbc, with a known plaintext an attacker is able to build a custom ssh packet (i.e. a type ssh_cmsg_stdin_data packet) with the padding bytes computed in a way such that the next 8-bytes of the encrypted data will decrypt to arbitrary plaintext. In this particular case, the decrypted data will correspond to the type field and 7 data bytes.
After the 16 bytes (padding+type+7 data bytes) the attacker would include a variable length of data bytes specifically crafted to produce a valid crc-32 field for the whole packet once it is decrypted.
This attack and several variations using the same technique can be performed due to the usage of weak integrity check schemes, in particular crc-32 has certain properties that allows the attacker to forge a valid crc for her corrupted packet.
However, for the attack to succeed the attacker must be able to perform an active network attack, by either intercepting the legit ssh connection at any point between the client and server and injecting a forged packet or by performing a tcp session hijack attack.
Such an attack is described in [6] and for ssh the two methods of tcp desynchronization can be used. in particular the method described as "null data desynchronization" can be carried out using packets of type ssh_cmsg_ignore.
Note that the new revision for the ssh protocol, proposed and published as internet drafts [2],[3],[4] [5] makes use of cryptographycally strong message authentication codes for integrity checks that wont fail to these attacks.
Its is important to mention that despise the vulnerabilities found in the ssh protocol, it still remains to be a much more secure alternative to telnet, rsh and rlogin applications.
[1] "the ssh (secure shell) remote login protocol", t. ylonen helsinki university of technology. november 15th 1995
(draft expired on may 15th, 1996)
included as the file ./rfc in the ssh distribution
<http://www.cs.hut.fi/ssh>
[2] "ssh protocol architecture", draft-ietf-secsh-architecture-01.txt.gz
t. ylonen, t. kivinen, m. saarinen. ssh. november 7th, 1997
[3] "ssh connection protocol", draft-ietf-secsh-connect-03.txt.gz
t. ylonen, t. kivinen, m. saarinen. ssh. november 7th, 1997
[4] "ssh authentication protocol", draft-ietf-secsh-userauth-03.txt.gz
t. ylonen, t. kivinen, m. saarinen. ssh. november 7th, 1997
[5] "ssh transport layer protocol",draft-ietf-secsh-transport-03.txt.gz
t. ylonen, t. kivinen, m. saarinen. ssh. november 7th, 1997
(drafts expired on may 7th, 1998)
all internet drafts are available at <ftp://ftp.isi.edu/internet-drafts/>
[6] "simple active attack against tcp", laurent joncheray, merit networks inc., 5th usenix security simposium. 1995.

Impact:

An attacker with access to the encrypted ssh stream may insert encrypted blocks in the stream that will decrypt to arbitrary commands to be executed on the ssh server.

Fix information:

Upgrade to the upcoming ssh protocol version 2. commercial f-secure ssh users contact data fellows inc. for information on how to upgrade to f-secure 2.0 notice that version 2 of the ssh protocol is not compatible with the previous version, thus you will need to upgrade all the ssh clients as well.
In the meantime, upgrade to version 1.2.25 of ssh, which fixes the problem. the ssh 1.2.25 distribution can be obtained from:
<ftp://ftp.cs.hut.fi/pub/ssh/ssh-1.2.25.tar.gz>
F-secure ssh version 1.3.5 fixes this security problem.
If you are using the commercial data fellows ssh package and you have a support contract, you can obtain the 1.3.5 from your local retailer.
Users without a support contract can obtain a patch which fixes this problem from:
<http://www.datafellows.com/f-secure/support/ssh/bug/su134patch.html>.
A patch for the free ssh 1.2.23 distribution and the complete ssh 1.2.23 package, with the patch applied, can be obtained at:
<http://www.core-sdi.com/ssh>
Below are the md5 hashes for the provided files

md5 (ssh-1.2.23.patch) = 6bdb63d57f893907191986c5ced557ab

md5 (ssh-1.2.23-core.tar.z) = fffb52122aae26c1f212c051a305a310

md5 (ssh-1.2.23-core.tar.gz) = f9509ba0f0715637805c6b116adc0869

Vulnerable systems:

All systems running implementations of ssh using protocol version 1.x are vulnerable.
This includes ssh software versions up to 1.2.23 and f-secure ssh 1.3.4 to obtain the version of the ssh server that is running on a given host you can issue the following commands:

$ telnet <ip address> 22

trying <ipaddress>…

connected to <ipaddress>.

escape character is '^]'.

ssh-1.5-1.2.23

\ / \-—— software version

|--— protocol version

^]

telnet> close

connection closed.

$ exit

Additional information:

These vulnerabilities were discovered by Ariel Futoransky and Emiliano Kargieman >
Core SDI wishes to thank the ssh maintainers Tatu Ylonen and Tero Kivinen for their quick response to the issues rised by this advisory.
Olli Voima of Data Fellows Inc. provided the fix information for the f-secure products.
Comments and questions regarding this advisory should be sent to:
Ariel Futoransky
Emiliano Kargieman
For more information about core sdi s.a. contact <moc.ids-eroc|eroc#moc.ids-eroc|eroc> or visit <http://www.core-sdi.com>

You can contact Core SDI S.A.<moc.ids-eroc|sbaleroc#moc.ids-eroc|sbaleroc> using the the following pgp key:

type bits/keyid date user id pub 1024/cf4e0cf5 1998/05/18 corelabs <moc.ids-eroc|sbaleroc#moc.ids-eroc|sbaleroc>

-begin pgp public key block-

version: 2.6.3ia

comment: requires pgp version 2.6 or later.

mqcnazvgfmgaaaeeajsfjndvcwiac4ak0ckeimubliwzsrvdrhjpqioyt/7kxxio

dzybr53fwmejyt8chxrl08i0r9rcufecnaez6xcalbhqukxdcll/czk80ccdscs5

trczggoebnxqioyvbvi4gnyhbs5wuvmh3b/mvrftvhmrruy9m/no/lnptgz1aaur

tcbdt1jftefcuya8y29yzwxhynnay29yzs1zzgkuy29tpokalqmfedvgfmn5zvy5

z04m9qebc6ed/0szt3f54jtvkzg3ezq8g60hvaw4/a5ti6i3oze6jsxxzgp6pa1x

i0jazpkauspo0mlc7bcijmkneuuhnn3xtn5yxtft0aeoot1mivv4bsdeub3x257g

3+vr8sxgk44vm4tfun8f/2dno/00yyp9rd3zq8tl+gmr5vxnlviziduh

=ulrg

-end pgp public key block-

Copyright notice:

The contents of this advisory are copyright (c) 1998 CORE SDI S.A., and may be distributed freely provided that no fee is charged for this distribution, and proper credit is given.

copyright ©1999-2000
Core SDI S.A.
webmaster
[/code]

O ile nie zaznaczono inaczej, treść tej strony objęta jest licencją Creative Commons Attribution-ShareAlike 3.0 License