DevCentral Groups
   
You are here: Community > Group Details > iRules

Get Connected with DevCentral

Sign up and Join this Group today!

Connect with your peers with the click of a button. Become a member of this group to post questions, sign up for notifications, provide comments, answer questions, access downloads and receive lots of other great documentation relevant to your interests. Connect with your community today!

  

Group Details

iRules

F5 DevCentral Topic Group dedicated to open discussion and collaboration related to F5's unique and incredibly powerful iRules scripting language.
iRules
Upcoming Events
There are no events currently connected to this group. Click here to search all F5 Events.

Having trouble posting to this forum? Click the "Join Group" button above to get access!

mitigating the TLS client-initiated renegotiation MITM attack
Last Post 01/21/2011 06:20 AM by Josh. 13 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
Please login or join DevCentral to post a reply.
 
PrevPrev NextNext
Author Messages
Lupo
Lupo
Post Count: 3
New Member


--
11/06/2009 05:29 AM  
I thought I'd share the iRule we use to mitigate one of the recently disclosed TLS attacks. Our focus lies on preventing the possible malicious data insertion during 'client-initiated renegotiation'.

Take care though to check that your virtual server does _not_ depend on (benign) renegotiations. If you're not sure, you can use
bigpipe profile clientssl all show all | grep -e PROFILE -e mid-stream

after a number of friendly connections to check for any 'mid-stream' handshakes.

Now for the iRule:
when CLIENT_ACCEPTED { 
# initialize TLS/SSL handshake count for this connection
set sslhandshakecount 0
}

# if you have lower priority iRules on the CLIENTSSL_HANDSHAKE event, you have to make sure, that they don't interfere with this iRule
when CLIENTSSL_HANDSHAKE priority 100 {
# a handshake just occurred
incr sslhandshakecount

# is this the first handshake in this connection?
if { $sslhandshakecount != 1 } {
# log (rate limited) the event (to /var/log/tmm)
log "\[VS [virtual] client [IP::client_addr]:[TCP::client_port]\]: TLS/SSL renegotiation occurred, dropping connection"
# close the clientside connection
TCP::close
}
}


On initial deployment the rule may fail in the CLIENTSSL_HANDSHAKE event a few times on busy virtual servers. This isn't a problem in our setup, but I welcome suggestions on how to prevent that. Is there a way to check the existance of a variable without inviting an error?

This rule was tested with v9.4.8, should be CMP compatible, and is safe for deployment on multiple virtual servers (i.e. not affected by CR127411). Observed performance impact is minimal.

References on the vulnerability:
http://extendedsubset.com/?p=8
http://www.links.org/?p=780
http://www.ietf.org/mail-archive/web/tls/current/msg03928.html
Jason Rahm
Jason Rahm
Post Count: 2272
DC Team - 7


--
11/06/2009 07:19 AM  
Nice work, thanks for sharing! Regarding the variable checking, you can use the catch command (Click here), or you can use info exists varName.
Don
Don
Post Count: 8
DC Team - 1


--
11/06/2009 11:15 AM  
Very nice indeed Lupo, thanks for sharing!
Don.
Deb Allen
Deb Allen
Post Count: 1243
Star Member


--
12/09/2009 01:35 PM  
replace TCP::close command with reject in code above to avoid core dumps
Paul Zajicek
Paul Zajicek
Post Count: 6
New Member


--
04/21/2010 11:54 AM  
Hi,
This rule only partially works. Our Web servers are scanned by several PCI DSS scanners & they all report that our LTM load balanced servers support SSL renegotiation with the rule applied. You can test this at:
http://netsekure.org/2009/11/tls-renegotiation-test/
Any thoughts on why its not working correctly ?
Lupo
Lupo
Post Count: 3
New Member


