Forum Discussion
Lupo_38935
Nimbostratus
Nov 06, 2009mitigating the TLS client-initiated renegotiation MITM attack
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
- JRahm
Admin
Nice work, thanks for sharing! Regarding the variable checking, you can use the catch command (Click here), or you can use info exists varName. - Deb_Allen_18Historic F5 Accountreplace TCP::close command with reject in code above to avoid core dumps
- Paul_Zajicek_73
Nimbostratus
Hi, - Lupo_38935
Nimbostratus
Two thoughts from my side:- 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) - 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.
- While http://netsekure.org/2009/11/tls-renegotiation-test/ reports
- Paul_Zajicek_73
Nimbostratus
Hi, - zoltak_114069
Nimbostratus
Hi, - zoltak_114069
Nimbostratus
We didn't pass the PCI DSS scanning with BIG-IP v 9.4.5 and the iRule for this version. - zoltak_114069
Nimbostratus
9.4.8 HF3 failed as well using the iRule. - Nasko_65861
Nimbostratus
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. - Josh_44053
Nimbostratus
Is this still the recommended way to mitigate this vulnerability at the BigIP level?
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects