Wednesday November 18, 2009 I found that experimental Intrusion Detection module as explained in my previous blog doesn't work as expected if an external plugin's AuthTrans SAF is added in obj.conf request processing and if that SAF returns REQ_PROCEED. This may be a rare case.
My id.conf :
SecRuleEngine on SecRequestBodyAccess on SecRule REQUEST_BODY "junk"
case 1: I created a dummy plugin having AuthTrans function myauth1; which just returns REQ_NOACTION it works fine. (look at
<ws7-install-dir>/samples/nsapi/ for examples of how to create a plugin)
#ifdef XP_WIN32
#define NSAPI_PUBLIC __declspec(dllexport)
#else /* !XP_WIN32 */
#define NSAPI_PUBLIC
#endif /* !XP_WIN32 */
#include "nsapi.h"
extern "C"
NSAPI_PUBLIC int myauth1(pblock *pb, Session *sn, Request *rq)
{
return REQ_NOACTION;
}
Added in Magnus.conf
Init fn="load-modules" shlib="myauth.so" funcs="myauth1"
Error logs in that case show :
...
... func_exec reports: executing fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1"
... func_exec reports: fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" returned -2 (REQ_NOACTION)
... func_exec reports: executing fn="myauth1" Directive="AuthTrans"
... func_exec reports: fn="myauth1" Directive="AuthTrans" returned -2 (REQ_NOACTION)
... func_exec reports: executing fn="magnus-internal/secrule-filters-insert"
... func_exec reports: fn="magnus-internal/secrule-filters-insert" returned -2 (REQ_NOACTION)
... func_exec reports: executing fn="ntrans-j2ee" name="j2ee" Directive="NameTrans"
...
case 2: When I change this AuthTrans SAF to return REQ_PROCEED, it doesn't work as expected:
#ifdef XP_WIN32
#define NSAPI_PUBLIC __declspec(dllexport)
#else /* !XP_WIN32 */
#define NSAPI_PUBLIC
#endif /* !XP_WIN32 */
#include "nsapi.h"
extern "C"
NSAPI_PUBLIC int myauth2(pblock *pb, Session *sn, Request *rq)
{
return REQ_PROCEED;
}
Added in Magnus.conf
Init fn="load-modules" shlib="myauth.so" funcs="myauth2"
Error logs in that case shows :
... func_exec reports: executing fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" ... func_exec reports: fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" returned -2 (REQ_NOACTION) ... func_exec reports: executing fn="myauth2" Directive="AuthTrans" ... func_exec reports: fn="myauth2" Directive="AuthTrans" returned 0 (REQ_PROCEED) ... func_exec reports: executing fn="ntrans-j2ee" name="j2ee" Directive="NameTrans ...Note fn="magnus-internal/secrule-filters-insert" is not getting executed here.
You can add a workaround add this secrule-filters-insert SAF above your ExternalPluginAuthTransSAF function:
<Object name="default">This will work fine when ExternalPluginAuthTransSAF function returns REQ_PROCEED but when it returns REQ_NOATCION, these filters will be added twice. If thats ok you can add this.
AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"
AuthTrans fn="magnus-internal/secrule-filters-insert"
AuthTrans fn="ExternalPluginAuthTransSAF"
NameTrans fn="ntrans-j2ee" name="j2ee"
...
</Object>
<Object name="default">Posted by meena ( Nov 18 2009, 03:55:16 PM IST ) Permalink Comments [0]
AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"
AuthTrans fn="magnus-internal/secrule-filters-insert"
AuthTrans fn="ExternalPluginAuthTransSAF"
AuthTrans fn="myauth"
NameTrans fn="ntrans-j2ee" name="j2ee"
...
</Object>
Intrusion detection in Sun Java System Web Server 7.0 update 2 - in experimental stages
| Element |
Possible Values | Description |
|---|---|---|
| <config-file> |
Text |
This
element may be present at the virtual-server
level as well as at the server
level. Points to a file containing ModSecurity rules. As with all file
paths in server.xml it may be an absolute path or a relative path, in
which case it is relative to the config
directory. The file name component may contain wildcard characters to
specify multiple files within the given directory. Multiple config-file
elements may be present as well. |
| Parameter | Description |
| engine
|
(Optional) Indicates how SecRule directives are
processed at request time. "on" indicates that the directives should be applied. "off" indicates that the directives should not be applied. "detection only" indicates that the directives should be evaluated but the result of the evaluation should not be enforced. The default value is what is set by SecRuleEngine directive (if any) in configuration file(s) specified by <config-file> element. If SecRuleEngine directive is not present, it is "off". |
| process-request-body | (Optional) Indicates whether
request bodies are processed when evaluating SecRule directives. When
request body processing is enabled, the server will buffer the entire request body in memory, up
to the limit defined by SecRequestBodyInMemoryLimit
directive (if any) in configuration file(s) specified by <config-file> element. If
SecRequestBodyInMemoryLimit
directive is not present, it is "131072". "on" indicates that request bodies should be processed. "off" indicates that response bodies should not be processed. The default value is what is set by SecRequestBodyAccess directive (if any) in configuration file(s) specified by <config-file> element. If SecRequestBodyAccess directive is not present, it is "off". |
| process-response-body | (Optional) Indicates whether
response bodies are
processed when evaluating SecRule
directives. When response body processing is
enabled, the server will buffer the entire response body in memory, up
to the limit defined by SecResponseBodyLimit
directive (if any) in configuration file(s) specified by <config-file> element. If
SecResponseBodyLimit
directive is not present, it is "524288". "on" indicates that response bodies should be processed. "off" indicates that response bodies should not be processed. The default value is what is set by SecResponseBodyAccess directive (if any) in configuration file(s) specified by <config-file> directive. If SecResponseBodyAccess directive is not present, it is "off". |
| Directive |
Values | Description |
|---|---|---|
| SecRuleEngine | On Off DetectionOnly |
server initialization Default value is "off" |
| Directive |
Values | Description |
|---|---|---|
| SecRule | VARIABLES " [@OPERATOR] Text regular expression or parameters to pass to the operator " [ACTIONS] |
|
| VARIABLES | [&!]VARIABLE[:/regular-expression/]| [&!]VARIABLE[:name]| [&!]VARIABLE[:regular-expression]... |
|
| & |
should count the number of variables in the array. | |
| ! |
x|!x:y examine all x but y should not be checked. | |
| | |
concatenate variables |
|
| :name |
a particular value |
|
| :/regular_expression/ or :'/regular_expression/' | matches regular expression |
| Values | |
|---|---|
| OPERATOR | rx |
| eq |
|
| ge |
|
| gt |
|
| le |
|
| lt |
|
| validateByteRange |
| Values | Description | |
|---|---|---|
| ACTIONS |
ACTION[:xxx],
ACTION[:xxx] ... |
| Values | |
|---|---|
| ACTION |
allow |
| msg |
|
| id |
|
| rev |
|
| severity |
|
| log |
|
| deny |
|
| status |
|
| phase |
|
| t |
|
| skip |
|
| chain |
| Directive |
Values | Description |
|---|---|---|
| SecDefaultAction | ACTIONS |
For a SecRule, if the previous SecDefaultAction directive is
present, those actions takes into effect. If none of these SecDefaultAction directives are present before a SecRule (in that file or files loaded before it), default SecDefaultAction directive with ACTIONS "log,deny,status:403,phase:2,t:replaceNulls,t:compressWhitespace,t:lowercase" is internally added. |
| Directive | Values | Description |
|---|---|---|
| SecRequestBodyAccess |
On Off |
Whether the server should parse
request body or not. Default value is "off" |
| Directive | Values | Description |
|---|---|---|
| SecRequestBodyInMemoryLimit | integer |
Configures the maximum request body size server will store in
memory. By default the limit is 128 KB (131072) |
| Directive | Values | Description |
|---|---|---|
| SecResponseBodyAccess | On Off |
Whether the server should parse response body or not. Default value is "off" |
| Directive | Values | Description |
|---|---|---|
| SecResponseBodyMimeType |
strings |
Configures which |
| Directive | Values | Description |
|---|---|---|
| SecResponseBodyMimeTypesClear | - |
Clears the list of MIME types considered for response body
buffering, allowing to start populating the list from scratch. |
Please look at my next blog on this topic also.
This blog copyright 2009 by meena