iRules

http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/Default.aspx
iRules
F5 DevCentral Topic Group dedicated to open discussion and collaboration related to F5's unique and incredibly powerful iRules scripting language.

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 06/09/2010 12:30 AM by zoltak. 9 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
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: 1822
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-re...tion-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-re...tion-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/...ation.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/...ation.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?
You are not authorized to post a reply.

Active Forums 4.2