Forum Discussion
Rachel
Nimbostratus
Apr 04, 2019Need to reject traffic based on header names not values
We have a need to reject traffic based on the case of the header names not header values.
For example:
Let's say the header name is Trueheader. If a payload comes in with a header name of TRUEh...
Kai_Wilke
MVP
Apr 05, 2019Hi Rachel,
to check if a given request contains a badly formated HTTP header name, you may use the iRule below. It first checks if the request does not contain the correctly formated
Trueheader. If a correctly formated Trueheader is not found, it continues to check if an other-wise formated TrUeHeAdEr exists in the request. If an other-wise formated TrUeHeAdEr is found, it will send a HTTP-400 bad request to the client...
when HTTP_REQUEST {
if { ( [lsearch -exact [HTTP::header names] "Trueheader"] == -1 )
and ( [lsearch -exact [string tolower [HTTP::header names]] "trueheader"] >= 0 ) } then {
HTTP::respond 400 content "BAD REQUEST"
return
}
}
I guess it would be also solution to transparently replace
TrUeHeAdEr with Trueheader, isn't it? If so then you may check out the iRule below. Instead of sending a HTTP-400 bad request it will store the value of the other-wise formated TrUeHeAdEr into a $trueheader variable, remove the TrUeHeAdEr and finally add a correctly formated Trueheader with the value stored in the $trueheader variable.
when HTTP_REQUEST {
if { ( [lsearch -exact [HTTP::header names] "Trueheader"] == -1 )
and ( [lsearch -exact [string tolower [HTTP::header names]] "trueheader"] >= 0 ) } then {
set trueheader [HTTP::header value "trueheader"]
HTTP::header remove "trueheader"
HTTP::header insert "Trueheader" $trueheader
}
}
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
