Friday April 11, 2008 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. |
This blog copyright 2009 by meena
wow, pretty neat.
Posted by 192.18.120.198 on April 12, 2008 at 09:54 PM IST #
Meena, this feature seems to be having some trouble with standard ReGex syntax from the Core Set v1.6.1. For example, this line in modsecurity_crs_20_protocol_violations.conf:
SecRule REQUEST_HEADERS:'/(Content-Length|Transfer-Encoding)/' "," "phase:2,t:none,deny,log,auditlog,status:400,msg:'HTTP Request Smuggling Attack.',id:'950012',tag:'WEB_ATTACK/REQUEST_SMUGGLING',severity:'1'"
throws these errors when an attempt is made to load it:
config (32208): HTTP8008: Unknown variable Transfer-Encoding)/' in SecRule directive in file /export/WS7/third-party/mod_sec_rules/modsecurity_crs_20_protocol_violations.conf at line 28
config (32208): HTTP8010: Unknown action auditlog,status:400,msg:'HTTP Request Smuggling Attack.',id:'950012',tag:'WEB_ATTACK/REQUEST_SMUGGLING',severity:'1' in directive in file /export/WS7/third-party/mod_sec_rules/modsecurity_crs_20_protocol_violations.conf at line 28
config (32208): HTTP8010: Unknown action tag:'WEB_ATTACK/REQUEST_SMUGGLING',severity:'1' in directive in file /export/WS7/third-party/mod_sec_rules/modsecurity_crs_20_protocol_violations.conf at line 28
The first error is complaining about this construct:
REQUEST_HEADERS:'/(Content-Length|Transfer-Encoding)/'
but as near as I can tell that construct is a valid regex grouping with an OR operator.
The other two errors seem to be complaining about auditlog and its variables being unknown. That's easy enough to live without, but breaking with the regex expression is kinda painful.
Posted by DzM on November 23, 2008 at 06:50 AM IST #
Thanx, Found one culprit. Will fix in next release.
In file "iplanet/ias/server/src/cpp/iws/netsite/lib/libsecrule/SecRec.cpp" line 540 regexp_started != regexp_started;
Should Be regexp_started = !regexp_started;
One BIG limitation with our server is we compare values in pblocks for headers or any variables. Our pblocks contain only lowercase name value pairs. So I do not recommend ACTION t:none (that removes default ACTION t:lowercase).
Anyways why would you only stop Content-Length? You would also want to stop "content-length"or any other lowercase upper case combination.
On my Web Server built with above fix :
$cat ms.conf
SecRuleEngine On
SecRule REQUEST_HEADERS:'/(content-length|transfer-encoding)/' "," "phase:2,t:none,deny,log,status:400,msg:'HTTP Request Smuggling Attack.',id:'950012'"
$telnet 0 1894
HEAD / HTTP/1.0
content-length: ,
HTTP/1.1 400 Bad request
Server: Sun-Java-System-Web-Server/7.0
Date: Sun, 23 Nov 2008 10:33:06 GMT
Content-length: 147
Content-type: text/html
Connection: close
Posted by meena on November 23, 2008 at 04:12 PM IST #