Safe object check

The Safe Object check provides user-configurable protection for sensitive business information, such as customer numbers, order numbers, and country-specific or region-specific telephone numbers or postal codes. A user-defined regular expression or custom plug-in tells the Web App Firewall the format of this information and defines the rules to be used to protect it. If a string in a user request matches a safe object definition, the Web App Firewall either blocks the response, masks the protected information, or removes the protected information from the response before sending it to the user, depending on how you configured that particular safe object rule.

The Safe Object check prevents attackers from exploiting a security flaw in your web server software or on your website to obtain sensitive private information, such as company credit card numbers or social security numbers. If your websites do not have access to these types of information, you do not need to configure this check. If you have a shopping cart or other application that can access such information, or your websites have access to database servers that contain such information, you must configure protection for each type of sensitive private information that you handle and store.


A website that does not access an SQL database usually does not have access to sensitive private information.

The safe object check is unlike that for any other check. Each safe object expression that you create is the equivalent of a separate security check, similar to the credit card check, for that type of information.

Configure the safe object check using the GUI


You must configure the safe object check only using the GUI. The command-line interface is not supported.

To add a safe object security check using the GUI:

  1. Navigate to Security > NetScaler Web App Firewall > Profiles.

  2. Select the required profile and click Edit.

  3. In the Advanced Settings pane, click Relaxation Rules.

  4. Select Safe Object and click Edit.

  5. Click Add and configure the following:

    • Safe Object Name. A name for your new safe object. The name can begin with a letter, number, or the underscore symbol. The name can consist of one to 255 letters, numbers, and the hyphen (-), period (.) pound (#), space ( ), at sign (@), equals (=), colon (:), and underscore (_) symbols.
    • Actions. Enable or disable the Block, Log, and Statistics actions, and the following actions:
      • X-Out. Mask any information that matches the safe object expression with the letter “X”.
      • Remove. Remove any information that matches the safe object expression.
    • Regular Expression. Enter a PCRE-compatible regular expression that defines the safe object. You can create the regular expression in one of following ways:
      • By typing the regular expression directly into the text box
      • By using the Regex Tokens menu to enter regular expression elements and symbols directly into the text box
      • By opening the Regular Expressions Editor and using it to construct the expression. The regular expression must consist of ASCII characters only. Do not cut and paste characters that are not part of the basic 128-character ASCII set. If you want to include non-ASCII characters, you must manually type those characters in PCRE hexadecimal character encoding format.


      Do not use start anchors (^) at the beginning of Safe Object expressions, or end anchors ($) at the end of Safe Object expressions. These PCRE entities are not supported in Safe Object expressions, and if used, causes your expression not to match what it was intended to match.

    • Maximum Match Length. Enter a positive integer that represents the maximum length of the string that you want to match. For example, if you want to match U.S. social security numbers, enter the number 11 in this field. That allows your regular expression to match a string with nine numerals and two hyphens. If you want to match California driver’s license numbers, enter the number eight (8).


      If you do not maximum match length, the Web App Firewall uses the default value of one (1) when filtering for strings that match your safe object expressions. As a result, most safe object expressions fail to match their target strings.

You can modify an existing express by selecting the required expression, clicking Open and then configuring the expression in the Modify Safe Object dialog box.

Following are examples of Safe Object check regular expressions:

  • Look for strings that appear to be U.S. social security numbers (SSN). The SSN consists of the following characters in the mentioned order:
    • Three numerals (the first of which must not be zero)
    • A hyphen
    • Two more numerals
    • A second hyphen
    • A string of four more numerals
  • Look for strings that appear to be California driver’s license IDs, which start with a letter and are followed by a string of exactly seven numerals:

  • Look for strings that appear to be customer IDs. The customer IDs consist of the following in the mentioned order:
    • A string of five hexadecimal characters (all the numerals and the letters A through F)
    • A hyphen
    • A three-letter code
    • A second hyphen
    • A string of 10 numerals


Regular expressions are powerful. If you are less familiar with PCRE-format regular expressions, double-check any regular expressions you write. Make sure that the regular expression defines exactly the type of string you want to add as a safe object definition. Careless use of wildcards, and especially of the dot-asterisk (.*) metacharacter/wildcard combination, can have results you did not want or expect, such as blocking access to web content that you did not intend to block.

Safe object check