HTML cross-site scripting check
-
Block—If you enable block, the block action is triggered if the cross-site scripting tags are detected in the request.
-
Log—If you enable the log feature, the HTML Cross-Site Scripting check generates log messages indicating the actions that it takes. If block is disabled, a separate log message is generated for each header or form field in which the cross-site scripting violation was detected. However, only one message is generated when the request is blocked. Similarly, 1 log message per request is generated for the transform operation, even when cross-site scripting tags are transformed in multiple fields. You can monitor the logs to determine whether responses to legitimate requests are getting blocked. A large increase in the number of log messages can indicate attempts to launch an attack.
-
Stats—If enabled, the stats feature gathers statistics about violations and logs. An unexpected surge in the stats counter might indicate that your application is under attack. If legitimate requests are getting blocked, you might have to revisit the configuration to see if you must configure the new relaxation rules or modify the existing ones.
-
Learn—If you are not sure which relaxation rules might be ideally suited for your application, you can use the learn feature to generate HTML Cross-Site Scripting rule recommendations based on the learned data. The Web App Firewall learning engine monitors the traffic and provides learning recommendations based on the observed values. To get optimal benefit without compromising performance, you might want to enable the learn option for a short time to get a representative sample of the rules, and then deploy the rules and disable learning.
-
Transform cross-site scripts—If enabled, the Web App Firewall makes the following changes to requests that match the HTML Cross-Site Scripting check:
-
Left angle bracket (<) to HTML character entity equivalent (<)
-
Right angle bracket (>) to HTML character entity equivalent (>)
-
<script>, and thereby run malicious code. If you enable both request-header checking and transformation, any special characters found in request headers are also modified. If the scripts on your protected website contain cross-site scripting features, but your website does not rely upon those scripts to operate correctly, you can safely disable blocking and enable transformation. This configuration ensures that no legitimate web traffic is blocked, while stopping any potential cross-site scripting attacks.
-
Check complete URLs for cross-site scripting. If checking of complete URLs is enabled, the Web App Firewall examines entire URLs for HTML cross-site scripting attacks instead of checking just the query portions of URLs.
-
Check Request headers. If Request header checking is enabled, the Web App Firewall examines the headers of requests for HTML cross-site scripting attacks, instead of just URLs. If you use the GUI, you can enable this parameter in the Settings tab of the Web App Firewall profile.
-
InspectQueryContentTypes. If Request query inspection is configured, the App Firewall examines the query of requests for cross-site scripting attacks for the specific content-types. If you use the GUI, you can configure this parameter in the Settings tab of the App Firewall profile.
Cross-site scripting Fine grained Relaxations
-
cross-site scripting Allowed Attributes: There are 52 defaults allowed attributes, such as, abbr, accesskey, align, alt, axis, bgcolor, border, cell padding, cell spacing, char, charoff, charset and so forth
-
cross-site scripting Allowed Tags: There are 47 defaults allowed tags, such as, address, basefont, bgsound, big, blockquote, bg, br, caption, center, cite, dd, del and so forth
-
cross-site scripting Denied Patterns: There are 129 defaults denied patterns, such as, FSCommand, javascript:, onAbort, onActivate and so forth
-
Value expression is an optional argument. A field name might not have any value expression.
-
A field name can be bound to multiple value expressions.
-
Value expressions must be assigned a value type. The cross-site scripting value type can be: 1) Tag, 2) Attribute, or 3) Pattern.
-
You can have multiple relaxation rules per field name/URL combination
-
The form field names and the action URLs are not case sensitive.
Using the Command Line to Configure the HTML Cross-Site Scripting check
-
set appfw profile topic.
-
<name> -crossSiteScriptingAction (([block] [learn] [log] [stats]) | [**none**]) -
[set appfw profile topic.
-
<name> **-crossSiteScriptingTransformUnsafeHTML** (ON | OFF) -
set appfw profile topic.
-
<name> -crossSiteScriptingCheckCompleteURLs (ON | OFF) -
set appfw profile topic.
-
<name> - checkRequestHeaders (ON | OFF) -
<name> - CheckRequestQueryNonHtml (ON | OFF)
-
bind appfw profile <name> -crossSiteScripting <String> [isRegex (REGEX | NOTREGEX)] <formActionURL> [-location <location>] [-valueType (Tag|Attribute|Pattern) [<valueExpression>] [-isValueRegex (REGEX | NOTREGEX) ]] -
unbind appfw profile <name> -crossSiteScripting <String> <formActionURL> [-location <location>] [-valueType (Tag |Attribute|Pattern) [<valueExpression>]]
Using the GUI to configure the HTML cross-site scripting check
-
Navigate to Application Firewall > Profiles, highlight the target profile, and click Edit.
-
In the Advanced Settings pane, click Security Checks.
-
Navigate to Application Firewall > Profiles, highlight the target profile, and click Edit.
-
In the Advanced Settings pane, click Relaxation Rules.
-
In the Relaxation Rules table, double-click the HTML Cross-Site Scripting entry, or select it and click Edit.
-
In the HTML Cross-Site Scripting Relaxation Rules dialogue box, perform Add, Edit, Delete, Enable, or Disable operations for relaxation rules.
-
To view default cross-site scripting patterns:
xss/allowed/attribute
xss/allowed/tag
xss/denied/pattern
-
To customize cross-site scripting Elements: You can edit the User-Defined signature object to customize the allowed Tag, allowed Attributes, and denied Patterns. You can add new entries or remove the existing ones.
Learn HTML Cross-Site Scripting (cross-site scripting) violations
-
show appfw learningdata <profilename> crossSiteScripting -
rm appfw learningdata <profilename> -crossSiteScripting <string> <formActionURL> [<location>] [<valueType> <valueExpression>] -
export appfw learningdata <profilename> **crossSiteScripting*
Configure cross-site scripting fine grain relaxation to bypass custom tags
bind appfw profile p1 -crossSiteScripting <string> <formActionURL> -valueType <valueType> <value expression>
bind appfw profile profile1 -crossSiteScripting formfield1 http://1.1.1.1 -valueType Tag tag1
-
Navigate to Application Firewall > Profiles, highlight the target profile, and click Edit.
-
In the Advanced Settings pane, click Learned Rules. You can select the HTML Cross-Site Scripting entry in the Learned Rules table and double-click it to access the learned rules. The table displays the Field Name, Action URL, Value Type, Value, and Hits columns. You can deploy the learned rules or edit a rule before deploying it as a relaxation rule. To discard a rule, you can select it and click the Skip button. You can edit only one rule at a time, but you can select multiple rules to deploy or skip.
Using the log feature with the HTML Cross-Site Scripting check
/var/log/ folder to access the log messages pertaining to the HTML Cross-Site Scripting violations:
Shell tail -f /var/log/ns.log | grep APPFW_cross-site scripting
Jul 11 00:45:51 <local0.info> 10.217.31.98 CEF:0|Citrix|NetScaler|NS11.0|APPFW|**APPFW_cross-site scripting**|6|src=10.217.253.62 geolocation=Unknown spt=4840 method=GET request=http://aaron.stratum8.net/FFC/CreditCardMind.html?abc\=%3Cdef%3E msg=**Cross-site script check failed for field abc=\"Bad tag: def"** cn1=133 cn2=294 cs1=pr_ffc cs2=PPE1 cs3=eUljypvLa0BbabwfGVE52Sewg9U0001 cs4=ALERT cs5=2015 act=**not blocked**
Jul 11 01:00:28 <local0.info> 10.217.31.98 07/11/2015:01:00:28 GMT ns 0-PPE-0 : default APPFW **APPFW_cross-site scripting** 132 0 : 10.217.253.62 392-PPE0 eUljypvLa0BbabwfGVE52Sewg9U0001 pr_ffc http://aaron.stratum8.net/FFC/login.php?login_name=%3CBOB%3E&passwd=&drinking_pref=on &text_area=&loginButton=ClickToLogin&as_sfid=AAAAAAVFqmYL68IGvkrcn2pzehjfIkm5E6EZ9FL8YLvIW_41AvAATuKYe9N7uGThSpEAxbb0iBx55jyvqOZNiVK_XwEPstMYvWHxfUWl62WINwRMrKsEDil-FC4llF **Cross-site script special characters seen in fields <transformed>**
Access the log messages by using the GUI
-
Navigate to the Application Firewall > Profiles, select the target profile, and click Security Checks. Highlight the HTML Cross-Site Scripting row and click Logs. When you access the logs directly from the HTML Cross-Site Scripting check of the profile, the GUI filters out the log messages and displays only the logs pertaining to these security check violations.
-
You can also access the Syslog Viewer by navigating to NetScaler > System > Auditing. In the Audit Messages section, click the Syslog messages link to display the Syslog Viewer, which displays all log messages, including other security check violation logs. This is useful for debugging when multiple security check violations might be triggered during request processing.
-
Navigate to Application Firewall > policies > Auditing. In the Audit Messages section, click the Syslog messages link to display the Syslog Viewer, which displays all log messages, including other security check violation logs.
Configure click to deploy feature by using the GUI
-
In the Syslog Viewer, select APPFW in the Module options.
-
Select the APP_cross-site scripting as the Event Type to filter corresponding log messages.
-
Select the check box to identify the rule to deploy.
-
Use the Action drop-down list of options to deploy the relaxation rule.
-
Verify that the rule appears in the corresponding relaxation rule section.
Statistics for the HTML Cross-Site Scripting violations
> sh appfw stats
> **stat appfw profile** <profile name>
Display HTML Cross-Site Scripting statistics by using the GUI
-
Navigate to Security > Application Firewall > Profiles > Statistics.
-
In the right pane, access the Statistics Link.
-
Use the scroll bar to view the statistics about HTML Cross-Site Scripting violations and logs. The statistics table provides real-time data and is updated every 7 seconds.
Highlights
-
Built-in Support for HTML Cross-Site Scripting attack Protection—The NetScaler Web App Firewall protects against Cross-Site Scripting attacks by monitoring a combination of allowed attributes and tags, and denied patterns in the received payload. All the built-in default allowed tags, allowed attributes and denied patterns used by the cross-site scripting check are specified in the /netscaler/default_custom_settings.xml file.
-
Customization—You can change the default list of tags, attributes, and patterns to customize the Cross-Site Scripting security check inspection for the specific needs of your application. Make a copy of the default signature object, modify existing entries, or add new ones. Bind this signature object to your profile to make use of the customized configuration.
-
Hybrid Security Model—Both signatures and deep security protections use the SQL/cross-site scripting patterns specified in the signature object that is bound to the profile. If no signature object is bound to the profile, the SQL/cross-site scripting patterns present in the default signature object are used.
-
Transform—Note the following about the transform operation:
-
Fine Grained Relaxation and Learning. Fine-tune the relaxation rule to relax a subset of cross-site scripting elements from security check inspection but detect the rest. The learning engine recommends a specific value type and value expressions based on the observed data.
-
Click to Deploy—Select one, or multiple cross-site scripting violation log messages in the syslog viewer and deploy them as relaxation rules.
-
Charset—The default charset for the profile must be set based on the need of the application. By default, the profile charset is set to English US (ISO-8859-1). If a request is received without the specified charset, the Web App Firewall processes the request as if it is ISO-8859-1. The open bracket character (<) or the close bracket character (>) will not get interpreted as cross-site scripting tags if these characters are encoded in other charsets. For example, if a request contains a UTF-8 character string "%uff1cscript%uff1e" but the charset is not specified on the request page, the cross-site scripting violation might not get triggered unless the default charset for the profile is specified as Unicode.