k8s-bigip-ctlr: TLS iRule fails after recent browser updates
Setup Details
CIS Version : 2.16.1
Build: f5networks/k8s-bigip-ctlr:latest
BIGIP Version: Big IP 15.1.10.3
AS3 Version: 3.48
Agent Mode: AS3
Orchestration: K8S
Orchestration Version:
Pool Mode: Nodeport
Additional Setup details: -
Description
A recent chrome update has modified the TLS handshake to include random grease, resulting in some TLS payloads being split into two packets. When the TLS server name extension is in the second packet, the generated iRule fails and the connection is reset.
Original iRule (part):
when CLIENT_DATA {
# Byte 0 is the content type.
# Bytes 1-2 are the TLS version.
# Bytes 3-4 are the TLS payload length.
# Bytes 5-$tls_payload_len are the TLS payload.
binary scan [TCP::payload] cSS tls_content_type tls_version tls_payload_len
if { ! [ expr { [info exists tls_content_type] && [string is integer -strict $tls_content_type] } ] } { reject ; event disable all; return; }
if { ! [ expr { [info exists tls_version] && [string is integer -strict $tls_version] } ] } { reject ; event disable all; return; }
Fixed iRule (provided by F5 support team):
when CLIENT_DATA {
# Byte 0 is the content type.
# Bytes 1-2 are the TLS version.
# Bytes 3-4 are the TLS payload length.
# Bytes 5-$tls_payload_len are the TLS payload.
set payload [TCP::payload]
set payloadlen [TCP::payload length]
if {![info exists payloadscan]} {
set payloadscan [binary scan $payload cSS tls_content_type tls_version tls_payload_len ]
}
if {($payloadscan == 3)} {
if {($tls_payload_len < 0 || $tls_payload_len > 16389)} {
log local0.warn "[IP::remote_addr] : parsed SSL/TLS record length ${tls_payload_len} outside of handled length (0..16389)"
reject
return
} elseif {($payloadlen < $tls_payload_len+5)} {
TCP::collect [expr {$tls_payload_len +5 - $payloadlen}]
return
}
if { ! [ expr { [info exists tls_content_type] && [string is integer -strict $tls_content_type] } ] } { reject ; event disable all; return; }
if { ! [ expr { [info exists tls_version] && [string is integer -strict $tls_version] } ] } { reject ; event disable all; return; }
Steps To Reproduce
- Deploy some k8s application with nodeport and TLS reencrypt
- Access resources on the application through the virtual server
Expected Result
All resources are loaded without errors and connection resets
Actual Result
Some resources fail to load, connection reset.
Diagnostic Information
LTM log message when iRule is executed and connection resets
Apr 24 10:59:06 XXX err tmm[17484]: 01220001:3: TCL error: /f5cis/Shared/crd_IP_443_tls_irule <SERVER_CONNECTED> - can't read "rc": no such variable while executing "set i $rc"
Observations (if any)
The observed problem occurs in all browsers (Chrome, Edge, Firefox) and the F5 support team confirmed, that recent updates cause the change in behaviour. The iRule provided by F5 reads the whole TLS payload, even if it is split into two packets and allows the TLS payload to be parsed correctly.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (10 by maintainers)
@lavahot , It will be released next week.
@trinaths @vklohiya fyi, below is the tested code working for users, please review in case anything missing
@vincentmli it probably is in https://github.com/F5Networks/k8s-bigip-ctlr/blob/4088633fecf61276eb8f502dd9cd33dc244e7071/pkg/controller/routing.go#L715-L723