Subject: Small modification to allow application proxies

From: Dan Shearer <[email-masked]>
Date: Sat, 4 Aug 2001 23:52:53 +0930 (CST)

This proposes a modification to
http://www.ietf.org/internet-drafts/draft-ietf-secsh-transport-09.txt

The change affects the definition of the header exchange, and I have not
found a record of it being previously discussed. My apologies if it has
been. I am not a security protocols expert (far from it) just a user
hacking together a solution.

Section 3.2 "Protocol Version Exchange" says:

  When the connection has been established, both sides MUST send an
  identification string of the form "SSH-protoversion-softwareversion
  comments"...
     :
  The server MAY send other lines of data before sending the version
  string.  Each line SHOULD be terminated by a carriage return and
  newline.  Such lines MUST NOT begin with "SSH-", and SHOULD be encoded
  in ISO-10646 UTF-8 [RFC-2279] (language is not specified).  Clients MUST
  be able to process such lines; they MAY be silently ignored, or MAY be
  displayed to the client user; if they are displayed, control character
  filtering discussed in [SSH-ARCH] SHOULD be used.  The primary use of
  this feature is to allow TCP-wrappers to display an error message before
  disconnecting.

I would like to suggest that the client be allowed to optionally send
other lines of data in the same way the servers can, ie a paragraph like
so:

  The client MAY send other lines of data before sending the version
  string.  Each line SHOULD be terminated by a carriage return and
  newline.  Such lines MUST NOT begin with "SSH-", and SHOULD be encoded
  in ISO-10646 UTF-8 [RFC-2279] (language is not specified).  Servers MUST
  be able to process such lines up to a limit of 4096 8-bit characters 
  after the newline; they MAY be silently ignored, or MAY be used to 
  perform some pre-processing of the connection attempt. If they are
  if they are displayed or logged, control character filtering discussed in 
  [SSH-ARCH] SHOULD be used.  The primary use of this feature is to allow 
  application-level proxies for ssh, whereby multiple, different servers
  can be accessed via a single IP address by specifying an appropriate
  payload such as a hostname or other mapping supported by the proxy. The
  syntax of any payload is not specified.

I have invented an arbitary 4096 character limit for safety, although I
don't really know what it should be. I observe that there is no such limit
in the original which says "Clients MUST be able to process such lines". I
suspect this allows the possibility of a malicious server or packet
insertion attack tying up an unsuspecting client, or otherwise confusing
it. I have not checked to see if this issue has been discussed before on
the secsh list; it probably has been, since it is rather obvious!

When I first started playing with openssh I fiddled with letting the
client specify version information such as a DNS name, however this isn't
a good solution for many reasons. UTF-8 DNS names would break the length
limit for a start. I don't see that this proposal weakens the protocol,
because the sensible way to implement an application proxy is just to send
on all information including the extended version string to the host the
other side of the proxy as specified by the payload.

Examples
--------

The following examples assume a network like this:

   Internet        ssh application proxy        Internal .test network

                     ip address 1.2.3.4         girafe (10.0.0.1)
                     DNS A bouchon.test        
                     CNAME girafe.test         

They also assume a -z parameter to the ssh client which puts everything
that follows -z in the extended version string. Sessions are initiated
from random hosts on the Internet.

   ssh -z girafe.test

would make a connection on port 22 to 1.2.3.4, and the proxy server would
see there was a payload. Since "girafe.test" resolves on the internal
network's DNS, the connection attempt is forwarded to 10.0.0.1 (if policy
allows.)

  ssh -z bouchon.test

would connect to port 22 on 1.2.3.4, and the proxy server would see that
the name in the payload is its own name, and (if policy allows) this is
forwarded on to the local machine just like any other connection. Either
there is an ssh daemon running on a port other than 22, or the proxy
server is also an ssh daemon (possibly inadvisable, depends) or the ssh
daemon is running on port 22 bound to another interface on the same
machine as 1.2.3.4.

  ssh -z zero.example

would initiate a connection to the machine zero.example, which is not
running an ssh proxy and would completely ignore the payload, proceeding
with an ordinary connection attempt. Apart from the transmited version
payload, everything in this example would proceed as if the command 
ssh zero.example had been used instead.
 
Benefits
--------

I see the benefits of this addition to be mainly:

  1. Networks behind NAT firewalls will be able to expose internal
     ssh services without exposing any more IP addresses. This increases
     convenience for such sites, not security

  2. An application proxy for ssh will become practical. This could
     increase security (even for sites which are not behind
     NAT firewalls) and it certainly allows some forms of logging
     and control to be centralised that would otherwise be distributed at 
     the ssh connection endpoints inside a network

  3. Potential to consolidate services, for similar reasons that 
     web hosters like to run many virtual servers from one IP address

The proxy could choose to perform transformations on the ssh stream rather
than just passing it on.

--
Dan Shearer
Open Source Manager
Mob: +61 411 49 1800
Tel: +61 8 8130 3104
[email-masked]

---

From: Bill Sommerfeld <[email-masked]>
Date: Mon, 06 Aug 2001 16:48:48 -0400

It's not clear to me why it would be necessary to change servers this
way; an application-layer proxy which required the client to prefix
the connection with some sort of control message could strip the
prefix from the stream before forwarding the rest to the eventual
destination, leaving the protocol, as seen on the outside of the
application proxy, unchanged.

A worked example of this is, of course, the SOCKS proxying protocol..

					- Bill

---

From: Dan Shearer <[email-masked]>
Date: Tue, 7 Aug 2001 07:38:35 +0930 (CST)

On Mon, 6 Aug 2001, Bill Sommerfeld wrote:

> way; 

Actually it isn't, you are right. The essence of my proposal can be
entirely met by modifying the client. Right now it is only the server
which can send extra information after the version string. If a client
wants to pass on meta-info of some sort it can't, unless it is with a
limited bodge in the comment string. 

It would be very nice if a standard ssh client could be used from any
platform to connect to such an application-layer proxy without any
additional infrastructure, just as any web browser can connect to a
virtual web server because the protocol passes information about which
host is requested.

However this would mean that if a client chose to send this information
every time by default (on the off-chance that it might be an application
proxy that it was connecting to) then any non-proxies would reject the
connection attempt because of extraneous data. Maybe that is a good thing.

I'll submit my implementation to the appropriate place and see what they
say. 

> an application-layer proxy which required the client to prefix

Thus creating a client (or a mode of a client, such as I proposed) that
would only work with a proxy. That's ok I guess.

--
Dan Shearer
Open Source Manager
Mob: +61 411 49 1800
Tel: +61 8 8130 3104
[email-masked]