--
04/22/2010 03:22 AM  
Two thoughts from my side:
  1. While http://netsekure.org/2009/11/tls-renegotiation-test/ reports Connecting to xxx:443 Sending partial HTTP request Trying to renegotiate Site allows client initiated renegotiation! Unpatched servers allowing client initiated renegotitation are vulnerable to a variation of the TLS MiTM attack. HTTP Response: HTTP/1.1 200 OK Date: Thu, 22 Apr 2010 08:31:30 GMT [...]I see no actual renegotiation taking place when investigating a packet dump of that connection:No. Time Source Destination Protocol Info 4 0.114197 205.205.221.5 x.x.x.x SSLv2 Client Hello 5 0.114211 x.x.x.x 205.205.221.5 TLSv1 Server Hello, 6 0.114219 x.x.x.x 205.205.221.5 TLSv1 Certificate, Server Hello Done 8 0.231424 205.205.221.5 x.x.x.x TLSv1 Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message 9 0.232253 x.x.x.x 205.205.221.5 TLSv1 Change Cipher Spec, Encrypted Handshake Message 10 0.345634 205.205.221.5 x.x.x.x TLSv1 Application Data (38 bytes) 12 3.357203 205.205.221.5 x.x.x.x TLSv1 Application Data (42 bytes) 14 3.570393 205.205.221.5 x.x.x.x TLSv1 Application Data (23 bytes) 15 3.611217 x.x.x.x 205.205.221.5 TLSv1 Application Data (391 bytes) 19 3.727658 205.205.221.5 x.x.x.x TLSv1 Encrypted Alert (I stripped 0-byte ACK and TCP handshake packets)
    It looks like that check isn't working properly to me.
    Have you been able to get a negative result on renegotiation for some other site at all? I couldn't find one.
  2. My iRule does not prevent renegotiations, but it closes the connection after one occurred. Thus a scanner will be able to successfully perform a TLS renegotiation, but will not be able to send data to the virtual server ressource.
Perhaps you should perform a packet dump and investigate your webserver logs for the request actually reaching the server.

I still think the iRule reliably prevents abuse of the TLS design problem.
Paul Zajicek
Paul Zajicek
Post Count: 6
New Member


--
04/22/2010 08:14 AM  
Hi,
There are some sites I've found that pass the test (www.asos.com), but my PCI DSS scanning supplier says I accept the http request, therefore I am vulnerable.
Looks like I have to upgrade (currently 9.3.0).
zoltak
zoltak
Post Count: 3
New Member


--
06/03/2010 12:03 AM  
Hi,
The following article describes a method to test client initiated SSL renegotiation.

http://blog.ivanristic.com/2009/12/testing-for-ssl-renegotiation.html

The iRule behaviour appears to reset as soon as the certificate has been re-verified.

Our PCI DSS scanning supplier is rescanning our network now with the iRule in place. I will let you know if the iRule satisfies the requirement.

We are running BIG-IP v 9.4.5.
zoltak
zoltak
Post Count: 3
New Member


--
06/08/2010 06:35 AM  
We didn't pass the PCI DSS scanning with BIG-IP v 9.4.5 and the iRule for this version.

We updated to BIG-IP v 9.4.8 HF3 and the iRule for this version. The behaviour is the same as observed on http://blog.ivanristic.com/2009/12/testing-for-ssl-renegotiation.html

I will let you know if BIG-IP v 9.4.8 HF3 passes the PCI scanning this time.

zoltak
zoltak
Post Count: 3
New Member


--
06/09/2010 12:30 AM  
9.4.8 HF3 failed as well using the iRule.

Does anyone have suggestions?
Nasko
Nasko
Post Count: 1
New Member


--
08/27/2010 08:27 AM  
Any rule you have *must* prevent renegotiation. If you have completed the renegotiation, the attack has already been successful, at least against the HTTP protocol. The reason is that the server buffers the client request, which is malicious coming from the man-in-the-middle (MiTM). Once renegotiation completes, the server executes the buffered request, which means game over.

So to be truly protected, you need to drop the actual renegotiation attempt. This is why netsekure.org reports you are vulnerable.
Josh
Josh
Post Count: 9



--
01/20/2011 02:40 PM  
Is this still the recommended way to mitigate this vulnerability at the BigIP level?

Patching our web servers is an unsavory option at this point.
hoolio
hoolio
Post Count: 11053
MVP - 9


--
01/20/2011 03:08 PM  
F5 has provided a config option in the client SSL profile, called "Renegotiation" to prevent renegotiation by default:


SOL10737: SSL Renegotiation vulnerability - CVE-2009-3555 / VU#120541
http://support.f5.com/kb/en-us/solutions/public/10000/700/sol10737.html

BIG-IP 10.1.0, BIG-IP 10.2.0
Introduce a clientssl / serverssl profile option to control whether midstream SSL renegotiation is allowed. For versions which include this CR, the default setting for the clientssl profile is disabled, and the default setting for the serverssl profile is enabled.


Aaron
Josh
Josh
Post Count: 9



--
01/21/2011 06:20 AM  
Thanks for the quick follow-up hoolio.
Please login or join DevCentral to post a reply.

  

93,050 Members in 191 Countries and Growing!

Join DevCentral Today!

About DevCentral

F5 DevCentral is your source for the best technical documentation, discussion forums, blogs, media and more related to application delivery networking.

So dive in, meet your peers, and get familiar with DevCentral. We hope it makes your job easier and helps you get more from your F5 investment. If new to DevCentral, check out the Getting Started section. And if you have any problems, or think something could be easier to use, let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback      or