Subject: Clarification regarding x-authentication

From: "Glen Matthews" <[email-masked]>
Date: Mon, 17 Nov 2003 16:10:15 -0500

Hi,

  this is a request for a clarification. 

  I'm looking at section 4.3.1 in the connection protocol - the comment
regarding Requesting X11 Forwarding is that: "It is recommended that the
authentication cookie that is sent be a fake, random cookie, and that the
cookie is checked and replaced by the real cookie when a connection request
is received."

  who should check? The ssh client or the server? And should the ssh client
delve into the first x11 protocol packet for the cookie? I see where it is,
but is that how the authentication should be carried out?

Glen Matthews
Hummingbird

---

From: [email-masked] (Niels Möller)
Date: 17 Nov 2003 22:42:34 +0100

"Glen Matthews" <[email-masked]> writes:

>   who should check? The ssh client or the server?

1. If the ssh client creates the fake cookie and includes it in the
   "x11-req" message, then the ssh client should dig into received X11
   data and check that received cookies are correct. There are at
   least two other ways of doing it:

2. Sending the real cookie. Then neither the client nor the server
   need to look into the X11 datastream, as the real X server will
   check the cookie.

3. Sending an empty cookie in the "x11-req" message. Let the server
   create a fake cookie. For each X11 connection, the server digs into
   the x11 datastream to check and remove the cookie. The client will
   also dig into the X11 connection to insert the real cookie before
   connecting to the real X server.

All ssh implementations I know of do (1). (2) is discouraged, for
security reasons: One should never reveal the real cookie to remote
machines. I think (3) is in some ways cleaner: ssh server and client
have already authenticated each other, so the X11 authentication on
the wire is redundant. But (3) has some drawbacks:

  * both server and client must dig into the X11 protocol.
  
  * since it's not specified what a server should do if it receives an
    empty cookie in the "x11-req", the client can't know if the server
    implementation will behave as described above, and generate a
    suitable random cookie that X clients must use. So the user is
    safer if the client implements (1).

In more general terms, letting the server do the authentication is in
a way making an (X11) client responsible for X11 server security, which
is not good practice.

/Niels