LWN.net Logo

TLS renegotiation vulnerability

By Jake Edge
November 18, 2009

Transport Layer Security (TLS), and its predecessor Secure Sockets Layer (SSL), are commonly used protocols for encrypting internet traffic, so TLS vulnerabilities can potentially affect a wide range of internet services. A recently disclosed flaw in the TLS protocol—though there is some dispute whether TLS is at fault—allows an "injected plaintext" attack against an encrypted session. This allows a "man in the middle" (MITM) attacker to prefix a victim's request with their own data, which gets interpreted by the server as if it came from the victim.

The flaw was disclosed on the Internet Engineering Task Force (IETF) TLS mailing list by Martin Rex of SAP on November 4, but it had actually been discovered two months earlier. Marsh Ray of PhoneFactor, Inc. discovered the problem in early August, but kept it quiet while alerting the IETF and various TLS developers and vendors. Those organizations came together as "Project Mogul" to find a solution to the problem. But once Rex had posted publicly about a possible MITM attack—independently discovered—against TLS (specifically Microsoft's IIS), Ray and his colleague Steve Dispensa released additional information showing that it was a pervasive problem for TLS (including Apache web servers, OpenSSL, GNUTLS, and others).

TLS allows clients and servers to renegotiate various session parameters within the TLS connection. When the renegotiation is done, however, TLS applications still accept data that came in before the renegotiation as if it were in the new security context. That hole allows a MITM attack. By arranging that the last data received is from the attacker, then causing a renegotiation with the victim, the attack effectively prepends the attacker's payload to the victim's request.

While it may sound rather theoretical, there is already a proof of concept (PoC) program available, and that has been adapted into a way to steal Twitter credentials. Other kinds of attacks are possible as well, some of which may exploit other internet protocols that use TLS, for example: SMTP (email), FTP, XMPP (Jabber), and some VPN implementations. Exploiting the vulnerability requires the attacker to control some node in between the client and server, which is not that difficult to do these days because of pervasive WiFi. Users are accustomed to using any available access point—especially if they use encrypted connections for their web/email/etc. connections—and that access point could be compromised.

Injecting the attacker's text into an existing TLS session may not seem like a particularly potent attack, but there are several examples of how it could work. Rex's original disclosure was related to web servers configured to require client certificates for some resources, and not for others, which will often lead to renegotiation. That led some to believe that this relatively rare configuration was required, but subsequent examples and explanations make it clear that there are other ways to cause, and exploit, renegotiation.

To attack a web-based application, the attacker typically would send their prefix to the server, then cause the renegotiation to occur. That renegotiation would actually be done between the victim's client and the server (with the MITM attacker just proxying the traffic). Due to the bug, the server would process the prefix in the new security context that gets established via the renegotiation. So, neither the client nor the server have any idea that this has occurred, and the attacker gets to insert his payload into the the client's secure session.

Eric Rescorla is one of those working on a long-term fix, but he also has a fairly straightforward example of the plaintext injection:

E.g., the attacker would send:
    GET /pizza?toppings=pepperoni;address=attackersaddress HTTP/1.1 
    X-Ignore-This:
And leave the last line empty without a carriage return line feed. Then when the client makes his own request
    GET /pizza?toppings=sausage;address=victimssaddress HTTP/1.1 
    Cookie: victimscookie
the two requests get glued together into:
    GET /pizza?toppings=pepperoni;address=attackersaddress HTTP/1.1 
    X-Ignore-This: GET /pizza?toppings=sausage;address=victimssaddress HTTP/1.1 
    Cookie: victimscookie
And the server uses the victim's account to send a pizza to the attacker.

The Twitter attack uses a similar scheme, but exploits the REST-based API for Twitter. In that case, the attacker's Twitter feed shows the victim's server request, which includes the base64-encoded username and password of the victim. In Thierry Zoller's "TLS/SSLv3 renegotiation vulnerability explained" [PDF]—a comprehensive guide to the problem—there is an example of hijacking email traffic using a similar technique: the attacker prepends SMTP commands to send an email to himself, then leaves the DATA command unterminated, effectively capturing the victim's outgoing email message.

Shortly after the initial disclosure, OpenSSL released a workaround that disabled renegotiation. According to Rescorla, almost all servers could disable renegotiation without impacting any needed functionality, but that doesn't fix the problem on the client side. Clients cannot detect whether the server allows renegotiation because the attacker could always fake a rejection of the renegotiation request.

A more long-term fix has been proposed—that site, ironically, has an invalid SSL certificate—by Rescorla, Ray, Dispensa, and Nasko Oskov of Microsoft. Their proposal would extend TLS to add information to each renegotiation about the previous renegotiation. In that way, clients could detect that their connection is not being negotiated for the first time, which would mean that a MITM had done a TLS negotiation already.

While TLS is the right place to make the fix, Adam Langley is unhappy that TLS is being blamed for the problem. His contention is that the applications are making unwarranted assumptions about what TLS provides. While that may be true, "every single protocol that is layered on top of TLS got this wrong", as Ben Laurie points out.

Zoller's paper also has a good summary of other protocols and programs that use TLS, along with their vulnerability status. It may be a hard vulnerability to exploit, because it requires a MITM position along with an ability to predict the client's traffic, but it is rather serious. As Rescorla and others note, though, MITM attacks simply using an attacker's certificate are generally fairly successful because users are willing to accept any certificate presented to them. It really isn't necessary to go to the lengths that are required to exploit this vulnerability until that changes.

[ Thanks to Tzvetan Mikov who suggested this as a topic shortly after it was made public. ]


(Log in to post comments)

TLS renegotiation vulnerability

Posted Nov 19, 2009 7:05 UTC (Thu) by jimparis (subscriber, #38647) [Link]

> While TLS is the right place to make the fix, Adam Langley is unhappy that TLS is being blamed for the problem. His contention is that the applications are making unwarranted assumptions about what TLS provides.

I understand his point (from TLS point of view, it's two entirely separate sessions, and it's the application that's incorrectly combining the data from these two sessions into one logical stream).

But still, the mechanism is interesting:

Alice asks to negotiate with the server.
- Mallory starts intercepting traffic
- Mallory asks to negotiate with the server.
- Negotiation happens between server and Mallory
- Mallory sends some data
- Mallory requests a renegotiation
- Mallory stops intercepting traffic
Negotiation happens between server and Alice

If TLS had included a concept of "this is the Nth negotiation in this TCP connection", something like this wouldn't have happened because Alice would see 2 and expect 1.

TLS renegotiation vulnerability

Posted Nov 19, 2009 7:48 UTC (Thu) by dlang (✭ supporter ✭, #313) [Link]

so am I understanding properly that this is a problem in TLS, but not in SSLv3?

so if TLSv1 is disabled and instead everyone uses SSLv3 this problem would not exist?

TLS renegotiation vulnerability

Posted Nov 19, 2009 15:44 UTC (Thu) by dtlin (✭ supporter ✭, #36537) [Link]

No, this affects all existing versions of the TLS/SSL protocols, including
- SSL 2.0
- SSL 3.0
- TLS 1.0
- TLS 1.1
- TLS 1.2

TLS renegotiation vulnerability

Posted Nov 19, 2009 7:56 UTC (Thu) by agl (guest, #4541) [Link]

Ben Laurie and I know each other and our respective blog postings make us
look much more pugnacious than we actually are :)

My post was written before the full details of the issue were out (or, at
least, before I had seen them) and I was concerned that pinpointing the
problem within TLS precluded a needed discussion about how to prevent this in
future. I still think this is true, and Ben agrees with the need to think
about this problem more deeply. This was one of those cases where each
component seemed secure (with their respective, though possibly mistaken,
assumptions), but the system as a whole clearly wasn't.

As the moment, however, people are still scrambling to plug the leak so we
should thank those volunteers who are doing so.

CAcert certs aren't "invalid"

Posted Nov 19, 2009 10:45 UTC (Thu) by dwmw2 (subscriber, #2063) [Link]

The resiprocate.org certificate isn't really invalid — it's just that it's signed by CAcert, and you probably don't have the CAcert root CA installed on your system. It's not included in Firefox by default, unfortunately.

CAcert certs aren't "invalid"

Posted Nov 19, 2009 13:29 UTC (Thu) by meuh (subscriber, #22042) [Link]

It's reported as invalid because CACert Root Certificate use MD5 signature, which is known to be broken.

Using plug-in for Firefox like SSL black List will tell you more about this : http://codefromthe70s.org/sslblacklist.aspx .

TLS renegotiation vulnerability

Posted Nov 19, 2009 14:18 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

Solution: let's ship all security people to Mars?

No, really. TLS/SSL standards are ridiculously complicated - you need to know about ASN.1 (and its encodings), leftovers of DAP (like braindead CNs), etc. So it's almost impossible for a single person to implement their own SSL/TLS library.

No wonder, people treat OpenSSL as a 'magic black box' which secures everything. Because it really is a black box.

What we need is a simple security protocol based on XML instead of ASN.1 with human-readable details and a manageable core standard.

TLS renegotiation vulnerability

Posted Nov 19, 2009 16:16 UTC (Thu) by dion (subscriber, #2764) [Link]

You know, I think you're right!

However, the trouble with reimplementing a security is that security is hard, so hard that people who do go greenfield then tend to implement horrible, nasty, disastrous things like the java keystore and the java keytool.

Granted, the jks might be an unfair example as thats where SUN seems to put their dimmest interns.

I wonder if it's at all possible to get both high quality crypto code and well-designed protocols and APIs out of the same brains.

TLS renegotiation vulnerability

Posted Nov 19, 2009 17:11 UTC (Thu) by nye (guest, #51576) [Link]

>I wonder if it's at all possible to get both high quality crypto code and well-designed protocols and APIs out of the same brains.

If only we could get funding for a research project to find out!

TLS renegotiation vulnerability

Posted Nov 19, 2009 22:28 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

Greenfield cryptoalgorithms tend to be bad, yes.

But the new Plain XML Security Protocol should use existing crypto. There's no need to reinvent the wheel.

Everything other should be mercilessly killed. I.e. ASN.1, X.509, PKCS#I'd_be_damned_if_I_remember and so on.

I think it can be done. Sometimes I even think to start writing it...

Why not

Posted Nov 20, 2009 7:35 UTC (Fri) by man_ls (guest, #15091) [Link]

It should be fun. Unfortunately the inertia of legacy implementations is often so heavy that many new efforts are not even considered. The case that always comes to my mind is the sad story of the D programming language. It looks quite interesting, but it has failed to gain wide support. Meanwhile the namespace was miserably trampled by Sun engineers with the language used in DTrace (I guess they didn't know about the former, or the temptation to use "D" was too irresistible).

TLS renegotiation vulnerability

Posted Nov 20, 2009 3:28 UTC (Fri) by cras (guest, #7000) [Link]

I think a big problem with OpenSSL being a magic box is the lack of documentation, and APIs that
are quite horrible if you want to do something a bit differently than everyone else. Usually whenever
I want to add a new TLS related feature I'll just try to find out existing code that does something
similar (because the functions' manual pages don't exist or are almost empty). And when that fails
(and it often does) I'll just have go read the OpenSSL code directly. And when I find that there
doesn't exist an easy way to do what I want, I'll just go and copy&paste a large chunk of OpenSSL
code to my code and modify it slightly..

I guess I should start looking at GNUTLS again, maybe things are better there..

TLS renegotiation vulnerability

Posted Nov 21, 2009 18:37 UTC (Sat) by kleptog (subscriber, #1183) [Link]

I've done a little programming with GNUTLS and one things is for sure, the interface is much nicer. It was created at a time when TLS was much more standard, and certain features went it from the beginning. Like BIOs in OpenSSL are in the from the beginning. Non-blocking is supported throughout.

Certainly I found it much nicer.

TLS renegotiation vulnerability

Posted Nov 20, 2009 6:35 UTC (Fri) by njs (guest, #40338) [Link]

> So it's almost impossible for a single person to implement their own SSL/TLS library.

On the one hand, you're right, TLS is ugly as sin. On the other, wtf, they're still finding bugs in *openssh* and *openssl*, which are possibly the most intensely scrutinized bits of code ever. You honestly think one random person -- one who's not even smart enough to understand ASN.1 -- is going to do better, no matter the protocol?

> What we need is a simple security protocol based on XML

Have you seen the horror that lurks in standards that mix XML and crypto? XML has many congenial aspects, but it does not mix well with the "just define a canonical bitstring dammit" world of crypto.

TLS renegotiation vulnerability

Posted Nov 22, 2009 1:29 UTC (Sun) by Cyberax (✭ supporter ✭, #52523) [Link]

>On the other, wtf, they're still finding bugs in *openssh* and *openssl*, which are possibly the most intensely scrutinized bits of code ever. You honestly think one random person -- one who's not even smart enough to understand ASN.1 -- is going to do better, no matter the protocol?

For starters, why not use a garbage-collected safe language (compiled one which doesn't require a VM, like OCaml or D) for reimplementation of OpenSSH? It'd instantly decrease the number of exploitable buffer-overflow bugs nearly to zero. In fact, I'm reading OpenSSH CVEs and almost _all_ of them are caused by its usage of unsafe language.

New OpenSSL should still be implemented in C, because it's the lowest common denominator, alas.

>Have you seen the horror that lurks in standards that mix XML and crypto? XML has many congenial aspects, but it does not mix well with the "just define a canonical bitstring dammit" world of crypto.

It's actually not that complex. The relevant standards are: http://www.w3.org/TR/xml-c14n and http://www.w3.org/TR/xml-exc-c14n/ , they are nicely _short_ and can be quite easily implemented. In fact, I've implemented a subset of them in the past quite easily.

XML signature core standard is also very nice and readable: http://www.w3.org/TR/xmldsig-core/

Hmm... It's actually not that much work to build new security protocol...

TLS renegotiation vulnerability

Posted Nov 22, 2009 4:49 UTC (Sun) by foom (subscriber, #14868) [Link]

> It's actually not that complex.

Are you kidding? That's *insane*ly complex, compared to just having a single standard spelling.
XML dsig (at least libxml version) is crazy slow, too.

TLS renegotiation vulnerability

Posted Nov 22, 2009 17:01 UTC (Sun) by Cyberax (✭ supporter ✭, #52523) [Link]

Well, if I had a choice between ASN.1 and insanely complex XML rules, then I'd still choose XML.

The trick in doing XML dsig is to output XML directly in a canonical format, then you can have a pretty fast implementation.

It's still slower than uber-optimized ASN.1 parsers, but personally, I don't care even if it's 10x slower.

TLS renegotiation vulnerability

Posted Nov 23, 2009 0:17 UTC (Mon) by foom (subscriber, #14868) [Link]

> Well, if I had a choice between ASN.1 and insanely complex XML rules, then I'd still choose XML.

That's a bit silly. Have you ever looked at ASN.1? It's really quite trivial. So much easier than XML,
it's hard to imagine why anyone would want to use an XML parser instead in security sensitive
code.

http://en.wikipedia.org/wiki/Basic_Encoding_Rules

Certificates actually use DER, which is a slightly restricted subset of BER:
http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules

TLS renegotiation vulnerability

Posted Nov 23, 2009 8:26 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

Unfortunately, I've worked with it. And that's why I'm quite sure: wherever ASN.1 goes, destruction and pain follows. Examples: LDAP, SNMP, SSL/TLS, Kerberos.

To be fair, XML canonicalization rules are designed for arbitrary XML. It's possible to simplify them by using a subset of XML. For example, by restricting entities, CDATA and namespace use.

In any case, less complex formats like JSON can be used instead of XML.

TLS renegotiation vulnerability

Posted Nov 23, 2009 13:50 UTC (Mon) by quotemstr (subscriber, #45331) [Link]

wherever ASN.1 goes, destruction and pain follows. Examples: LDAP, SNMP, SSL/TLS, Kerberos.
You have an interesting definition of "destruction and pain". These protocols are used all over the place and are successful by any measure.

TLS renegotiation vulnerability

Posted Nov 23, 2009 15:49 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

Do you know how to make a simple request with LDAP? Can you write a simple LDAP Ping using plain sockets?

I can easily do this for HTTP/FTP/SMTP even IMAP. I don't even want to contemplate this for SSL/TLS.

That's the problem, it's impossible to create a simple client for SSL.

TLS renegotiation vulnerability

Posted Nov 30, 2009 12:22 UTC (Mon) by robbe (subscriber, #16131) [Link]

How can the MITM present the correct server certificate to the victim?
This problem is not mentioned at all in all the papers I skimmed, so this
is probably just me being daft.

TLS renegotiation vulnerability

Posted Dec 3, 2009 0:10 UTC (Thu) by xoddam (subscriber, #2322) [Link]

As I understand it, the certificate exchange is still between the client and the server; the MITM does nothing more than forward the data and insert a cleartext payload into a window of vulnerability. In this attack, the MITM does not need to know or have any certificate or cipher keys.

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds