SSLv3 Traces [Part 2]

Posted by jgraver on February 08, 2009
SSL Facts / No Comments

This SSL Packet Trace is based on the Server View found here. My goal is to add useful hash information to the packet dump which in its original form only contained the state register values.

These are the starting values for your MD5 and SHA-1 Hash Objects.
State = useless
Hash = digest() of all handshake data seen so far
Buf Hash = digest() of all 64 byte blocked handshake data
Buffered Data = 63 or less bytes of data waiting to be added to the hashes

Starting Values [0]
MD5 State:      67452301efcdab8998badcfe10325476
SHA State:      67452301efcdab8998badcfe10325476c3d2e1f0
MD5 Hash:       d41d8cd98f00b204e9800998ecf8427e
SHA Hash:       da39a3ee5e6b4b0d3255bfef95601890afd80709
Buf MD5 Hash:   d41d8cd98f00b204e9800998ecf8427e
Buf SHA Hash:   da39a3ee5e6b4b0d3255bfef95601890afd80709
Buffered Data [0]

Now each handshake section of the packet is added to the hash objects in 64 byte blocks. If you do not yet have 64 bytes to add you simply hold onto them in a buffer.

Client Hello [52]
MD5 State:      67452301efcdab8998badcfe10325476
SHA State:      67452301efcdab8998badcfe10325476c3d2e1f0
MD5 Hash:       56d14200dd0dc905d876474c98ac2e0e
SHA Hash:       677664bb8d411d0f757f593dfb2509194274177b
Buf MD5 Hash:   d41d8cd98f00b204e9800998ecf8427e
Buf SHA Hash:   da39a3ee5e6b4b0d3255bfef95601890afd80709
Buffered Data [52]
01 03 00 00 1b 00 00 00  10 01 00 80 03 00 80 06  ................
00 40 07 00 c0 00 00 04  00 00 0a 00 00 09 00 00  .@..............
03 00 00 06 d8 90 d7 86  4e 5c 92 9f 90 07 da 83  ........N\......
1c 25 89 01                                       .%..

While the hash states listed in the original packet traces were useless the buffered data was pretty handy, it was a clear indication of what pieces to add to the hash objects. In this packet we add 74 more bytes to the 52 we had saved up from before. After using up the first 64 bytes we are left with 62 left over.

Server Hello [74]
MD5 state:      88c9b8dfc144c3163d5f0a6f5c8050c2
SHA state:      626c5d48a75e632814b572a7a634256195d4b038
MD5 Hash:       613d367016bd9df00fa25e8761c0af57
SHA Hash:       bbf09b7676a261bb679cd618919450e14a62aec7
Buf MD5 Hash:   5e612aa87f6994fb836aba168af7eb10
Buf SHA Hash:   34d1303dde2ff4f0bfede8a22e8307fcb7a297bf
Buffered Data [62]
ce e0 92 9c ff 03 be d3  c5 25 a2 ec 61 85 b1 ea  .........%..a...
93 bf a0 5e a9 79 1c 8a  ed 16 20 00 00 4f 47 95  ...^.y.... ..OG.
8f 49 f8 7b d8 41 71 5f  36 f9 6f 7d a2 31 fa 25  .I.{.Aq_6.o}.1.%
07 8e 45 3c 0e d9 e7 d4  d2 86 5c 00 04 00        ..E<......\...

This is where the packets start getting really long. Although the certificates are long (and very complicated) they are one of the very few SSL packets with ASCII printable text. When looking at a packet dump these are the most recognizable packets of an SSL transaction.

Server Certificate [1331]
MD5 state:      9cbff56d42b7e94ef4ff1acf323703fa
SHA state:      bb19323f4e8e5ab8b1cbe0a2687c706bd8f29c00
MD5 Hash:       1c0168d2bf58b931d3900e043b3d0811
SHA Hash:       192cd1976ae06f563062c05744ab632aebd54226
Buf MD5 Hash:   658a2e15ea5d2bd02b3b8c19b91bb8ff
Buf SHA Hash:   ee8d3d2e7c232414b45c2d94045abfbe4d78f2f9
Buffered Data [49]
a7 62 b3 5b 8e 4d 82 bd  4d 85 eb 0d 5a 87 c0 41  .b.[.M..M...Z..A
c9 a6 c2 69 9c ee 81 49  2a fb 01 55 6f b1 df 21  ...i...I*..Uo..!
a7 b0 70 e4 5d 34 3b 90  29 f9 14 c3 2e 07 79 13  ..p.]4;.).....y.
c7                                                .

