Skip to main content
Version: 4.6.x.x LTS

InputValidationFilter

The task of the InputValidationFilter is to perform a validation of the incoming requests. This validation is done on the HTTP layers; namely the HTTP headers and the HTTP body can be checked. The InputValidationFilter therefore provides mechanisms to perform the checks according to configurable rules.

As the InputValidationFilter outgrew itself in complexity, we recommend using separate filters for the same functionalities:

  • For the most common OWASP attacks, you can use the ModsecurityFilter.
  • For request and response header validation, you can use the HeaderValidationFilter.
  • For parameter validation, you can use the ParameterValidationFilter.

If it is possible to solve a given use case with one of the filters mentioned above, it is strongly recommended doing so (instead of using the InputValidationFilter).

A configuration rule has the following format:

[RuleID:<ruleId>:][ DecodingRules: <comma-separated list of rules>:<regexp>

The RuleID allows defining a unique id for the rule. This ID will be traced in the log file when there is a match. This allows an easy correlation between a configured rule and the log file.

The DecodingRules configure a chain of decoding functions which is applied to the pattern prior to matching.

The regexp part is the rule itself. Check Regular expressions for more information.

While normally new-line and white-space delimiters are supported, the following attributes only support new-line delimiters.

  • ContentTypesAndLengths
  • FileNameBlackList
  • FileNameWhiteList
  • FormNameBlackList
  • FormNameWhiteList
  • FormNameValueBlackList
  • FormNameValueWhiteList
  • FormValueBlackList
  • FormValueWhiteList
  • HeaderBlackList
  • HeaderWhiteList
  • QueryBlackList
  • QueryWhiteList
  • URIBlackList
  • URIWhiteList
Classname
ch::nevis::isiweb4::filter::validation::InputValidationFilter
Library
libInputValidationFilter.so.1

Profiles

NameDescription
HTTP-ValidationChecks for HTTP protocol validations.
HTTP-Validation-StrictWhitelist patterns for HTTP request headers.
HTTP-Validation-LengthWhitelist patterns for HTTP request headers length.
HTTP-LimitationsEnforces limits on HTTP requests (1KB URI, 12KB query, 100KB input forms, 6MB file uploads).
HTTP-ResponseHeadersWhitelist pattern for HTTP response headers.
ModSecurity-GenericDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset part of the OWASP Core ModSecurity Rule Set. This profile contains rules to prevent several generic types of attacks.
ModSecurity-SQLInjectionsDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset part of the OWASP Core ModSecurity Rule Set. This profile contains rules to prevent SQL-injection attacks.
ModSecurity-XSSAttacksDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset part of the OWASP Core ModSecurity Rule Set. This profile contains rules to prevent XSS attacks.
ModSecurityExtended-GenericDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset for checking the URI part of requests, generated from OWASP Core ModSecurity Rules targeting argument names. The actual version of ModSecurity Rule Set does not contain explicit rules for checking the URI part; so these rules may be used optionally to prevent generic types of attacks in the URI.
ModSecurityExtended-SQLInjectionsDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset for checking the URI part of requests, generated from OWASP Core ModSecurity Rules targeting argument names. The actual version of ModSecurity Rule Set does not contain explicit rules for checking the URI part; so these rules may be used optionally to prevent SQL-injection attacks in the URI.
ModSecurityExtended-XSSAttacksDeprecated This profile is deprecated. Use the ModSecurityFilter with CRS instead.Ruleset for checking the URI part of requests, generated from OWASP Core ModSecurity Rules targeting argument names. The actual version of ModSecurity Rule Set does not contain explicit rules for checking the URI part; so these rules may be used optionally to prevent XSS attacks in the URI.

These pre-defined profiles are updated on a regular basis. We recommend copying the profile you are going to use and to define a new name for the new profile to avoid interference with the application's configuration when updating to a newer version of nevisProxy. This allows you to migrate the updated profile in a controlled and secure way whenever you want.

It is possible to aggregate profiles, as long as they do not overlap (that is, as long as a property is not used in both profiles). However, it is strongly recommended that you use one profile per filter.

See the chapter Configuration profiles for an example how to use profiles.

Configuration

NameType, Usage Constraints, DefaultsDescription
AllowedHeadersstring array optional, basicdefault: allow allA list of permitted header fields. If a request contains a header that is not in this list, it gets blocked. If nothing is configured, all header fields are allowed.
AllowedMethodsstring array optional, basicdefault: allow allDefines the allowed HTTP methods (GET, POST, HEAD, ...). If not configured, all HTTP methods are allowed.
BlockOnErrorboolean optional, basicdefault: trueDefines whether a request is blocked (answers with an HTTP "403 Access forbidden" response) if a configured rule has been broken. Otherwise, a message is traced. The parameter RemoveInvalidHeader can override this parameter for header validation. For more details see the description of the RemoveInvalidHeader parameter further below in this table.
MaxBlockedPerSessioninteger optional, advanced default: not setThis parameter allows to define a maximum number of requests blocked by the InputValidationFilter during a session. If the maximum is reached, the user session will be invalidated.
CaseSensitiveRegexpsboolean optional, basicdefault: falseMakes the regular expressions used in this filter match case sensitive.
CheckAlphanumericInputboolean optional, advanced default: falseIf this attribute is set to true, blacklists will only be applied if the input string is alphanumeric. With the profile PHP-MAX, the configuration attribute CheckAlphanumericInput is set to true.
ContentTypesAndLengthslist of content length rules optional, advanced default: unlimited for allDefines the max. content length per requested content type. A content length rule has the following format:<content type>:<max. length> If not configured, an unlimited length is allowed.
DecodingRuleslist of decoding rules optional, advanced default: not configuredSupports configuration of a newline-separated list of decoding rules. A decoding rule consists of several decoding configurations separated by whitespace or ',' or ';'.If 'DecodingRules' is not configured, every blacklist regexp rule is executed against the respective part of the request (called test string). In the case of a match, the request is blocked. If 'DecodingRules' is configured, the test string is first decoded with the first configured decoding and the regexp rules are then executed against the new test string. If several decodings are configured in on rule, the output from the first rule is the input for the second rule. The following decodings are supported: HTML_decode (see http://en.wikipedia.org/wiki/Character_encodings_in_HTML) URL_decode (see http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html) URL_decode_unicode: Same as urlDecoding, but also handles encoded Unicode characters and IIS unicode encoding. BASE64_decode: base64 decoding of the input. lowercase: Lowercase the input. compress_whitespace: Convert tab, newline, carriage return and form feed characters to spaces, and then converts multiple consecutive spaces to a single space character. replace_comments: Replace C-style comments with a single space character. Non closed comments will also be replaced with a whitespace. normalisePath: Replace multiple forward slashes with a single forward slash and removes directory self-references. jsDecode: Decode JavaScript escape sequences. removeNulls: Remove null bytes from the string. removeWhitespace: Remove all whitespace cha-racters from the string. cssDecode: Decode CSS-encoded characters. Each one of these decoding rule correspond to a input normalization function in the PHP-IDS project. If a decoding chain has been configured on the rule itself, the input parameter will be ignored (overwritten) for the said rule. This attribute configures the default value for the rules not defining a decoding chain.
DefaultDecodingRulestring optional, advanced default: URL_decodeThis parameter allows to configure a decoding function which is always applied first (before the decodings defined in DecodingRules). If ’none’ is configured, no default decoding is applied.
FileNameBlackListlist of file name rules optional, advanced default: allow allSpecifies which patterns in file names will cause the request to be blocked in case of a file upload by a POST request. A file name rule has the following format: [RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp> If not configured, all file names are allowed.
FileNameWhiteListlist of file name rules optional, advanced default: allow allDefines the rules that file names have to comply with in case of a file upload by a POST request for the request to be passed. A file name rule has the following format:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp>If not configured, all file names are allowed.
FormNameBlackListlist of form parameter name rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Blacklist for form parameter names:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp>
FormNameWhiteListlist of form parameter name rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Whitelist for form parameter names:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp>
FormNameValueBlackListlist of form content rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Defines the forbidden values per form parameter name. A form content rule has the following format:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]name:<regexp>
FormNameValueWhiteListlist of form content rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Defines the allowed values per form parameter name. A form content rule has the following format:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]name:<regexp>
FormValueBlackListlist of form value rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Defines the rules for form values that must be fulfilled for the request to be blocked. A content form value rule has the following format:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp>If not configured, all form values are allowed.
FormValueWhiteListlist of form value rules optional, advanced default: allow allDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Defines the rules for form values in order for the request to be passed. A content form value rule has the following format: [RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:<regexp> If not configured, all form values are allowed.
FormNameSkipListlist of form names optional, advanced default: noneDeprecated This parameter is deprecated. Use the parameter ParameterRules instead.Defines a "skip" list of given names for all Form** rules. Skip rules have the following format: <parameter-name-regex>[(:<ruleId>)] ruleIds are optional, if none are specified, the form name is skipped for all Form* rules. If ruleIds are specified, the given parameter is skipped only for rules with the defined ruleId*.
RequestHeaderRuleslist of request header rules optional, advanced default: allow allDefines rules for the header name and value. A header rule has the following format: [RuleID:<ruleId>:]<header-regexp>:<value-regexp>:<action>:[<log level>:[<status code>]]<action>: allow: allow the header value for the matching header names. required: a header with the configured name and value must be in the request. drop: drop the headers matching. deny: block the requests containing matching headers. <log level> (optional, default: allowed headers are logged silently, the others as log): log: allowed and dropped headers are logged as NOTICE. Required and denied headers are logged as ERROR. silent: allowed headers are logged as DEBUG_LOW. Dropped headers are logged as INFO. Required and denied headers are logged as INFO. <status code> ) are used: Condition: :<VARIABLE>:<regexp> *CIDR example: REMOTE_ADDR:CIDR/10.4.12.0/22/
ParameterRuleslist of request parameter rules optional, advanced default: allow allsupported Pragmas: continue (default), breakDefines rules for request parameters (body and query parameters). This parameter uses the following syntax:[Condition:Only the first match will be executed per parameter. Other matching rules will be silently dropped. If a parameter does not match any rule, the parameter will by silently allowed. Parameters are extracted from the request to name-value pairs. The following Content-Types are supported: application/x-www-form-urlencoded: the name and value are defined within the request itself. application/json: the structure path of each json element is used as name. text/x-gwt-rpc: gwt.[i] is allocated as name for each different value sent in the request. * multipart/form-data
ResponseHeaderRuleslist of response header rules optional, advanced default: allow allDefines rules for the header name and value. The same syntax and options as for the input parameter "RequestHeaderRules" can be used.
ResponseCookieRuleslist of response cookie rules optional, advanced default: allow allThe rules that new Cookies (i.e., "Set-Cookie" headers) have to fulfill for the response to be passed, dropped or blocked.*[Condition:
MaxHeadersAllowedinteger optional, security/troubleshooting default: unlimitedThe max. number of HTTP headers allowed in a request. If not configured, an unlimited number is allowed.
MaxQuerySizeinteger optional, security/troubleshooting default: unlimitedThe max. query string length of a request. If not configured, an unlimited length is allowed.
MaxURISizeinteger optional, security/troubleshooting default: unlimitedThe max. URI length of a request. If not configured, an unlimited length is allowed.
MaxBodySizeinteger optional, security/troubleshooting default: unlimitedThe max. size of a request body. If not configured, an unlimited length is allowed.
LimitRequestParametersinteger optional default: unlimitedThe maximum number of parameters allowed on a request. This number must not be bigger than the number set in the attributeLimitRequestParametersof thenavajo.xmlfile . If the attribute is not configured in thenavajo.xmlfile, then there is no limit here.
QueryBlackListstring optionalBlacklist for query validation:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]<regexp>
QueryWhiteListstring optionalWhitelist for query validation:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]<regexp>
ReadLineSizeinteger optional, security/troubleshooting default: 1024The maximum size of embedded headers of a multipart request. An error will result if a longer line occurs.
RemoveInvalidHeaderboolean optional default: falseIf set to "true", nevisProxy will remove headers that are not configured in theAllowedHeadersparameter and process the requests. Otherwise, such requests will be handled as specified in theBlockOnErrorparameter.This parameter is ignored if theAllowedHeadersparameter is not set.
ShowPlainTextValuesboolean advanced default: falseIf set to true, the values of name-value pairs are logged in plaintext. For security reasons this attribute should not be set to true in production, but only under development or integration.
StatusCodestring optional, min: 100 / max: 1000, default: 403Permits specification of an HTTP error code to be sent in the response if input validation fails.
URIBlackListlist of URI rules optional, basicIf an URI (only the path portion) blacklist is configured, validation is successful only if the URI does not match any of the entries in the blacklist. If an URI is found in both the blacklist and the whitelist, validation also fails:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]<regexp>
URISkippListlist of regexps optional, advanced default: not specifiedIf the URI (only the path portion) matches one of the regexps, the request is passed through without any check. This feature is used to reduce the number of false positives:[RuleID:<ruleId>:]``[ DecodingRules: <comma-separated list of rules>:]<regexp>
URIWhiteListlist of URI rules optional, basicdefault: allow allDefines the rules that the URI (only the path portion) has to fulfill for the request to be passed.A URI rule has the following format:[RuleID:<ruleId>:]``[ DecodingRules: <comma separated list of rules>:]<regexp>If not configured, all URIs are allowed.
AuditLog.FileNamestring optional, advancedDefines a file name where to audit the received request parameters (in form of a name value pair). The value will be encrypted using the 'AuditLog.Key'.
AuditLog.RotationPolicystring optional, advancedThe rotation policy for the AuditLog.FileName. Possible values: size:<max.filesize in bytes>:<number of versions> time:hourly
AuditLog.Keystring optional, advancedThe key used to encrypt the parameter value received in a request (form submit for example). The key has the following syntax: plain:<key> : a plain text key pipe://<command> : get the key via a pipe (external program)
RawTypesstring optional, advancedA list of newline-separated lines of header fields that expect a Raw-Type body. Each line has the following format:<content-type-regex>:<name> For each RawType, there will be exactly one name-value pair '<name>=<body-content>' to which the input validation rules, defined within the ParameterRules parameter of this filter, will be applied. This parameter allows to perform input validation on any type of request not using standard Content-Types.
DisabledRuleIdslist of strings optional, advanced default: not specifiedNewline separated list of <ruleId> strings defining rules to disable. The validation rules listed here will be disabled despite their presence elsewhere in the configuration.

Instead of using the deprecated Form** parameters of the InputValidationFilter, you can now use the ParameterRules* attribute. In the following examples you can see some simple examples that can be used instead of the deprecated parameters.

To block a parameter value from a submitted form, instead of configuring the deprecated FormValueBlackList:

<init-param>
<param-name>FormValueBlackList</param-name>
<param-value>
.*foo
</param-value>
</init-param>

You can achieve the same behavior via ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^.*:.*foo:deny
</param-value>
</init-param>

This blocks all incoming requests if any parameter value contains foo.

To allow given parameters to have the previously blocked value, instead of using the deprecated FormNameSkipList and FormValueBlackList:

<init-param>
<param-name>FormNameSkipList</param-name>
<param-value>
parameter1
parameter4
</param-value>
</init-param>

You can achieve the same with ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^parameter1$:.*:allow
^parameter4$:.*:allow
.*:.*foo.*:deny
</param-value>
</init-param>

This will allow the requests to pass through, even if parameter1 or parameter4 contains the value foo.

To allow parameters to have a given value, instead of configuring FormValueWhitelist:
<init-param>
<param-name>FormValueWhiteList</param-name>
<param-value>
bagafoo
</param-value>
</init-param>

You could achieve the same with:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^parameter1$:.*:allow
^parameter4$:.*:allow
^.*:bagafoo:allow
^.*:.*foo:deny
</param-value>
</init-param>

To block a request because one of the Form parameter names, instead of FormNameBlackList:

<init-param>
<param-name>FormNameBlackList</param-name>
<param-value>
exec
action
</param-value>
</init-param>

You could achieve the same with ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^exec$:.*:deny
^action$:.*:deny
</param-value>
</init-param>

To allow only given characters in the Form names, instead of using FormNameWhiteList:

<init-param>
<param-name>FormNameWhiteList</param-name>
<param-value>
^[a-zA-Z0-9]+$
</param-value>
</init-param>

You could add something like this to the previously configured ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^exec$:.*:deny
^action$:.*:deny
^[a-zA-Z0-9]+$:.*:allow
^.*$:.*:deny
</param-value>
</init-param>

This allows all requests with non-special character parameter names (except for exec and action), but block everything else.

It is possible to validate the form value, for a given form field, and block the request if it contains undesired values, just like with FormNameValueBlackList:

<init-param>
<param-name>FormNameValueBlackList</param-name>
<param-value>
isiwebuserid:root
isiwebpasswd:test
</param-value>
</init-param>

The same can be achieved with ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^isiwebuserid$:root:deny
^isiwebpasswd$:test:deny
</param-value>
</init-param>

This blocks if the values root or test are entered.

To add input validation to the entered values of the given form parameters, like with FormNameValueWhiteList:
<init-param>
<param-name>FormNameValueWhiteList</param-name>
<param-value>
isiwebuserid:^[a-zA-Z]*$
isiwebpasswd:^[a-zA-Z0-9]*$
</param-value>
</init-param>

You could achieve the same (combined with the forbidden values) with ParameterRules:

<init-param>
<param-name>ParameterRules</param-name>
<param-value>
^isiwebuserid$:root:deny
^isiwebpasswd$:test:deny
^isiwebuserid$:[a-zA-Z]+$:allow
^isiwebpasswd$:[a-zA-Z0-9]+$:allow
^isiweb.+:.*:deny
</param-value>
</init-param>