Chapter 3. Working with Access Control Policies

Table of Contents

1. Overview
2. Validation order and precedence
3. Policy elements
3.1. Static content policy
3.2. Global URL path policy
3.3. Global parameters policy
3.4. Web application policy parameter classes
4. Regular expressions in Profense
4.1. What are regular expressions
4.2. Metacharacters
4.3. Repetition
4.4. Special notations with \
4.5. Character sets [...]
4.6. Lookaround
4.7. Examples
4.8. Further reading
5. Building the access policy
5.1. Initial configuration
5.2. Learner - automatic application profiling
5.3. Allow from log

Access Control Policies define a list of allowed requests and parameters against a given web system to which access is filtered by Profense™.

An Access Policy or ACL (Access Control List) is defined by a collection of proxy global policies and application specific policies . This mix provides the ability to specify short yet fine grained access control policies:

Global patterns

These are general rules which specify criteria for allowing requests on a proxy global basis. Rules are specified by extension and by specifying a grammar (using regular expressions) for valid URLs and parameters.

Global patterns include Static content policies, Global URL policies and Global parameters policies.

Web applications

In access policy terms a web application is defined as an URL path which takes one or more parameters as input.

The web application policy list consists of one or more URL paths each with a specific policy, a web application policy entry.

The web application policy entry is defined by its URL path and valid input for one or more of the URLs parameters are defined using either a list of allowed values, grammar (a regular expression) or a class which is a predefined regular expression.

Web application policy entries always take precedence over global rules. It is perfectly possible though to utilize a mix of global and specific rules - even for a single application.

Incoming requests are validated in the following order:

  1. Static content policy

    If the extension and path of the requested filename matches the policy defined in Static content policy and the request has no parameters, the request is allowed.

  2. Global URL path policy

    If the request has no parameters and one of the global URL policy patterns matches it it is allowed.

  3. Web applications policy

    If the request (including possible parameters) matches an entry in the detailed web application policy it is allowed.

  4. Web applications policy + global parameters policy:

    If a request matches an entry in the web applications policy but one or more parameters are offending, these parameters are checked against the global parameters policy.

    If there is a combined match the request is allowed.

  5. Global URL policy + global parameters policy:

    If a requested URL with parameters matches a global URL policy pattern and all supplied parameters match global parameter patterns the request is allowed.

  6. In Auto mode Global URL policy + global parameters + negative check for unknown parameters:

    In Auto mode, if a query (a request parameter) does not match any rules it is validated using negative signature based policy rules. If it allowed it is added to the learning sample population and when enough samples are recorded the parameter is included in the positive policy.

  7. No match:

    The request is denied.

As mentioned above an access policy for a proxy is composed of proxy global policies and application specific policies . In addition to these elements a class element is available. The class elements are predefined regular expressions which are defined on a proxy global basis but can be used for specifying ACL list entries.

Requests are validated against the policy elements in the order and precedence described in Section 2, “Validation order and precedence”

Profense™ has full support for standard PCRE (Perl Compatible Regular Expressions).

Following below is a brief regular expression "survival guide". For a more thorough explanation of the subject some links and books are recommended at the end of the section.

A regular expression is a formula for matching strings that follow some pattern.

Regular expressions are made up of normal characters and special characters. Normal characters include upper and lower case letters and digits. The characters with special meanings and are described in detail below.

In the simplest case, a regular expression looks like a standard text string. For example, the regular expression "john" contains no special characters. It will match "john" and "john doe" but it will not match "John".

In an input validation context we always want the expression to match the whole string. The expression above would now be expressed as ^john$, where the characters ^ and $ means starting of line and end of line. Now john will only match "john" but not "john doe". To obtain match of "john doe" as well as "john smith" etc. we employ a few more simple special characters. In its simplest form "john lastname " could be expressed as "^john.*$" meaning: A string starting with the characters "john" followed by zero or more (the "*") occurrences of any character (the "."). For those familiar with the simple wild-card character "*" in (a.o.) DOS and Unix, ".*" equals "*" - that is: anything .