The following packet is where this demo trace really goes off the rails. Netscape chose to illustrate one of the more complicated capabilities of SSL. Although client side certificates are essential to SSL VPN connections, they are very seldom seen in standard HTTPS sessions.

Server Certificate Request [4846]
MD5 state:      8e428cd82e39d5b55907f503aba04860
SHA1 state:     c6a44cb5395684f2bd4f6340a9e71646f27f44a1
MD5 Hash:       944f3c49e385599172d9c418a93c4bf0
SHA Hash:       274b63fb35c478f7358e9f2b5334cb17c96728c5
Buf MD5 Hash:   54c0082e941319cb5aea8683d83f745a
Buf SHA Hash:   54b3a5bd49a6d2b8c2265d4166bf5feb2b17a1f4
Buffered Data [31]
 1e 30 1c 06 03 55 04 03  14 15 47 65 74 20 53 6d  .0...U....Get Sm
 61 72 74 63 61 72 64 20  44 65 6d 6f 20 43 41     artcard Demo CA

Finally we get to the Server Hello Done message.

Server Hello Done [4]
MD5 state:      8e428cd82e39d5b55907f503aba04860
SHA state:      c6a44cb5395684f2bd4f6340a9e71646f27f44a1
MD5 Hash:       d100fddd68dc017674a40f3cc28921d4
SHA Hash:       4bd7ccd3e58633b629e2bb2f51cc90aa0973d9b4
Buf MD5 Hash:   54c0082e941319cb5aea8683d83f745a
Buf SHA Hash:   54b3a5bd49a6d2b8c2265d4166bf5feb2b17a1f4
Buffered Data [35]
 1e 30 1c 06 03 55 04 03  14 15 47 65 74 20 53 6d  .0...U....Get Sm
 61 72 74 63 61 72 64 20  44 65 6d 6f 20 43 41 0e  artcard Demo CA.
 00 00 00                                          ...

Client sends its identity to the Server. This step is not commonly seen.

Client Certificate [1330]
MD5 state:      87508b0c13815c09c8c3d6e1c21acdea
SHA state:      5cfaa109407fc96ac3ca17120fdb98899772153a
MD5 Hash:       b508728fb32560bcd8d4dce42cea601e
SHA Hash:       b6dbc745718ed93d8ad2237b2e2aea8d73cfd3a5
Buf MD5 Hash:   b7bb5762de2898dd0b995e91f9c30e85
Buf SHA Hash:   eba03e1be44f281b97b0b709316a916353be3da8
Buffered Data [21]
 6f b1 df 21 a7 b0 70 e4  5d 34 3b 90 29 f9 14 c3  o..!..p.]4;.)...
 2e 07 79 13 c7                                    ..y..

Now here is the first packet with actual encryption. This packet contains the pre-master secret that has been asymmetrically encrypted with the server’s public key. This pre-master secret will be used to calculate the symmetric key. I will focus on this packet in a future post as it is very interesting.

