Forum Discussion
Yozzer
Nimbostratus
Mar 07, 2012XSS checks in irule
Hi
Can an irule check for special chars in a switch statement?
switch -glob [URI::decode [URI::query "?[HTTP::payload]" Param1]] {
"*<" {
set variable "x...
hoolio
Cirrostratus
Mar 13, 2012Jason pointed out a nice trick for this. You can get a count of the number of instances of a character using split and llength:
llength [split [HTTP::payload] &]
Or to be more exact, you'd want to subtract one:
% set str {name1=value1&name2=value2&name3=value3}
% split $str &
name1=value1 name2=value2 name3=value3
% llength [split $str &]
3
Or together:
% expr {[llength [split $str &]] -1}
2
But really, ASM gives you much better normalization and validation. For example, you could apply all of the XSS attack signatures to all parameters. If you have a specific POST request you want to restrict the number of parameters to 1 for, you can configure this in the ASM policy.
Aaron
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