Specifying anything is not very useful in an input validation context. With regular expressions much more fine grained input validation masks can be defined with the rich set of meta characters, character classes, repetition quantifiers, etc.

A brief explanation with some examples follows below.

The following classes are predefined in Profense™. The classes are presented in the order the Automatic Policy Generator evaluates them when automatically mapping classes to input parameters.

Class Regular expression Description
empty   No values allowed
num \d{1,32} Digits - a maximum of 32 digits
payment_card (?:\d{4}[\-\x20]?){2}\d{4,5}[\-\x20]?(?:\d{2,4})? Payment card numbers, allows for spaces and hyphens between number groups.
alphanum \w{1,32} International alphanumeric characters. No spaces. max. 32 chars.
alphanum_long \w{1,256} International alphanumeric characters. No spaces. max. 256 chars.
ms_ident {?[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}}? Microsoft identifier with optional preceding and trailing curly brackets.
path (?!.*(\.\.|//).*)[\w\-/]{1,512} Path containing /, alphanumeric characters and - (hyphen). Consecutive / and period not allowed through negative look-ahead.
text_long [\w\x20+.,\-:]{1,256} Simple international text. max 256 chars.
text_very_long [\w\x20+.,\-:]{1,32000} "Simple" international text - max 32000 chars.
email [\w.+-]+@(?:[\w-]+\.)+[A-Za-z]{2,4} Simple email. Several subdomains possible.
standard [\w\x20_:,.@/()\-={}]{1,4096} Text input, international, several special characters allowed including newline. Max 4096 chars.
standard_long [\w\x20_:,.@/()\-={}]+ Text input, international, several special characters allowed including newline. Max chars. defined by proxy settings max request size.
url (?:https?://)?(?!.*(\.\.|//).*)[\w\x20,.@(){}/?=&\-]+ Simple international URL match. With parameters. Consecutive "/" or "." not allowed (negative look ahead)
printable [^\x00-\x08\x0c\x0e-\x1f\x7f\x80-\x9f]+ Any number of printable characters. Defined by negating character class containing non-printable characters.
anything .+ Anything but newline.
Anything_multiline (.|\n)+ Anything including newline.

Table 3.9. Predefined standard classes in Profense


A number of web sites and books are describing regular expressions in more detail.

Wikipedia

A general description

http://en.wikipedia.org/wiki/Regular_expression

The 30 Minute Regex Tutorial

The code project

.NET specific tutorial, includes a software tool for testing.

http://www.codeproject.com/dotnet/RegexTutorial.asp

Regular-Expressions.info

Excellent web site dealing extensively with the subject.

http://www.regular-expressions.info

There are many good books covering regular expressions. Here we mention a few.

Regular Expression Pocket Reference

Introduction and quick reference from O'Reilly.

http://www.oreilly.com/catalog/regexppr/index.html

Regular Expression Pocket Reference

Introduction and quick reference from O'Reilly.

http://www.oreilly.com/catalog/regexppr/index.html

Mastering Regular Expressions, Second Edition

Learning to use regular expressions efficiently. Does not pretend to be introductory in any way. Also from O'Reilly.

http://www.oreilly.com/catalog/regex2/index.html

Sams Teach Yourself Regular Expressions in 10 Minutes

Sounds appealing. If you are new to regular expressions this is probably a good place to start. From Sams Publishing.

http://www.samspublishing.com/title/0672325667

In Profense™ access policy elements can be added and/or altered in a number of ways:

Learner - automatic application profiling

When enabled, the analyzes incoming requests employing a combination of statistics, heuristic attack classification and server responses. The Learner builds a complete profile of the web site including static requests, web applications and input parameters.

Based on the web site profile a policy is created using a combination of global patterns and specific web application policy entries. In most cases no post adjustment to the automatically built policy is necessary.

Initial configuration

When creating a proxy a few very general policy elements can be added.

Allow from log

Access policy rules can be created or modified by allowing rejected requests from the log section.

When adding or modifying acl entries from log classes are used to map input validation patterns to parameter values.

Manual entry

All access policy elements can of course be added , modified and deleted manually.

© 2007 Armorlogic