Client Key Exchange [68]
MD5 state:      250fb55d512afd7f4854468080c702a9
SHA state:      cf323bf6a3ca8feb6b10e4f5101104276472968d
MD5 Hash:       54eb606b1f4352c10c52d240091602b7
SHA Hash:       65141df5f72d09f62828f95ed8de803e0a009716
Buf MD5 Hash:   b699de2ef33abd107ede96e69faf64a7
Buf SHA Hash:   b91d39ce7f125cf8f7b1996607478c4f618a6616
Buffered Data [25]
 88 a4 60 56 61 57 c9 4f  5e 3a 1f f2 86 12 16 38  ..`VaW.O^:.....8
 36 1c 3d c6 b8 0a 3f bd  88                       6.=...?..

Certificate Verify message – not commonly seen as client authentication is rare.

Certificate Verify [70]
MD5 state:      0cde7c7c27e9771142037f53633d4736
SHA state:      f6b217ec76f0d9ddda324813462ca026fe925ba3
MD5 Hash:       f92d49e65ac3d9a74de397f064db1adf
SHA Hash:       69c1b5559a70c2c489b57b4b9ba0e4c93c7b667c
Buf MD5 Hash:   b6ec7929879ba9b378fe4081442940d9
Buf SHA Hash:   45848df7885b538bd7c0df282a8701fb1ccfaf6f
Buffered Data [31]
 77 28 96 8e b5 61 74 f2  84 1c 31 a2 3f 4f 58 78  w(...at...1.?OXx
 11 88 72 4e ed 70 e8 ac  e9 82 37 ec 8d 32 7b     ..rN.p....7..2{

The Client Change Cipher Spec message is not included in the hashes. The Client Finished message however is. This packet (or portion of a packet) is the first symmetrically encrypted data we have seen so far. At this point in the handshake both the server and client posses a shared key.

Client Finished [40]
MD5 state:      f6b0a72e2150598caa3fb2fe89f69207
SHA state:      56341040456e541453cd46246e6ddff8789c7ee0
MD5 Hash:       cb815a237cf657b82b5bdb8e686d8a7b
SHA Hash:       732a54c36c4346d076727a8ff7856361adfaeec7
Buf MD5 Hash:   33329f6bde606b5ffd7516031f3ff610
Buf SHA Hash:   3e9fe0f55988bdb950d710e74d3279866b77713a
Buffered Data [7]
 ba c1 0f d4 a3 0f 67                              ......g

When this packet is unencrypted you will find a message that can only be verified if you have all the handshake data seen thus far. This is a little harder than just adding a couple of captured packets, as several portions of the message need to be excluded (all record data and change cipher spec messages). The server then does the same thing with this newly included data and completes the handshake by constructing the server finished message. I will look at this final step in my next post.

Tags:

Potentially 219K Expired SSL Certs?

Posted by Tyler on February 06, 2009
SSLFail / 2 Comments

Royal Pingdom has a post up mention that Netcraft has announced there are now one million sites that are using SSL. That’s valid certs, trusted by a third party, not expired and where the common name matches the hostname.  That’s a far cry from the 3293 found in Netcrafts first SSL survey.

Does this survey catch everything? Probably not, but it’s most likely a good starting point.

Now, how did Royal Pingdom determine that there are potentially 219K in expired certs? They based it on a 2007 survey from Venafi (referenced here), that said 18% of Fortune 1000 websites had expired certificates. They applied the percentage to the Netcraft total and, voila… 219K. They also go on to say that even if you have that it’s still 100K websites with expired certificates.

I’d be willing to wager a guess that if the number is off it’s mark, that it’s probably too low rather than two high. I encounter sites all the time with expired certs. Mind you, since we started SSLFail.com, I’ve had a harder time finding them.  However, I did happen to stumble across one just the other day and since we don’t feature screenshots with IE often enough… here you go.

OpenRCE.org Expired SSL

OpenRCE.org Expired SSL

Tags: , ,

Blogger mixed content

Posted by romain on January 27, 2009
SSLFail / No Comments

blogger1

Tags:

SSLFail.com == SSL FAIL?

Posted by Tyler on January 27, 2009
Site Related / 5 Comments

We just received a link to our own site. It would appear that someone was looking and discovered that we don’t have a SSL Enabled site. This is very true, but we’re not a large company with tons of visitors (in fact we’re still at less than 1000 unique visitors) and we’re not asking you for your passwords or allowing you to do online banking (however, feel free to email me your online banking information :) ).

We could setup a self-signed certificate to allow for encryption, but then you’d have to walk through those annoying “Add An Exception” screens for this site.

The reality of it is that not everyone needs SSL, although I’m sure in saying that even some of my fellow SSLFail.com bloggers will disagree with me.

That being said, if anyone feels we require a SSL cert, let me know… I doubt I’ll shell out the money for one, but maybe a SSL vendor will come along and read this and offer us one free of charge :) .

Tags:

Mixed Content Warnings

Posted by jgraver on January 18, 2009
SSLFail / 5 Comments

We are off the domain mismatch SSL Errors right now so I thought I would highlight another one that I find pretty often – Mixed Content Errors.

My (current) browser of choice Chrome defines Mixed Content Errors as;

“Your connection to www.website.com is encrypted with 128-bit encryption. However this page includes other resources which are not secure. These resources can be viewed by others in transit, and can be modified by an attacker to change the look or behavior of the page.”

Oh Noes!

Royalbank serving up mixed content

mc_rb1

Here is HSBC doing so on its homepage

mc_hs1

Continue reading…

Tags:

A Great Example of Failing User Trust

Posted by Tyler on January 16, 2009
SSLFail / 2 Comments

[Update: apparently Romain and I posted the same image, so I've removed the image from my comment]

We recently had a link submitted (Thanks Jirka) that I think is a great example of betraying user trust in the SSL Realm. The link in question belongs to Microsoft and links to none other than their phishing filter FAQ. I can’t get this site to load without SSL in my browser (however, that could simply be network issues), so SSL is the only choice. I refuse to believe that Microsoft couldn’t afford a wildcard certificate to avoid this issue, or another IP address with a single domain cert. Sure once again, it may just be a ssl_error_bad_cert_domain error, but does this error need to exist?

Tags:

Microsoft/Phishing SSLFail!

Posted by romain on January 16, 2009
SSL Fail Images, SSLFail / 2 Comments

phishing_microsoft

Twitter SSL Fail… Again!

Posted by Tyler on January 15, 2009
SSL Fail Images, SSLFail / 2 Comments

Given my last post on ssl_error_bad_cert_domain error you probably wouldn’t expect me to post another one so soon, but I thought that this really demonstrated my point. Mike Murray posted to twitter earlier today that something was up with their SSL and asked if perhaps it was a compromise of sorts.  Tonight he sent us a a copy of the image. Mike’s a bright guy and well known in around InfoSec, if this made him question what was going on then I think it’s safe to say that these SSL error messages are a hindrance to our day to day use of the web.

I know I’ve already posted a Twitter SSL Fail in Chrome, but here’s the image Mike sent:

Twitter SSL Fail Image

Twitter SSL Fail Image

Tags:

Why ssl_error_bad_cert_domain is bad

Posted by Tyler on January 14, 2009
SSLFail / 3 Comments

Since the site went live and our first ssl_error_bad_cert_domain error (note: I will be using the Firefox error message to identify most of these errors) was posted, we’ve been receiving emails, comments and IMs regarding this SSL error and why it isn’t a security issue, and how we shouldn’t be posting them. There may be some truth in that, so many sites throw this error that it’s not even funny. I was sent lists yesterday that contained financial institutions, vendors and others who all had this error.

Now as a commenter mentioned this is just a matter of two domains pointing to the same A record. For the record though, it doesn’t necessarily have to be the same A record but more on that later. This issue was something I had in th back of my mind when I mentioned this concept to Marcin, and I’m really glad that people have picked up on it and mentioned it because I get to write this post already.

You see I could care less if there’s “no security implications” to the error message. Although I disagree with that, I believe it’s more accurate to say there’s “no technical security implications”. My concern with this error messages is user perception. The point that I wanted to make was just how plentiful these messages are in the latest round of browsers. However, it should be noted that Firefox is more lenient than IE7 and Chrome in some cases.

You can’t tell a user to “be wary” of SSL errors and know where they are going, there’s more to it than that. There are sites that may throw ssl_error_bad_cert_domain due to the cert containing or not containing ‘www’. There are, however, bigger errors that I’ve seen.

One of these errors may deserve it’s own discussion page, but instead we’ll discuss it here. The error can be seen on: reddit.com, westjet.com and others. The error message contains: The certificate is only valid for a248.e.akamai.net. Now anyone who’s reading this blog probably knows what Akamai is, but does your family know? Do your non-IT coworkers know? Does that person sitting across from you on transit know? Asking people to accept these is like opening the door to MitM. What happens when I MitM their connection and it asks them to accept a certificate that’s valid for loadbalance.mymaliciouswebsite.com. How does your average user know the difference?

So yes, to the technical this is a non-issue but to the people using the computer every day that know nothing about how it operates, or why it works… this is an issue. We’re training users to click through. People argued this point on Vista (it also happens on Ubuntu and OS X), that people would just always click. If this is a vald argument for operating systems, then we should be worried about what this means for web browsing. I encounter more SSL error pages daily than I do UAC pop-ups from Vista.

For those of you saying that doesn’t affect the encrypted status of the traffic, I ask that you remember that that is only one side of SSL. The other is as a form of verification, to authenticate that the site you’re visiting is the site that it says it is. This is where my concern comes from, this is the issue that I have. I should not visit my online banking website and see The certificate is only valid for a248.e.akamai.net but I know of at least one bank who’s main website brings up that message.

So how do we fix this? I’ve also been asked this question already. I guess the answer for that depends on where you think the problem lies. The simplest answer is most likely user education, but we all know educating a user is easier to say than it is to do. So who’s fault is it? Is it the fault of the browser for introducing all these “in your face” error messages? Is it the responsibility of the websites to purchase additional SSL certs to deal with these one off cases? Should certificate vendors be more open with pricing and bundling? I don’t really know the answer but I think it’s something we need to start thinking about.

Possible Fixes:

  1. Browsers remove ssl_error_bad_cert_domain error for sites where stripping www. (or appending www.) leads to the domain identified in the certificate.
  2. Website Owners purchase appropriate certificates, purchasing wild card SSL certificates to accomodate sites with multiple associated domain names or buying multiple certificates when their websites span multiple TLDs/ccTLDs
  3. SSL Vendors provide greatly reduced rates to purchase certificates for multiple TLDs or decreased costs on wild card SSL certs (which interesting enough doesn’t have a price on the Verisign Wildcard SSL page)

I can think of a few other fixes, and a couple of theories that I’m in the process of testing.  I will incorporate updates to the list as I confirm my theories, but I also want people to suggest fixes in the comments.

So in the end will you continue to see ssl_error_bad_cert_domain error images posted? Most likely, however we will most likely stick to larger, popular sites and please know that we’re only doing it in hopes that the website owner will resolve the problem. Not to fix any technical errors (although we’ll always post people with technical issues) but to prevent users from learning to quickly click-through browser error messages.

Tags: ,

SSLv3 Traces [Part 1]

Posted by jgraver on January 14, 2009
SSL Facts / No Comments

This is Part 1 of a series of posts about Netscape’s SSLv3 spec.

When working on my first SSL Client I went looking for the official RFC to correctly implement the SSLv3 protocol. Near total FAIL.

The SSLv3 protocol was created by Netscape back in 1995. The file that most people (continue to) reference is:

http://www.netscape.com/eng/ssl3/draft302.txt

Which is tragically some horrible 404 page now. Even Openssl.org continues to cite this as the official spec for SSLv3.

The file has been moved into the care of the The Mozilla Foundation and can now be found here:

http://www-archive.mozilla.org/projects/security/pki/nss/ssl/draft302.txt

Once you have found the SSLv3 spec you get to read one of the most ambitious and sadly disappointing specs ever written. SSLv3 got so many ideas right and fell just short of explaining them in enough detail that developers could easily build their own clients. What saved SSLv3 was the set of packet traces of live connections that Netscape put together.

http://www.mozilla.org/projects/security/pki/nss/ssl/traces/index.html

They spoke the universal language of hex and came close to being the best illustration of this protocol in action. Unfortunately they too fell short of properly explaining what was going on. The non-client auth trace used export keys and the 128 bit RC4 trace used client-auth. This left out perhaps the most common scenario seen on the Internet – the high encryption (>=128 bit) non-client auth session.

What makes these connection traces difficult to construct (and annotate) is that by design SSL is difficult to sniff and recreate. Looking directly at encrypted traffic will do you little good in understanding the algorithms that encrypted it.

I am going to do my best to recreate the original Netscape traces as well as add some more modern traces of traffic typically seen today.

On with the show …
SSL_RSA_EXPORT_WITH_RC4_40_MD5 no client-auth.

PACKET 1 :: CLIENT >> SERVER

ClientHello [54]
80 34 01 03 00 00 1b 00  00 00 10 01 00 80 03 00  .4..............
80 06 00 40 07 00 c0 00  00 04 00 00 0a 00 00 09  ...@............
00 00 03 00 00 06 d8 90  d7 86 4e 5c 92 9f 90 07  ..........N\....
da 83 1c 25 89 01                                 ...%..

Although it is listed as an SSLv2 Client Hello it carries SSLv3 information. There was a time when there were HTTP servers on the Internet which only spoke SSLv2. By sending the SSLv3 information in an SSLv2 Client Hello users were able to safely contact tcp(443) without crashing servers. These days nearly all clients will default to TLSv1/SSLv3 so there is little reason to actually use this old format anymore.

SSL2 record [2]
80 34                                             .4

The record layer is not considered part of the SSL Handshake and is usually listed separately – you will see why shortly.

SSL2 ClientHello [52]
01 03 00 00 1b 00 00 00  10 01 00 80 03 00 80 06  ................
00 40 07 00 c0 00 00 04  00 00 0a 00 00 09 00 00  .@..............
03 00 00 06 d8 90 d7 86  4e 5c 92 9f 90 07 da 83  ........N\......
1c 25 89 01                                       .%..

The SSLv2 Client Hello (minus the record layer) is added to the handshake data. Why is this important? To complete the SSL Handshake (SSL Finished Message) all Handshake Data sent from both the Client and Server is required. When coding this you just keep concatenating these byte strings together.

Handshake Data [52]
01 03 00 00 1b 00 00 00  10 01 00 80 03 00 80 06  ................
00 40 07 00 c0 00 00 04  00 00 0a 00 00 09 00 00  .@..............
03 00 00 06 d8 90 d7 86  4e 5c 92 9f 90 07 da 83  ........N\......
1c 25 89 01                                       .%..

Now as we trace through the SSL Connection this handshake data is going to get fairly large. The Netscape traces use an MD5 and SHA1 hash to track the progress. However they use the values of the internal hash registers, which for practical coding purposes is near useless. Listing the hash digest as you add data to it allows you follow along and ensure you have added the correct data.

Netscape lists the starting values of MD5 and SHA1 hashes as:

MD5 state: 67452301 efcdab89 98badcfe 10325476
SHA1 state: 67452301 efcdab89 98badcfe 10325476 c3d2e1f0

However if you were to create a brand new md5 or sha object (in Python) and call digest() you get:

MD5 Digest d41d8cd98f00b204e9800998ecf8427e
SHA Digest da39a3ee5e6b4b0d3255bfef95601890afd80709

I have not seen an easy way to view the internal state registers of these hash objects – and really why bother? Just list the digest instead …

If you search for the obscure hex strings above you will eventually find out they are the default starting values of MD5 and SHA1 state registers.

RFC 1321 Section 3.3

word A: 01 23 45 67
word B: 89 ab cd ef
word C: fe dc ba 98
word D: 76 54 32 10

FIPS 180 Section 5.3.1

0 H = 67452301
1 H = efcdab89
2 H = 98badcfe
3 H = 10325476
4 H = c3d2e1f0

I have no idea why Netscape chose this akward method of hash usage.

If you add the handshake data to your MD5 and SHA1 objects and check the digest you will see the following values for the first packet.

 Handshake Data [52]
MD5: 56d14200dd0dc905d876474c98ac2e0e
SHA: 677664bb8d411d0f757f593dfb2509194274177b

As is usually the case when studying the SSL Protocol, the most confusing parts are often the secondary protocols involved (of which there are a TON).

In Part 2 of this series I will explain the First Server Packet.

Tags: