just for my understanding - can someone please clarify which encoding is being used in the regex with F5 release under K59329043 in order to mitigate log4j CVEs exploits ?
I’m referring to this regex
when RULE_INIT {
# To switch to a much more aggressive regexp uncomment the first line and comment the second.
# set static::log4j_regex {(?i)(\$|\\+(0?44|([u0]00|x)24))‘?(\{|\\+(0?173|([u0]00|x)7b))’?}
set static::log4j_regex {(?i)(\$|\\+(0?44|([u0]00|x)24))‘?(\{|\\+(0?173|([u0]00|x)7b))’?\s*((j|b|\\+(0?1[5140]2|([u0]00|x)[64][a2]))|((\$|\\+(0?44|([u0]00|x)24))?‘?(\{|\\+(0?173|([u0]00|x)7b))’?.+?‘?(\}|\\+(0?175|([u0]00|x)7d))’?))}
}
I’m seeing some false positives in the payload of applications where the iRule is at the moment active; nevertheless when I attempt to regex the payload I cannot see any match - so I suspect I might be using the wrong encoding.
The idea here is that, when you encounter a string that starts with ${j the rest of the string is most likely going to be ndi:ldap:/55.55.55.55:1389/Exploit}.
If you remember previous versions of this iRule, F5 was always offering two or three different regexes. More or less permissive. The more characters you inspect, the more permissive the iRule will be. You could also say you will have less false positive.
On the other hand - the more characters you inspect, the more CPU cycles are used. Matching regex is expensive on the CPU. So it’s a trade-off between preciseness and performance.
thank you for clarifying the trade off idea behind.
What I’m still missing here is the encoding part used when performing the Regex comparison - as mentioned in the initial post, I’m seeing some false positives within the application payload. This forced me to manually add some whitelisting within the originally provided iRule.
I’ve attempted to dump the payload as collected by the “HTTP_REQUEST_DATA” event and have it checked against the reference regex (tcl based regex checking - using the f5 built-in tclsh interpreter for ex.) in order to better understand what is exactly matching the Regex - yet I’m seeing no matches.