Hi, I have the below iRule that is supposed to remediate the Telerik UI library vulnerability mentioned in the title above. The iRule is built based on their IIS URL Rewrite recommendation. I understand its logic in general but I am not a developer and I am not sure that what I am seeing is OK or not. If I test the iRule with a malicious request using Postman or curl, it works as expected, the request is blocked every time. If I test using a browser, any browser, the first request is blocked and the next one is allowed, which is not what I would expect. Below is the iRule and any help/advice would be much appreciated. I am running BIGIP LTM 17.5.1.3. Thank you
when HTTP_REQUEST {
# Case-insensitive match on path for Telerik.Web.UI.WebResource.axd
set path_lc [string tolower [HTTP::path]]
if { [string match “*telerik.web.ui.webresource.axd” $path_lc] } {
# Normalize method
set method [string toupper [HTTP::method]]
# Decode query string (may be empty)
set raw_q [HTTP::query]
if { $raw_q eq “” } {
set dec_q “”
} else {
set dec_q [URI::decode $raw_q]
}
# Decode Cookie header (if present)
set raw_cookie “”
if { [HTTP::header exists “Cookie”] } {
set raw_cookie [HTTP::header value “Cookie”]
}
set dec_cookie [URI::decode $raw_cookie]
# -------------------------
# Rule 1 (ALLOW): Allow RadAsyncUpload/RadCloudUpload POSTs
# IIS: UrlDecode(QUERY_STRING) must match ^type=(rau|rcu)$ and method == POST
# -------------------------
set allow_post_rau_rcu 0
if { $method eq “POST” } {
if { [regexp -nocase {^type=(rau|rcu)$} $dec_q] } {
set allow_post_rau_rcu 1
}
}
if { $allow_post_rau_rcu } {
# Stop further processing (equivalent to stopProcessing=“true”)
return
}
# -------------------------
# Rule 2 (BLOCK): Block all GET requests containing Content-Type header
# IIS: method == GET AND HTTP_CONTENT_TYPE matches “.+”
# -------------------------
if { $method eq “GET” } {
if { [HTTP::header exists “Content-Type”] && [string length [HTTP::header “Content-Type”]] > 0 } {
HTTP::respond 403 content {Request blocked 2}
event disable
return
}
}
# -------------------------
# Rule 3 (BLOCK): Block PRType and encoded attacks; also block non-GET
# IIS: MatchAny of:
# - UrlDecode(QUERY_STRING) contains “prtype=”
# - UrlDecode(HTTP_COOKIE) contains “prtype=”
# - REQUEST_METHOD != GET
# Note: The allowed POSTs above have already returned.
# -------------------------
if { [regexp -nocase {prtype=} $dec_q]
|| [regexp -nocase {prtype=} $dec_cookie]
|| $method ne “GET” } {
HTTP::respond 403 content {Request blocked 3}
event disable
return
}
# If none of the block conditions match, allow the request.
}
}