Anti-evasion filter available - vulnerability with command injection
Marc Stern <marc.stern <at> approach.be>
2008-10-02 10:26:03 GMT
Hello,
When trying go block some shell commands ("command/c", "rm -rf", etc.),
there are very easy ways to totally evade any rule you wrote, by
escaping some characters, or by using other separators than traditional
spaces.
Some examples are
c^ommand /c ...
"command" /c ...
command,/c ...
rm \-rf
I wrote a ModSecurity filter (I guess this the first published one :-0)
that normalises a string for check against a command-line pattern.
It supports all evasion techniques I (and Brian from Breach, thanks)
found for Windows and Unix shell scripts.
This filter is used in production from several months, but I had to
wait until all my customers implemented it before releasing the
vulnerability.
This filter avoids this problem by
* deleting all backslashes [\]
* deleting all double quotes ["]
* deleting all sigle quotes [']
* deleting all carets [^]
* deleting spaces before a slash [/]
* deleting spaces before an open parentesis [(]
* replacing all commas [,] and semicolon [;] into a space
* replacing all multiple spaces (including tab, newline, etc.) into
one space
* transform all characters to lowercase
Usage: t:cmdLine
Ex: SecRule ARGS "(?:command(?:\.com)?|cmd(?:\.exe)?)(?:/.*)?/[ck]"
"phase:2,t:none,t:cmdLine"
It is available for download on
http://www.approach.be/security-modsecurity.html
The package contains source code, binaries for Win32 (compiled with
Visual C++ 6.0), and documentation.
Do not hesitate to give any feedback, or send additional escape
sequences you would find.
Regards
Marc
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
mod-security-users mailing list
mod-security-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mod-security-users