ssh insertion attack

ssh insertion attack

Advisory ID: 19980612 CORE-SDI-04

CVE Name: CVE-1999-1085

CERT: VU#13877

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

[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

[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:

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:

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:

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 22

trying ...

connected to .

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 or visit, you can contact CORE SDI S.A. at info@core-sdi.com using the following pgp key:

type bits/keyid date user id

pub 1024/cf4e0cf5 1998/05/18 corelabs

-----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.

Locally Exploitable: 
no
Remotely Exploitable: 
no
  • Book Demo

Research Blog