Subject: [TLS] MITM attack on delayed TLS-client auth through renegotiation

From: Martin Rex <[email-masked]>
Date: Wed, 4 Nov 2009 18:28:00 +0100 (MET)

After elaborating so much about the client cert authentication
through renegotiation with Microsoft IIS, I'm beginning to believe
that there is a potential security problem with that scheme,
because it is susceptible to a MITM attack.

How serious the problem is depends on whether and how the client
performs the server identification on the renegotiation TLS handshake.

The problem:  when Microsoft IIS is configured to request a client
certificate after having received the request, then it WILL perform
an unauthenticated request!  Sending the reply back only to the
authenticated client is a poor excuse for acting on an unauthenticated
request.

Attack scenario:

             sess1                                 sess2
  TLS client <--->  rogue TLS server (doing MITM)  <--->  victim MS IIS

The roge TLS server waits for innocent clients to connect and offers
to accept the same TLS client certs than the victim MS IIS server.

If a TLS client with a promising TLS client cert connects (sess1),
then the rogue TLS server establishes an anonymous TLS connection
(sess2) with the victim MS IIS server and sends the request it wants
performed (URL with command parameters) to the victim MS IIS server--
which replys with a Hello Request asking for a full TLS handshake
of an entirely new and independent authenticated TLS session (sess3)

At this point, the rogue TLS server starts relaying the TLS
handshake messages between the TLS client and the victim MS IIS,
i.e. it forwards all handshake messages it receives over sess2
to the client over sess1, and likewise forward all handshake
messages it receives over sess1 to the victim MS IIS over sess2.

The ChangeCipherSpec is the last Handshake message on each
direction that is decrypted/encrypted under the original sess1/sess2
settings, for all further communication, the rogue TLS server (MITM)
will forward the incoming network data 1:1 to the other side
(because that is protected under keys known only to the TLS client
and to the victim MS IIS.

The victim MS IIS server has no means to detect that it has been
attacked.  Whether the TLS client cares about receiving a different
TLS server cert in the renegotiation handshake and what it will
do about it -- if anything, depends entirely on the application
of the TLS client.  At the TLS level, everything looks just fine.

I'm not sure that all clients will repeat the server authentication.
They can be expected to verify the server certificate before sending
off their request.  Depending on the API architecture, they may not
always realize or care that a renegotiation was performed while they
were sitting on SSL_read() waiting for the server reply.

And even if they decide to perform an additional server endpoint
identification, they might be doing it after the renegotiate
handshake has been successfully completed -- a point where the
victim MS IIS has started performing the action requested
in the anonymous request from the MITM.

-Martin

---

From: Nicolas Williams <[email-masked]>
Date: Wed, 4 Nov 2009 16:32:42 -0600

Martin,

You're right, of course, but this attack is easily defeated by the
client checking that the server certificate is the same for the outer
TLS connection as for the inner one.  It's also easily defeated by the
server sending a ChangeCipherSpec in the re-negotiation: the MITM will
not be able to decrypt or tamper with the record layer for the inner
connection (and if the MITM pretends to the client to be the server end
of the inner connection then it will not be able to authenticate as the
client to the real server).

But suppose the MITM can get the client to accept an TLS_DH_anon_*
cipher suite for the outer connection: then there's no way for the
client to ensure that the server end-points of the two connections are
the same.  The best way to defeat this now then is to have the server
*always* send a ChangeCipherSpec in the re-negotiation.

Re-negotiation handshakes are tunneled in the record layer of a previous
TLS connection, and the only links between the two connections (inner
and outer) are the authentication credentials of the two end-points.
Usually the client end-point will be anonymous in the outer connection,
and not anonymous in the inner one.  And usually the server certificate
must be the same in both cases.  Checking that the latter is the case
and/or sending a ChangeCipherSpec in the re-negotiation, is and should
be sufficient; it should also be required.

Another solution would be to use bind the outer connection into the
inner connection's PRF, so as to ensure that the Finished messages can
only check out if both end-points of the inner connection are also the
same end-points for the outer connection.  This is what we call channel
binding.  The additional PRF inputs extension would provide the
necessary channel binding facility.

In general I prefer the channel binding approach because it's easier to
make it work in all cases.  Anon-anon cipher-suites?  No problem.

Note that there is a security consideration here for the TLS channel
bindings then, particularly tls-unique: if the inner and outer channels
are not bound somehow (either by having the same server end-point cert,
or by channel binding of the inner to the outer) then we should want the
TLS channel binding see by the application to be that of the of the
inner channel, _and_ we should want the inner channel's negotiation to
have included a ChangeCipherSpec.

Thanks for bringing this to light.

Nico
--