Cns 320 en Instructorexerciseworkbook 1 3 Days v01
Cns 320 en Instructorexerciseworkbook 1 3 Days v01
Cns 320 en Instructorexerciseworkbook 1 3 Days v01
CNS-318-1I
Lab Guide
Credits Page
Title Name
Architects Jesse Wilson
Howard Weise
Product Managers Lissette Jimenez
Matthew Brooks
Technical Solutions Developers Anton Mayers
Aman Sharma
Rhonda Rowland
Instructional Designer Elizabeth Diaz
Graphics Designers Ryan Flowers
Joe Baum
Publication Services Akhilesh Karanth
Rahul Mohandas
Zahid Baig
Special Thanks Layna Hurst
Todd Hurst
Layer 8 Training
Contents
Credits Page ...................................................................................................................................................................2
Lab Guide Overview .......................................................................................................................................................5
Lab Environment Overview ...........................................................................................................................................6
Citrix Hands-on Labs ..................................................................................................................................................10
Module 2: Application Firewall Profiles and Policies ...................................................................................................11
Exercise 2-1: Create Profile and Policy for AFWeb .................................................................................................12
Exercise 2-2: Create Profile and Policy for WebGoat .............................................................................................18
Exercise 2-3: Enable Insight Security Reporting .....................................................................................................22
Module 4: Application Firewall: Attacks and Protections ...........................................................................................25
Exercise 4-1: Start URLs and Deny URLs .................................................................................................................27
Exercise 4-2: Application Firewall Signatures .........................................................................................................37
Exercise 4-3: HTML Comment Stripping .................................................................................................................41
Exercise 4-4: Buffer Overflow .................................................................................................................................43
Exercise 4-5: SQL Injection .....................................................................................................................................46
Exercise 4-6: Cross Site Scripting ............................................................................................................................53
Exercise 4-7: Cookie Consistency Check .................................................................................................................58
Exercise 4-8: Form Field Consistency Check ...........................................................................................................68
Exercise 4-9: Credit Card and Safe Objects ............................................................................................................73
Exercise 4-10: Start URLs with URL Closure / Learning ..........................................................................................79
Exercise 4-11: CSRF Form Tagging / Referer Header Validation ............................................................................86
Module 5: Application Firewall Logs and Troubleshooting .........................................................................................97
Exercise 5-1: Custom Application Firewall Error Page ............................................................................................98
Exercise 5-2: NetScaler Insight Center: Security Insight .......................................................................................101
Module 6: Advanced Security and Filtering ...............................................................................................................108
Exercise 6-1: HTTP Callouts ..................................................................................................................................109
Exercise 6-2: IP Rate Limiting ...............................................................................................................................116
Exercise 6-3: App QOE ..........................................................................................................................................121
Exercise 6-4: IP Reputation...................................................................................................................................127
Appendix A: Transition to Part 2................................................................................................................................121
Appendix: Challenge Question Answers ....................................................................................................................137
Lab Guide Overview
In this lab guide, you will get valuable hands-on experience with NetScaler and its security features including
Application Firewall. This lab guide will enable you to work with product components and perform required steps
for configuration of the NetScaler for web application security.
5
Lab Environment Overview
Lab Diagram
SERVER LIST
6
NetScaler List
CREDENTIALS LIST (1): Training Domain Users and Groups for NetScaler Administration
7
Working with the Labs
It is strong recommended, when running the exercises in this class, that you perform NetScaler configurations
using Chrome web browser to access the NetScaler Configuration Management utility and test application attacks
and protections in Firefox.
This will allow you to switch back-and-forth from the configuration utility to the test application multiple
times during each exercise.
When certain labs require you to reset cookies or the browser's session state it will only affect Firefox and
the test applications and not your connection to the management console in Chrome.
Many of the troubleshooting and test utilities that will be required for the Application Firewall and other
exercises are only installed for Firefox.
A suggested windows arrangement is pictured below:
During the Application Firewall exercises, the NetScaler Configuration Utility (GUI) will be run in the web browser
to perform most of the configuration. You will also be asked to open two separate PuTTY sessions to make SSH
connections to the NetScaler CLI.
Putty (1) will be used to view the Syslog output as it is generated, using the following commands:
shell
cd /var/log/
tail -f /var/log/ns.log | grep APPFW
Putty (2) will be used to toggle the Application Firewall feature on or off as required:
enable ns feature appfw
disable ns feature appfw
8
These SSH sessions will be used to make it easy to view Application Firewall violations as they occur or to switch
the feature on and off frequently during exercises. The lab will instruct you when to create the sessions and when
to use them.
It is recommended that students keep the two session running during the Application Firewall labs and switch
between the Putty sessions as needed. A suggested arrangement for the windows is displayed below.
9
Citrix Hands-on Labs
Certification exam preparation Get ready for your Citrix certification exam
by practicing test materials covered by lab
exercises.
10
Module 2: Application Firewall Profiles and Policies
Overview:
Company ABC has previously deployed a NetScaler to load balance their primary web applications. You have been
asked to configure Application Firewall protections in front of the demonstration web applications: AFWeb and
WebGoat.
This module demonstrates the initial configuration of the Application Firewall by creating the necessary profiles
and policies for each of the test applications. The initial profile state is tested to confirm that violations will be
blocked and then the profiles will be modified until a more detailed configuration can be performed.
Create Application Firewall profiles with the appropriate initial settings to suit the application
requirements.
Configure profiles with responses to display when violations occur.
Configure and bind Application Firewall policies to the appropriate virtual servers.
Configure NetScaler Insight Center for AppFlow and Security Insight reporting for the Application Firewall
feature.
This module contains the following exercises using the NetScaler Configuration Utility GUI:
11
Exercise 2-1: Create Profile and Policy for AFWeb
In this exercise, you will create the initial Application Firewall profile settings for AFWeb. This exercise will
introduce the initial Application Firewall profile configuration and explore the default settings. Once the
Application Firewall feature is confirmed to successfully block traffic, the profile will be minimally relaxed to allow
normal page navigation until a more thorough configuration can be completed in Module 4. Application Firewall
events logged to syslog will also be reviewed as part of the configuration and troubleshooting process.
This exercise prepares the initial profile settings and view the initial protection behavior.
Create a new Application Firewall profile and policy for AFWeb. Policy will be applied to AFWeb only.
Configure initial profile settings so that violations are directed to the AFWeb error page: /blocked.htm.
Test the profile to confirm block behavior is occurring and then disable blocking on Start URLs to allow
normal application operation.
In this exercise, you will perform the following tasks:
NOTE: Use Firefox to test applications, while using Chrome to access the NetScaler
Configuration Utility and make configuration changes.
12
3. Enable basic features on the NetScaler:
Navigate to System > Settings.
Click Configure Basic Features.
Verify the following features are already enabled:
o SSL Offloading
o Load Balancing
o HTTP Compression
o Content Switching
Enable (check) the following features:
o Rewrite
o Application Firewall
Click OK.
Click OK.
Click OK.
13
8. Verify Security Checks initial settings:
Click Security Checks under Advanced Settings.
Verify that all basic mode security checks are enabled for Block, Log, and Stats.
Start URL Deny URL Buffer Overflow
Field Formats HTML Cross-Site Scripting HTML SQL Injection
Verify that Learning is disabled for all security checks.
Click OK.
Click Create.
10. Bind the Application Firewall policy to the load balancing virtual server for AFWeb.
Click Done.
NOTE: Use Firefox to test applications, while using Chrome to access the NetScaler
Configuration Utility and make configuration changes.
14
12. Connect to NS_VPX_01 using the NSIP Address (192.168.10.101) using the PuTTY SSH client.
Use the PuTTY shortcut on the desktop of your Student Desktop OR run the following
command: Right Click Start > Run > Putty 192.168.10.101
13. Use the SSH session to view the Syslog events for AppFw:
Access Shell:
shell
Run the following command to output APPFW events as they are generated:
tail -f /var/log/ns.log | grep APPFW
Keep the command running. This window will be referred to as Putty (1).
16. Return to the Putty (1) window displaying the Syslog output.
Verify new violations are displayed as they occur.
IMPORTANT: Keep this putty session with the log output running throughout the Application
Firewall exercises. This window will be referred to as Putty (1) and will be used to view the
current syslog events for the Application Firewall in later exercises.
If the output stops due to a log file rollover event, use the following procedure:
Use CTRL+C to stop the current command.
Then repeat the log output command:
tail -f ns.log | grep APPFW
15
17. Update the Application Firewall profile settings for AFWeb to temporarily prevent blocking on
Start URL violations:
Return to the NetScaler Configuration Utility in Chrome at http://192.168.10.101.
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_afweb and click Edit.
NOTE: When editing a profile the "Save & Close" option is presented to make it easy to apply all
security check changes and close profile in one click; however, it does not save the NetScaler
configuration. It is not a required step. If you click "OK" under the Security Check section, then
all security check changes will be applied. If you click "DONE", the profile will be closed.
The lab procedures will not use the "Save & Close" button as in some situations the profile will
need to remain open for other edits. For consistency, the lab will require student to click "OK"
under sections where settings have been changed. Then the click "Done" step will be used to
close the profile when all edits are complete, when needed.
Note: Make sure that page /blocked.htm is not displayed in the URL when testing.
19. Return to the PuTTY (1) SSH session displaying the Syslog output:
Verify additional APPFW_STARTURL violations are displayed, but this time the actions
indicate the content was <not blocked>.
NOTE:
Disabling the BLOCK action, does not disable the security check or prevent the
processing associated with it.
The violation is still detected, only the NetScaler does not take a corrective action; the
violation is still logged as the LOG action is enabled.
Takeaways:
Application Firewall profiles can be configured with default settings that determine the initial start state.
The basic defaults start with basic protections, no sessionization-based features enabled, and no learning
16
enabled. The advanced defaults start with advanced protections, including sessionization-based features
and URL Closure enabled, no default Start URL rules, and learning enabled.
The security checks included are determined by the profile type: Web, XML, or Web 2.0.
Even though the basic profile contains an initial set of Start URL's, most profiles will require some minimal
settings in order to successfully pass traffic.
Each profile can be configured with a unique blocked page to display on violation either by redirecting to
a specific error page, redirecting to the default page "/", or by importing content for the NetScaler to
display on violation.
17
Exercise 2-2: Create Profile and Policy for WebGoat
In this exercise, you will create an additional Application Firewall profile for use with WebGoat. The initial profile
settings will be enabled, the HTML Error page will be specified, and the default protection level should be tested to
confirm that WebGoat traffic is being blocked successfully. Finally, the profile will be updated to prevent blocking
based on the initial Start URL violations, until a more thorough configuration can be completed in Module 4.
The WebGoat profile will use a similar set of initial configurations as the AFWeb profile to start with. Each
application will then require unique protection settings to ensure security protections while allowing successful
application operation in later modules.
Create a new Application Firewall profile and policy for WebGoat. Policy will be applied to WebGoat
virtual server only.
Create an HTML Error page on the NetScaler to use as a violations blocked page.
Test the profile to confirm block behavior is occurring and then disable blocking on Start URLs to allow
normal application operation.
In this exercise, you will perform the following tasks:
NOTE: In future exercises, if the browser is reset or cookies are deleted, you may need to repeat
this process. If prompted for authentication, use the guest credentials above. If you are
presented with the "Start WebGoat" button, click "Start WebGoat" in order to proceed with the
exercise, whether the exercise notes it or not.
18
4. Create an Application Firewall profile for WebGoat:
Navigate to Security > Application Firewall > Profiles.
Click Add.
5. Create a basic error page for use with Application Firewall violations for WebGoat:
Navigate to Security > Application Firewall > Imports.
Select HTML Error Page tab and click Add.
Enter basicerror_webgoat in the Name field.
Select Text under Import From.
Click Continue.
Enter the following text in the File Contents box:
This request was blocked by the Application Firewall.
Click Done.
NOTE: WebGoat does not have its own error page. The NetScaler is being used to provide a
basic error message during Application Firewall violations. This content will be replaced with a
more robust and user-friendly message later on in the course.
The error message is being used for lab purposes to make it clear when the Application Firewall
blocks an attack. Typically, in production, the "on error" response would be to redirect to "/" or
to use a message that does not explicitly declare the use of a NetScaler Application Firewall in
the protection process. Use care when wording a custom error message.
6. Update the Application Firewall profile for WebGoat with initial settings:
Navigate to Security > Application Firewall > Profiles.
Select (check) profile appfw_prof_webgoat and click Edit.
Click Profile Settings in the right pane (under Advanced Settings) to add the category to
the configuration area.
19
7. Verify Security Checks initial settings:
Click Security Checks under Advanced Settings.
Verify that all basic mode security checks are enabled for Block, Log, and Stats.
Start URL Deny URL Buffer Overflow
Field Formats HTML Cross-Site Scripting HTML SQL Injection
Verify that Learning is disabled for all security checks.
Click OK.
Click Done.
9. Bind the Application Firewall policy to the load balancing virtual server for WebGoat.
Click Done.
20
11. Return to the Putty (1) session displaying the Syslog output:
12. Update the Application Firewall profile settings for WebGoat to temporarily prevent blocking on
Start URL violations:
Return to the NetScaler Configuration Utility in Chrome at http://192.168.10.101.
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_webgoat and click Edit.
Takeaways:
Application Firewall Profiles can be tuned with application specific settings.
AFWeb and WebGoat will have independent security settings, HTML Error/blocked page responses, and
security check settings through application specific profiles.
21
Exercise 2-3: Enable Insight Security Reporting
In this exercise, you will enable Insight Security reporting using NetScaler Insight Center. The NetScaler Insight
Center will be used to apply the appropriate AppFlow configuration to the NetScaler for the AFWeb and WebGoat
virtual servers. The Insight Security reporting will be enabled now to allow for later review of data gathering in the
Application Firewall Logs and Troubleshooting module. A full discussion of Security Insight will be made after the
Attacks and Protections exercises.
Click Create.
22
3. Configure Insight Security monitor for the AFWeb and WebGoat virtual servers.
Select Load Balancing from the View field.
Select (check) each of the virtual servers:
172.21.10.111 lb_vsrv_afweb
172.21.10.112 lb_vsrv_webgoat
Click Enable AppFlow.
4. Verify both load balancing virtual servers display a green check under AppFlow Logging.
5. Click Dashboard tab in NetScaler Insight Center.
Navigate to Security Insight.
Click Get Started.
23
7. View the AppFlow settings configured by NetScaler Insight Center:
View Features:
Navigate to System > Settings.
Click Configure Advanced Features.
Verify AppFlow is now enabled.
Click OK.
NOTE:
Enabling AppFlow with Security Insight using NetScaler Insight Center makes a number
of configuration changes to the managed NetScaler appliance. These changes include
enabling the AppFlow feature, configuring the AppFlow collector, and creating and
binding the necessary AppFlow policies.
However, Security Insight requires some additional settings to be enabled, that Insight
Center does not apply on its own. These settings will be enabled in Module 5.
(The configuration should report the running configuration has not changed, indicating Insight
Center saved the configuration when applying its updates.)
Takeaways:
NetScaler Insight Center simplifies the configuration of AppFlow integration by remotely configuring the
managed NetScaler with the necessary AppFlow collectors and AppFlow policies.
Web Insight and HTML Injection policies enable client/server web site performance data gathering for
HTTP/HTTPS load balancing and content switching virtual servers.
HDX Insight policies enable HDX (ICA Proxy) network metrics for NetScaler Gateway (SSL VPN virtual
servers).
Security Insight allows AppFlow reports on Application Firewall violations for protected load balancing and
content switching virtual servers.
24
Module 4: Application Firewall: Attacks and
Protections
Overview:
This module demonstrates the configuration and use of Application Firewall profiles and related settings to protect
against multiple web application security vulnerabilities and attack vectors.
The exercises in this module demonstrate multiple web application security attacks and how Application Firewall
profiles, signatures, and security checks are used to prevent the attack by blocking the attack or using an alternate
attack mitigation option when available.
Configure additional Start URL regular expressions to allow legitimate traffic to be permitted.
o Understand the difference between Start URL without URL closure and with URL Closure
behavior.
o Understand how URL Closure affects the Start URL configuration.
Create and configure signature protections for a profile and manage rule states within the signature
configuration.
Understand the various web attacks and configure appropriate security checks to prevent the attacks.
Manage protection actions enforced for individual security checks (Block, Log, Stats).
Configure different levels of protection when needed by changing from attack prevention actions (Block) to
attack negation actions (X-Out, Remove, and Transform).
Configure Learning within the profile and then evaluate and deploy learned rules.
Evaluate the NetScaler syslog (/var/log/ns.log) for Application Firewall events and use the syslog to confirm or
troubleshoot profile configurations.
This module contains the following exercises using the NetScaler Configuration Utility GUI:
25
Before you begin:
Estimated time to complete this lab module: 3 hours 15 minutes
Exercises in this module will be performed in blocks. Recommended times per block are identified above. Timings
may vary.
26
Exercise 4-1: Start URLs and Deny URLs
In this exercise, you will enable and update the Start URL security checks so that both AFWeb and WebGoat will
properly display without being prematurely blocked. Additional adjustments to Start and Deny URLs will be made
to ensure that required content is displayed, while preventing access to disallowed content.
Scenario:
During the initial set up of the Application Firewall, you noticed that the default profiles were being blocked even
though the default Start URLs were enabled. Therefore, the first step in configuring the Application Firewall
profiles is to update the Start URL settings so that legitimate application content will not be blocked once the
protection is re-enabled.
After the Start URLs are properly configured to allow normal application traffic to be displayed successfully,
additional adjustments will be made to protect additional areas of the site that are exposed due to Web Server
misconfigurations, backdoors, or other broken navigation links.
This exercise will demonstrate the basic risk posed by forceful browsing and the use of both Start URLs and Deny
URLs to prevent the vulnerability.
Update the Start URLs to allow basic AFWeb navigation to succeed while still preventing access to
normally blocked content. Additional content will be allowed through additional modifications of the Start
URLs. Other content will be added to the deny list.
o In these exercises, it is important that the regular expressions added are properly configured to
only allow or deny the content expected.
o Ensure the regular expressions are not overly broad or overly narrow in scope.
Configuration 1: With the default Start URLs configuration, the Application Firewall profile is
automatically blocking navigation to the primary URLs for AFWeb: http://afweb.training.lab/ and
http://172.21.10.111/.
o Determine why these URLs are blocked and update the Start URLs to allow this content.
o Identify if there is any other content that is still being blocked that should be expected to be
allowed.
o If properly configured, the Allow Demo page will still be blocked and the Deny Demo page is still
allowed. This will be corrected next.
Configuration 2: Make additional adjustments to the allow and deny lists.
o Update the Start URL configuration to allow the Allow Demo page.
o Update the configuration to explicitly block the Deny Demo page and the hidden page
(/private.htm).
Configuration 1: With the default Start URL configuration, the WebGoat profile is automatically blocking
most page navigation with the WebGoat website.
o Beginning with the default page navigation to http://webgoat.training.lab/WebGoat/attack,
identify why the violation is occurring and implement an appropriate Start URL.
o It is important that you avoid configuring an overly broad Start URL.
Configuration 2: After the initial WebGoat page has been allowed, additional site navigation will be
blocked. Identify why the navigational links are being blocked and identify a more appropriate allow Start
URL.
27
In this exercise, you will perform the following tasks:
Configuration 1
2. Enable BLOCK action on Start URL:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_afweb and click Edit.
Click Security Checks under Advanced Settings.
Check (enable) Block next to Start URL.
Click OK to apply changes to the Security Checks section.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
Re-open Firefox.
Challenge Question 1: Why are the first two requests denied but the third request is
allowed?____________________________________________________________________
(For more details see Question 1 in the Challenge Question & Answers section in the Appendix.)
28
5. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output.
Repeat the procedure and add the following additional Start URLs:
^http://172\.21\.10\.111/$
^[^?]+[.]ico$
Click Close to close the Start URL Relaxation Rules after all 3 rules have been created and return
to the Profile properties view. (There will be 5 total rules in the Start URL list.)
NOTE:
The second regular expression allows access to the URL via VIP. It is included for
illustration purposes only.
Confirm all three URLs are now allowed and do not generate any blocked events.
29
Configuration 2
9. Attempt to navigate to the Allow Demo and Deny Demo pages. Use the browser back button to
return to the main page between tests.
Click the Allow Demo link to navigate to the demonstration page.
Confirm this page is currently blocked by Application Firewall.
Click the Deny Demo link to navigate to the demonstration page.
Confirm this page is currently allowed by Application Firewall.
Manually browse to http://afweb.training.lab/private.htm.
Confirm this page is currently allowed by Application Firewall.
The objective with the next several steps is to update the Application Firewall profile so that:
The Allow Demo page is allowed.
The Deny Demo and the backdoor URL /private.htm are blocked.
You will update Start and Deny URLs to accomplish both tasks.
10. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output.
12. Update the Relaxation Rules for Start URLs to allow the "Allow Demo" page:
Select (check) Start URL under Relaxation Rules and click Edit.
Click Add.
Enter the following regular expression in the Start URL field:
/allow[.]demo$
Click Create.
Click Close to close the Start URL Relaxation Rules summary.
30
13. Update the Relaxation Rules for Deny URLs to block the "Deny Demo" page and the Private URL:
Deselect Start URL under Relaxation Rules.
Select (check) Deny URL under Relaxation Rules and click Edit.
Click Add.
Verify Enabled is checked to enable the rule (many Deny URLs are disabled by default
so it is easy to inherit the wrong value.).
Enter the following regular expression in the Deny URL field:
/denyme[.]htm
Click Create.
Note: Make sure you have 50 per page selected at the bottom so you can see the new rules you
are creating.
Repeat the procedure and add the following additional Deny URL:
The Private URL:
/private[.]htm
Click Create.
15. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
31
Configure required Start URLs for WebGoat
Step Action
1. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
Configuration 1
2. Enable BLOCK action on the Start URL:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_webgoat and click Edit.
Click Security Checks under Advanced Settings.
Check (enable) Block next to Start URL.
Click OK to apply changes to the Security Checks section.
3. Disable the Application Firewall feature to test the unprotected WebGoat site.
NOTE: You will need to toggle the Application Firewall feature on and off throughout these
exercises. The recommended procedure is to keep a CLI session running and run the appropriate
enable/disable commands as needed. This will allow you to remain within the Profile
configuration within the GUI for the subsequent steps.
NOTE: This step was performed to make sure WebGoat was operational before re-enabling the
protection settings.
5. Switch to Putty (2) and re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
32
6. Switch to Firefox and reconnect to the WebGoat URL:
http://webgoat.training.lab/WebGoat/attack
Challenge Question 1 (for WebGoat): Why is this WebGoat URL blocked with the default
profile?_____________________________________________________________________
For more details see Question 1 in the Challenge Questions & Answers section in the Appendix.
7. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
During testing, you may or may not also see a violation for /favicon.ico. If the /favicon.ico is not
displayed in the list of violations, it may be due to the browser caching this object when
Application Firewall was disabled, this will be accounted for in later steps.
9. Update the Relaxation Rules for Start URLs to allow minimal required Access to WebGoat:
Click Relaxation Rules under Advanced Settings.
Select (check) Start URL under Relaxation Rules and click Edit.
NOTE: Configuring Start URL rules to also allow access by VIP will be omitted for this application.
All tests will be conducted using FQDN. However, remember to account for possible VIP access
with production applications.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
Re-open Firefox. Do not browse to WebGoat yet.
33
11. Switch to Firefox and reconnect to the WebGoat URL:
http://webgoat.training.lab/WebGoat/attack
Configuration 2
12. In WebGoat, navigate to the following links to test access. Return to the main WebGoat page
between tests to resume navigation:
Click on General > HTTP Basics in the navigation pane on the left.
Click on Access Control Flaws > Remote Admin Access in the navigation pane on the
left.
These requests are blocked by Application Firewall.
All lesson navigational links will be blocked.
13. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Identify which URLs are blocked and why, based on the violations listed in the syslog output.
The navigational links in WebGoat use the form:
http://webgoat.training.lab/WebGoat/attack?Screen=###&menu=###
Challenge Question 3: Why is the base URL created in the previous step along with the default
Start URLs, not enough to allow access to WebGoat?___________________________________
For more details see, Question 3 in the Challenge Question & Answers in the Appendix.
15. Update the Start URLs in the WebGoat profile to allow access to WebGoat content that
references query parameters.
Select (check) Start URL under Relaxation Rules and click Edit.
Click Add.
Enter the following regular expression in the Start URL field:
^http://webgoat[.]training[.]lab/WebGoat/attack([?].*)?$
Click Create.
NOTE: This expression uses the query parameter regex that is included in the default Start URL
and combines it with the WebGoat path. This will broadly allow any query parameter string
concatenated with the /WebGoat/attack path.
This may be overly broad for the legitimate URLs that WebGoat will be using, but we also need
to prevent blocking URLs that conform to patterns for several of the attack demonstrations so
that other attack/protection combinations can be used.
34
16. Add a Start URL for the favicon:
Click Add.
Enter the following regular expression in the Start URL field:
/favicon[.]ico$
Click Create.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
Re-open Firefox. Do not browse to WebGoat yet.
19. Test the connection to WebGoat without Application Firewall protection configured:
Open Firefox and browse to http://webgoat.training.lab/WebGoat/attack.
NOTE: The WebGoat URL path is case-sensitive.
Log on as guest / guest.
Click Start WebGoat.
Verify you can see the WebGoat site page.
NOTE: In future exercises, if the browser is reset or cookies are deleted, you may need to repeat
this process. If prompted for authentication, use the guest credentials above. If you are
presented with the "Start WebGoat" button, click "Start WebGoat" in order to proceed with the
exercise, whether the exercise notes it or not.
These request (and other navigational links) are now allowed by Application Firewall.
21. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
35
24. Save the NetScaler configuration.
Takeaways:
When deploying a new Application Firewall profile, always start by configuring Start URLs to ensure
successful access to a site.
Start URLs (without URL Closure) provide a URL whitelist for site access. If a request is not covered by a
Start URL, it will be blocked. In basic mode, the default Start URLs cover a wide range of content types,
but even with these enabled, some sites may have URLs or content that does not conform to this initial
pattern and additional Start URLs should be defined.
Avoid creating unnecessarily broad Start URLs. Any content, not covered by a Start URL will be blocked
anyway without the need to create an explicit Deny URL.
36
Exercise 4-2: Application Firewall Signatures
In this exercise, you will use Application Firewall signature protections as part of the Application Firewall profile.
The signatures will be created from the default signatures within the NetScaler configuration and associated with
the protection settings for WebGoat.
Scenario:
Now that the Application Firewall profiles have been initially configured to allow minimal required access to the
applications, you have decided to add an extra layer of protection to WebGoat by incorporating the Signature
protections for a hybrid security model.
During this initial round of configuration, you will only be enabling shell-shock protections as the security team
wants to verify the protection behavior prior to rolling out other applications. Additional protections can be
configured within the signature after the initial application evaluation phase.
NOTE: For lab purposes, in order to hack WebGoat for certain demonstrations in later exercises, several of the
built-in signatures cannot be enabled. Please, only enable the settings indicated.
2. Update signatures:
Navigate to Security > Application Firewall > Signatures.
Select (Check) *Default Signatures and then click Update Version.
Version 13 was the signature version available with the NetScaler 11.1.47.14 firmware. Newer
signature versions may be availbale.
If an update to signature version 14 (or later) is available, select OK to update the
version.
Notice the Base version for signatures on the NetScaler is incremented to the new
version if updated.
37
3. Create a new custom signature based on the default signature file:
Select (Check) *Default Signatures and click Add. (This will create a new signature
instance based on the current default signature definition.)
Do not click on *Default Signatures or you will automatically open the default
signatures to edit. Instead, check the option so that Add command will create a new
signature instance based on the Default Signatures.
Use the Search function to find specific rules within the current selected category:
Click Search to open the Search pane.
Change the drop-down list from Enabled to LogString.
Enter passw in the search field next to the drop-down list that now says LogString.
Click Refine Search.
Click OK to apply changes to custom signature. The new signature file "webgoatsigs" is created.
38
6. Add custom signature settings to the WebGoat Application Firewall profile:
Navigate to Security > Application Firewall > Profiles.
Select (check) profile appfw_prof_webgoat and click Edit.
Click Profile Settings under Advanced Settings.
Scroll down to the Common Settings section.
Select webgoatsigs under Bound Signatures
Click OK to apply changes to the Profile Settings.
9. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output.
Takeaways:
Signatures evaluate against requests before the security checks are evaluated.
The NetScaler contains a default set of signatures that can be used to create custom signature definitions
tailored for specific applications or web platforms.
o Signature protections are NOT enabled in the default settings. The default signature cannot be
changed.
o By creating custom signatures from the default set, administrators receive the default signature
protections and can enable or disable individual rules.
Custom signature files can also be used to customize the SQL Injection and XSS (Cross-Site Scripting)
patterns.
o By default, applications are protected by the built-in SQL Injection and XSS settings.
o A custom signature file can be used to define custom SQL keyword, special characters, wild card,
and SQL transformation rules.
39
o A custom signature file can also be used to define custom XSS allowed attribute and tag
dictionaries along with custom denied patterns.
Custom signature files can also be imported using a native file format supported by NetScaler or
generated from external vulnerability scanning systems.
40
Exercise 4-3: HTML Comment Stripping
In this exercise, you will demonstrate sensitive information leak vulnerabilities present in existing HTML comments
and update the Application Firewall protection to prevent this vulnerability.
Scenario:
The security team is concerned that some of the application developers have over-documented some of the
production application code and as a result sensitive information such as application shortcuts and backdoors
appropriate to developers are available to the public users of the site. One such vulnerability, involving both test
and admin credentials, was already identified in an existing application.
While the application developers have a new mandate to sanitize their code prior to publishing on production
servers, the security team is concerned about the delay in time to implementation and the reality that the
developers will miss some instances of sensitive information.
The security team wants the Application Firewall configuration to protect against this specific vulnerability in a way
that poses the least risk to the application functionality.
Use WebGoat and view level of vulnerability in source code on the Code Quality > Discover Clues in the
HTML lesson.
Update the WebGoat application firewall profile to prevent sensitive information leaks within the source
code.
In this exercise, you will perform the following tasks:
Search the page source for HTML comments that contain credentials for this page:
Right-click the page area near "Sign In" and click View Page Source.
In the Source pane, enter CTRL+F to search for the phrase FIXME in the page source.
Search twice more (for FIXME) until you find the HTML comment with the credentials.
Take note of where in the page source these credentials are listed.
Keep the window with the page source open for later reference.
41
3. Click Restart this Lesson to reset the lesson state.
Click Done.
Search the page source for HTML comments that contain credentials for this page:
Right-click the page area near "Sign In" and click View Page Source.
In the Source pane, enter CTRL+F to search for the phrase FIXME in the page source.
If necessary, compare the new page source with the previous page source window.
Near the second instance of "Fixme" in the page source you will now see the HTML Comment
tags next to the "Sign In" header <h1> element: <!-- -->, but no comment content. This instance
previously contained the logon credentials.
Takeaways:
HTML Comments can be a useful source of information for an attacker as it could contain information
about how the application works, including navigational links, backdoor URLs, production or test accounts
that are still active on the system. Many developers don't think to clean this content before posting
production code.
HTML Comment Stripping is not enabled by default.
NetScaler Administrators should evaluate whether comment stripping is required and whether "strip all
comments" or "exclude script tags" are appropriate given the functionality of the website.
If sensitive information cannot be removed using comment stripping (due to client-side code
dependencies not covered by excluding the script tag), then the burden falls on the application
developers to clean output in code prior to posting.
42
Exercise 4-4: Buffer Overflow
In this exercise, you will demonstrate a buffer overflow attack and protection. After the initial demonstration, you
will then adjust the protection level for a specific application.
Scenario:
The application developer and the security team have reviewed the AFWeb application. They are concerned about
some known buffer overflow vulnerabilities within their application and the web server platform it runs on. They
want the NetScaler to be configured to protect against large data objects being submitted.
Enable Application Firewall for AFWeb and confirm that the Buffer Overflow protection can prevent large
content submitted via URLs.
After the initial configuration, the application developer is concerned that the initial thresholds are too
aggressive and are actually blocking legitimate site traffic. The app developer wants you to adjust the
allowed threshold to accept content that matches the application's allowed length but blocks content
above the threshold specified.
2. Switch to Putty (2) and disable the Application Firewall feature using the NetScaler CLI:
Run the following command to disable Application Firewall:
disable ns feature appfw
43
3. Open Firefox and browse to AFWeb:
Browse to http://afweb.training.lab/.
Click Buffer Overflow Demo link to access the demonstration page.
Verify the page loaded successfully.
View the URL used by the link.
The Buffer Overflow demonstration page includes a very long URL. In some cases, manually
supplying a large URL, large Cookie, or large header to a web site could cause a buffer overflow
exception to occur. The Application Firewall will be used to prevent large URLs, headers, or
cookies from being submitted.
4. Switch to Putty (2) and re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
6. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Note that the syslog indicates the URL that caused the violation and its length, along with the
maximum allowed length.
Application Firewall will now allow URLs up to 1228 characters long, but will block URLs longer
than this new threshold. This allows the demonstration to be viewed as a legitimate URL. While
the second demonstration page is still in violation.
44
Takeaways:
Buffer Overflow attacks involve sending large amounts of data using long URLs, large cookies, or headers
whose values exceed expected lengths.
Buffer Overflow protection is enabled by default with maximum defined thresholds for URL Length,
Cookie Length, and Header Length.
The Buffer Overflow protection can be adjusted to set thresholds (larger or smaller) for acceptable
content for your web application, while blocking everything over the allowed maximum threshold.
45
Exercise 4-5: SQL Injection
In this exercise, you will implement a protection against an application with a backend vulnerable to database
exploits using SQL Injection attacks.
Scenario:
The security team and the application team are concerned about two of their applications that frontend
databases. Both of these applications predated development standards that required the applications to use
parameterized input for SQL queries or to ensure the applications properly sanitized user input prior to executing
against the database. Until the code review has been completed, the security team wants you to update the
Application Firewall protections to prevent certain patterns of SQL Injection attacks without compromising the
current application functionality.
Demonstrate the SQL Injection attack and level of vulnerability against WebGoat using the page: Injection
Flaws > String SQL Injection.
Enable Application Firewall protection to prevent the attack using the block action.
Adjust the level of protection and negate the attack using the transform action.
Requirements for this Scenario for AFWeb:
View the AFWeb application and view the level of vulnerability with two of its pages: SQL Injection Demo
and Form Field Demo pages.
Create a relaxation to allow the drop-down list on the Form Field Demo pages to not generate a violation,
while leaving other fields on the site protected using the Block action.
In this exercise, you will perform the following tasks:
46
4. Demonstrate a SQL Injection attack against WebGoat:
Enter the following string in the Enter your last name field:
Smith' OR '1'='1
Click Go.
Verify the page now displays a list of all users and user data from the table and not just
information for Smith.
5. Switch to Putty (2) and re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
47
2. Update the WebGoat profile to transform SQL Injection attacks instead of block transactions:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_webgoat and click Edit.
Click Security Checks under Advanced Settings.
Confirm this time the request is allowed; but the attack is negated and no user data is displayed.
Observe how the transformation affected the user input (which is echoed in the last name field)
after submission.
Verify the text in the last name field displays the transformed expression:
Smith'' OR ''1''=''1
Verify the message under the field, outputs the attempted SQL query with the
transformed text include:
SELECT * FROM user_data WHERE last_name = 'Smith'' OR
''1''=''1'
5. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
48
6. Return to WebGoat in Firefox:
Return to the String SQL Injection page (Injection Flaws > String SQL Injection).
Click Go multiple times to resubmit the transformed content.
Notice how the double single quotes ('') do not keep getting re-transformed after the initial
request. The NetScaler's built-in transformation rules will transform a single-quote (') to a double
single-quote (''), but a double single quote ('') is transformed to itself (''). This may or may not be
appropriate for the application.
NOTE: Transformations can be useful to negate an attack but may pose issues to an application
on the backend if it is performing its own transformations or not expecting transformed
characters.
7. Return to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
8. Update the WebGoat profile to restore the block action instead of the transform action:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_webgoat and click Edit.
Click Security Checks under Advanced Settings.
49
2. Identify Field name and URLs used in the SQL Injection Demo page:
NOTE: This is one method for identifying the field names and their URLs. The field name can also
be identified by viewing the page source, from the syslog entries when a violation is observed, or
from the learned violations list once learning is enabled, in later exercises.
3. Identify Field and URLs used in the Form Field Demo page:
4. Switch to Putty (2) and enable the Application Firewall feature in the CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
50
7. Perform the attack on the Form Field Demo page:
Return to http://afweb.training.lab.
Click Form Field Demo.
Select President's Select Checking in the account type field.
Click Submit. This submits the page to /field.asp.
The objective with the next several steps is to update the Application Firewall profile so that:
The search field on the SQL Injection Demo pages (/sql.htm and /sql.asp) is still
protected from SQL Injection attacks.
While exempting the acct_type field on the Form Field Demo pages (/field.htm and
/field.asp). Other fields on these pages will still be protected.
8. Return to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
9. Configure Relaxation Rule for HTML SQL Injection:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_afweb and click Edit.
Click Relaxation Rules under Advanced Settings.
Select (check) HTML SQL Injection and click Edit.
Click Create and click Close to apply the HTML SQL Injection Relaxation Rules.
51
13. Attempt to submit legitimate data on the Form Field Demo page:
Return to http://afweb.training.lab.
Click Form Field Demo.
Select President's Select Checking in the account type field.
Click Submit this submits the page to /field.asp.
Select President's Select Checking in the account type field again on /field.asp.
Click Submit.
14. Perform the attack on the protected field in Form Field Demo page:
Return to http://afweb.training.lab.
Click Form Field Demo.
Enter the following in the email address field:
Select '
Click Submit.
Verify attacks in the email_addr field are still blocked by Application Firewall.
Takeaways:
The HTML SQL Injection security check can protect against SQL injection attacks against form fields,
headers, and cookies within a web application.
SQL Injection security check supports block on violation and transform on violation protections. The
security check also supports learning for identifying relaxations (exemptions).
Administrators can adjust the strictness of the SQL Injection security check per profile.
o By default, a violation is only identify if both SQL Special Characters and SQL Keywords are
present.
o The strictness can be adjusted to violation on SQL Special Characters only, SQL Keywords only,
Characters AND Keywords (default), and Characters OR Keywords.
o By default SQL Wildcard characters do not trigger violations, but this can be enabled.
If no signatures are bound to the profile, then the identification of SQL Characters and SQL Keywords, and
the transformation rules are handled by the default behavior of the NetScaler. The default settings can be
observed in the default signature.
o If necessary, custom signatures can be created and bound to a profile that adjust the SQL
Keyword, SQL Character, and SQL Wildcard dictionaries.
o Custom signatures can also be used to customize the transformation rules.
o Care should be exercised when changing from the default protections.
52
Exercise 4-6: Cross Site Scripting
In this exercise, you will demonstrate a Cross Site Scripting attack and implement protections against the attack.
Scenario:
The security team has alerted you to another potential issue with the WebGoat web application. The security team
is concerned about Cross-Site Scripting attacks and wants to see a demonstration protecting against attacks
uploaded to the application's built-in message system functionality. They will then consider implementing Cross-
Site Scripting protections for other applications.
First, demonstrate the attack and vulnerability against an unprotected website using WebGoat's Cross-
Site Scripting (XSS) > Stored XSS Attacks page.
Next, enable the protection and confirm a cross-site scripting attack is blocked on violation.
Then, change the application firewall protection to transform on violation.
In this exercise, you will perform the following tasks:
Note that if you navigate away from the page and then return, the message with the uploaded
script is still present, meaning the attack will impact potentially other users of the site.
Click Restart this Lesson before proceeding. (The message badscript1 will not be removed.)
53
Cross Site Scripting 2 - Block Protection
Step Action
1. Use Putty (2) to re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
7. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Verify the previous message badscript1 is displayed in the message list, but badscript2 was
prevented and is not present.
54
10. Update the WebGoat profile to transform Cross Site Scripting attacks instead of block
transactions.
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_webgoat and click Edit.
Click Security Checks under Advanced Settings.
Confirm this attempt was allowed, but transformed by the Application Firewall.
Click badscript3 in the Message List.
Note that the script content is displayed in the Message body, but the script is not
executed (like it was in badscript1).
The message contents were safely transformed, so the message posts but as non-executable
code. Message body is displayed instead of an alert prompt.
55
14. In Firefox, highlight the Message Contents for badscript3, right-click and click View Selection
Source. This will display the page source for the highlighted section only.
Highlight This:
Transformations:
"<" was transformed to <
">" was transformed to >
15. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Takeaways:
The Cross Site Scripting security check can protect against XSS injection attacks against fields, headers,
and cookies within an application. The Cross-Site Scripting can target tags, attributes, and patterns.
Cross Site Scripting security check supports block on violation or transform on violation protections. The
security check also supports learning.
Violations of the security check include:
o Presence of tags or attributes not listed in the allowed tags or allowed attributes lists.
o Presence of content that confirms to a pattern in the denied patterns list.
Cross-Site Script security check settings are based on the settings specified in the default signatures. An
administrator can customize the allowed/denied settings by creating a custom signature file, adjusting the
XSS patterns, and then binding the custom signature to the appropriate application.
In addition, Cross-Site Scripting enforces a single origin-rule, meaning scripts should only access or modify
content on the server on which they are located. Many applications may use extensive libraries of
JavaScript-enhanced web content that violates this rule. The Cross-Site Security check behavior must be
adjusted.
56
Upon transformation, the NetScaler encodes the "<" and ">" script tag delineators with their html
encoded counterparts: < or >.
NetScaler 11.0 and later implements a change to the violation triggers for Cross-Site Scripting that is
different than prior releases.
o Previously, the presence of unmatched brackets could trigger a violation. Example a "<" without
a corresponding ">", or two empty brackets with no content between "<>".
o To support streaming content, where unmatched brackets can occur, cross-site script now only
triggers if both tags occur "<" followed by a ">".
57
Exercise 4-7: Cookie Consistency Check
In this exercise, you will demonstrate a cookie tampering attack and configure the NetScaler Application Firewall to
prevent the attack.
Scenario:
The security team wants to see a demonstration of how to use the Application Firewall to prevent cookie
tampering and poisoning attacks. For this example, AFWeb will be used since it creates both persistent and
transient cookies as part of the application operation.
The security team first wants to see what the attack prevention behavior is like using the block action. The team
also wants to better understand the tracking process the NetScaler users for the cookies generated by the
application, in order to ensure the various application development teams that the NetScaler protection should
not "break the application". Prior to performing an attack, the security team wants to be sure you demonstrate
normal application operation with the protections in place before performing the attack demonstration.
After the basic demonstration, the security team has heard some troubling reports from some of their application
developers that a few of the legacy applications are storing sensitive information in cookies used to process user
logon or application security decisions. These particular applications are slated to be rewritten to address this
concern, but you have offered to show the Cookie Consistency check transformation action as well, in order to
mitigate some of these risks. Applications will need to be tested to ensure that the transformation actions do not
create an unexpected issue for the necessary applications.
Demonstrate the cookie tampering attack using AFWeb with protections disabled.
o Use the AFWeb Cookie Consistency Demo page and view the normal page behavior while
unprotected.
o Use browser plug-ins to view cookie state and properties as the cookies are created, modified,
and deleted.
Next, enable the Cookie Consistency Check with Block action and repeat the attack while the protection
features are enabled. Observe the protection behavior and violation events.
Then, update the Cookie Consistency Check to protect cookies with the Transformation settings and
repeat the attack while investigating the transformation options.
o The transformation lab will demonstrate cookie transformation by encrypting cookies, proxying
session cookies, and modifying cookie HTTPOnly and Secure flags.
Finally, update the profile with a relaxation to create an exemption for the cookie.
In this exercise, you will perform the following tasks:
58
Cookie Consistency 1- View Cookies and Perform Cookie Tampering Exploit
Step Action
1. Switch to Putty (2) and disable the Application Firewall feature using the NetScaler CLI:
Run the following command to disable Application Firewall:
disable ns feature appfw
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
IMPORTANT:
For this exercise, make NetScaler configuration changes in Chrome and test AFWeb in a
single instance of Firefox.
During this exercise, you will be asked to clear session state and cookies in Firefox
multiple times. Be sure you close and restart all instances of Firefox when asked.
When viewing output in LiveHTTPHeaders, you may capture some background process
from Firefox. Ignore this output. Most of these services were disabled, but a few still
occur.
Note: There are 2 tools menu’s select the one at the top next to bookmarks.
59
4. Access the Cookie Consistency Demonstration Page:
Switch to Live HTTP Headers to view the cookie(s) that are set:
The final request now lists multiple cookies:
ASPSESSIONID (there will be at least one cookie present)
MySiteVisitorName
Web Developer Extension can also be used to view Cookies (and Cookie parameters) in Firefox:
Switch to AFWeb tab.
Click Tools > Web Developer Extension > Cookies > View Cookie Information.
The current cookie details will then be displayed in a new tab.
Use either Live HTTP Headers or Web Developer Extension to identify details such as:
Which cookies are temporary or persistent?
Are cookie contents encrypted or clear text?
Are cookie flags for HTTPOnly or Secure set or not set?
60
6. Continue with the Cookie tampering exercise using the Cookie Consistency Demo page:
NOTE: The "modify" button uses client side code to change the cookie without having the server
perform the modification. Other utilities such as Tamper Data could have been used to
manipulate this cookie as well.
This type of client-side manipulation of the cookie is what the NetScaler will be used to prevent.
Switch to Live HTTP Headers to view the session cookie that remains:
ASPSESSIONID is still present.
MySiteVisitorName is deleted.
The page state displayed is directly related to the state of the MySiteVisitorName cookie. Be
aware of this as we use the NetScaler to prevent the cookie tampering attack.
61
8. Clear all cookies to fully reset demonstration:
Make sure the Firefox window has focus, then enter CTRL+SHIFT+DEL. Alternate: Click
History > Clear Recent History.
Ensure Everything is selected in the Time Range to Clear box and Cookies are included
in the Details.
Click Clear Now.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
NOTE: Cookie Consistency check is currently disabled as it is not on by default with the Basic
settings.
2. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
Use Web Developer Extension to view the current cookies on the site:
Click Tools > Web Developer Extension > Cookies > View Cookie Information.
Switch to the Cookie Information tab and confirm one cookie exists:
citrix_ns_id This is the NetScaler sessionization tracking cookie.
62
5. Next, access the Cookie Demonstration page:
Switch to the AFWeb tab.
Click Cookie Consistency Demo link.
Use Web Developer Extension to view the current cookies on the site:
Click Tools > Web Developer Extension > Cookies > View Cookie Information again.
Switch to the second Cookie Information tab and confirm three cookies exist:
citrix_ns_id This is the NetScaler sessionization tracking cookie.
citrix_ns_id_.training.lab_%2F_wat Tracking cookie for other session cookies.
ASPSESSIONID Session cookie created by the AFWeb application.
6. Next, set the cookie with the custom value (This is not an attack):
Switch to the AFWeb tab.
Enter <your name> in the Name field.
Click Submit.
Verify the Cookie Demonstration page now displays the value of your cookie: <your
name>.
Use Web Developer Extension to view the current cookies on the site now:
Click Tools > Web Developer Extension > Cookies > View Cookie Information again.
Switch to the third Cookie Information tab and confirm five (5) cookies exist:
citrix_ns_id This is the NetScaler sessionization tracking cookie.
citrix_ns_id_.training.lab_%2F_wat Tracking cookie for other session cookies.
citrix_ns_id_.training.lab_%2F_wlf Tracking cookie for other persistent cookies.
MySiteVisitorName Persistent cookie created by the AFWeb application.
ASPSESSIONID Session cookie created by the AFWeb application.
NOTE: These lab steps were included to demonstrate how the Cookie Consistency check tracks
sessionization and the cookies created by the application before showing the attack negation.
NOTE: With the Cookie Consistency Check, on violation the BLOCK action does not redirect the
user to the specified HTML error page, instead the illegally modified cookie is stripped from the
request by the NetScaler and never reaches the Web Server.
The cookie will still be in the client side page, but it is not reaching the web server during the
request. As a result, there will still be 5 cookies present in the browser when viewed using Web
Developer Extension.
63
8. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Also note the cookie is in violation from multiple URLs as the cookie is presented in multiple
requests for the different page objects (.css, images, etc.).
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
NOTE: The Cookie Consistency check is unique in that the BLOCK and TRANSFORM actions can
be enabled at the same time. Cookie Transformation changes the way Cookie Consistency checks
work. Enabling Transform actions only without a Block action may not protect against all attacks.
64
3. Open a new instance of Firefox and access the AFWeb site:
Browse to http://afweb.training.lab/.
Click Cookie Consistency Demo link.
This value was accepted successfully and your custom value is displayed in the page.
4. Use Web Developer Extension to view the current cookies on the site:
Click Tools > Web Developer Extension > Cookies > View Cookie Information.
Switch to the Cookie Information tab and confirm only two (2) cookies exist:
citrix_ns_id This is the NetScaler sessionization tracking cookie.
MySiteVisitorName Persistent cookie created by the AFWeb application.
The Session Cookie ASPSESSIONID is not displayed at all client side as it is being proxied by the
NetScaler.
Also, the NetScaler does not generate tracking cookies when using the Transform option for
Cookie Consistency checks.
NetScaler identified this request as a violation and removed the cookie from the request. Verify
you are back at the prompt for your name, indicating no cookie was sent to server.
65
7. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
IMPORTANT:
Close all instances of Firefox (including Tamper Data), then re-open Firefox, before
continuing. This ensures any session cookies are also cleared.
66
3. Switch to Firefox and access the AFWeb site:
Browse to http://afweb.training.lab/.
Click Cookie Consistency Demo.
No violation was detected once the cookie was exempted from the protection.
Takeaways:
Cookie Consistency Check requires the NetScaler to utilize sessionization and session tracking for each
user connecting to the application. With the block protection enabled, the NetScaler will track the
sessionization cookie assigned to the user's session and all persistent and all session cookies generated by
the application.
In order for Cookie Consistency check to be effective, the NetScaler must first see the creation of the
original application cookies. Therefore, enabling this security check for users who have existing long-lived,
persistent cookies on their devices to begin with due to previous connections to the application will
generate numerous false positives for cookie violations. Users must delete existing cookies and request
fresh cookies when this security check is enabled. Existing cookies are not tracked by the NetScaler and
will be seen as an automatic violation.
Cookie Consistency check also supports a transform action, which allows three potential modifications to
the cookie set by the application. When the transform action is enabled, the block behavior and
conditions for violation are slightly different than when the action is set to block.
o Encrypt Server Cookies: Encrypt all, Encrypt session only, Decrypt only, none.
o Proxy Sever Cookies: Session only, none.
o Flags to add to cookies: All, HTTPOnly, Secure, none.
With the block action enabled, upon violation, the Application Firewall strips the cookies in violation from
the request and the cookie never reaches the server. A block violation will be logged, but no "block" error
page will be displayed.
With the transform action enabled, cookies will be rewritten according to the transformation rules.
Cookie transformations are not logged in syslog.
Block and Transform actions can be enabled at the same time.
67
Exercise 4-8: Form Field Consistency Check
In this exercise, you will demonstrate how the form field consistency security check can protect against parameter
and form field manipulation attacks.
Scenario:
The security team has asked you to implement Form Field Consistency protection for the WebGoat application. But
after their initial testing, they were getting some immediate violations. In this case, they want Form Field
Consistency to be enabled to protect the website from client-side manipulation
First, view the attack against WebGoat when the protection is disabled. Use the Parameter Tampering >
Exploit Hidden Fields demonstration page for testing.
Next, explore the normal operation of the website and investigate how the application handles data
passing during the purchase process.
Then, enable the Form Field consistency check. Prior to performing the attack, first attempt to operate
the site normally.
o Identify any violations that are being identified erroneously and update the Form Field
Consistency check to allow this content.
o Verify normal site operations are restored.
Finally, enable the Form Field Consistency check and ensure the previous attack is prevented.
In this exercise, you will perform the following tasks:
Form Field Consistency 1 - Parameter and Form Field Manipulation - Attack Demonstration
Form Field Consistency 2 - Attack Protection
68
4. In Firefox, open Tamper Data
Click Tools > Tamper Data.
Click Start Tamper.
Tamper Data will run in a separate window. Arrange the windows so you can see Tamper Data
on one side and your regular Firefox browser running WebGoat on the other.
While Tamper Data is running it will intercept requests client-side before submitting them to the
server, allowing you to manipulate headers and query parameters in the request.
In the right-pane, Tamper data displays the query parameters posted in the request. Change the
following parameters:
Enter 10 in QTY (quantity).
Enter 1.99 in Price.
Click OK to submit the modified request.
Confirm the total price displayed reflects the modified values and you received 10 TV's
for $19.90.
6. Switch to WebGoat in Firefox and click Restart this Lesson before proceeding.
NOTE: Form Field Consistency check is currently disabled and not yet in effect.
69
2. Switch to Firefox and browse to WebGoat: http://webgoat.training.lab/WebGoat/attack.
Navigate to Parameter Tampering > Exploit Hidden Fields.
Refresh or reload the page.
NOTE:
Hidden Fields can be viewed in the page source, as well.
Web Developer Extension (and similar tools) could be used to manipulate this form
field; however, WebGoat has some built in protections against modifying the price in
this way, so the hack demonstrated using Tamper Data to adjust the Query Parameters
during the POST is the optimal attack for this site.
3. Return to the NetScaler configuration utility and connect to the NSIP: http://192.168.10.101.
Expected Result: WebGoat is blocked by the Application Firewall, but no attack as been
performed, yet. (In a few odd situations, WebGoat may not be blocked immediately. Double-
check if Form Field Consistency check is enabled within the profile. If still an issue, reset Firefox
before continuing.)
Explanation: Parts of the WebGoat navigation menu are modified using client-side code. This
can result in the regular navigation parameters like "menu" and "screen" triggering a false
positive once Form Field Consistency is enabled.
Before proceeding with the exercise, you will configure an exception for these particular
parameters in order to allow legitimate site operation.
70
6. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Note: Syslog only flagged the first violation as the request was redirected without requiring
additional processing. The "Screen" parameter will also trigger a violation. Both updates will be
made at one time.
7. Return to the NetScaler configuration utility and connect to the NSIP: http://192.168.10.101.
8. Update the Application Firewall profile for WebGoat with a relaxation for the Form Field
Consistency Check.
Remain in the profile settings for appfw_prof_webgoat.
Click Relaxation Rules under Advanced Settings.
Select (check) Form Field Consistency under Relaxation Rules and click Edit.
Click Close to close the Form Field Consistency Relaxation Rules window.
NOTE: For the Action URL regular expressions, DO NOT include a trailing slash or "$".
This URL pattern will exempt the Screen and Menu parameters from every URL on
webgoat.training.lab. This is necessary due to how WebGoat navigation is handled.
Refresh the page when done viewing the Form Field properties.
71
10. Perform the Hidden Field Manipulation / Form Field Manipulation attack:
In the right-pane, Tamper data displays the query parameters posted in the request. Change the
following parameters:
Enter 10 in QTY (quantity).
Enter 1.99 in Price.
Click OK to submit the modified request.
12. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
Click Done.
Takeaways:
Form Field Consistency check is not enabled by default with the basic protections, but is enabled with the
advanced protections.
The NetScaler takes forms in responses with a custom value in the as_fid field and then compares the
computed value of the form fields with the form is represented by the client during a request. If the
current form computed value doesn't equate to the original computed value or if the as_fid field is
present, a violation occurs.
Form Field consistency check ensures that:
o No new fields are created or no fields were removed from the original response.
o Hidden and read-only fields do not change values.
o Fields should not change types.
o Field lengths should not change, if originally specified.
o Field values are consistent with the field input type.
72
Exercise 4-9: Credit Card and Safe Objects
In this exercise, you will demonstrate response time protections and prevent credit card (PCI) and other sensitive
information leaks from being displayed in web responses.
Scenario:
The security wants to ensure that the Application Firewall can also prevent leakage of protected information for
their applications that accept payment information and sensitive user identification information. Specifically, they
want to confirm the ability to block credit card numbers, US tax identification (social security) numbers, and phone
numbers in a variety of formats.
NOTE: While the SQL Injection attack in WebGoat exposes a list of credit card numbers in the
user property dump, none of the numbers in the WebGoat application actually conform to valid
test credit card numbers and will not be suitable for the attack prevention demonstration with
Application Firewall.
AFWeb will be used for this demonstration. Please note that the numbers listed in AFWeb
consist of a mixture of invalid patterns and numbers that conform to test accounts.
3. Switch to Putty (2) and re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
73
5. Update the AFWeb profile to enable Credit Card protection:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_afweb and click Edit.
NOTE: Secure Credit Card Logging is enabled by default. This allows Credit Card protection
violations to be logged, but prevents logging the credit card numbers to the syslog output. It is
strongly recommended that this value is NOT disabled.
Verify the connection request was terminated and the page does not load. Response-time
security checks terminate the response; they do not redirect to the HTML error page.
8. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
With Secure Logging of Credit Card numbers enabled (GUI or CLI setting), credit card numbers
are NOT included; if security logging of Credit Card numbers is disabled, Credit Card numbers will
be included in syslog events. (Secure Logging is on by default; this is a profile setting.)
74
10. Update the AFWeb profile to enable Credit Card protection using transform actions:
Navigate to Security > Application Firewall > Profiles.
Select appfw_prof_afweb and click Edit.
This time the response is displayed but numbers that match valid Credit Card patterns are X-ed
out except for the last 4 digits. Numbers not conforming to valid Credit Card patterns are not
masked. Notice that certain credit card patterns can be identified even if digits are separated by
spaces ( ) or hyphens (-).
12. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
3. Switch to Putty (2) and re-enable the Application Firewall feature using the NetScaler CLI:
Run the following command to enable Application Firewall:
enable ns feature appfw
75
5. Update the AFWeb profile to enable Safe Object protections:
Navigate to Security > Application Firewall > Profiles.
Select appfw_prof_afweb and click Edit.
NOTE: Other regular expressions could be used depending on the complexity of the pattern
being matched. Watch out for expressions being too general and matching a wide range of
legitimate page content.
Also note that each Safe Object is, in effect, its own security check. Each object pattern, can be
protected with its own unique settings for Block, Log, Stats or transform options for X-Out or
Remove.
NOTE: Other regular expressions could be used depending on the complexity of the pattern
being matched.
Verify the connection request was terminated and the page does not load. Response-time
security checks terminate the response; they do not redirect to the HTML error page.
Since the page contained both objects and one is set to block, while the other is set to
transform, the block action takes precedence and no content is displayed.
76
9. Switch to Putty (1) window displaying the syslog (/var/log/ns.log) output:
The security check does identify the security check (Safe Object), the safe object name the
pattern matched, and the pattern found.
NOTE: It is important to note that unlike with Credit Cards, safe object patterns are included in
the log and there is no "secure logging" enabled/disabled equivalent option. The security check
logging action can be disabled to prevent logging content, but this omits a record of the action as
well.
14. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
NOTE: To avoid logging safe objects in syslog, you will need to disable the log action for the Safe
Object. This means you won't have the record of the security check action when violations occur.
77
Takeaways:
Response time checks will terminate the response upon violation when the block action is specified.
For Credit Cards, the response time check can allow administrators to specify the credit card patterns to
protect (within the list of providers supported by NetScaler), the maximum allowed number of cards
permitted per page, and whether to block on violation or X-out on violation.
By default Credit Card numbers are not logged to syslog when an event is reported. This is controlled by
the "Secure Credit Card Logging" parameter in each application firewall profile. Secure logging is enabled
by default. If the setting is disabled, credit card numbers which trigger violations will be included in syslog
events.
Safe Object is a custom response time security check. Administrators can define a regular expression that
identifies content of concern. Each Safe Object rule acts as its own security check and can be individually
configured for block, log, stat, x-out, and remove behavior.
o X-out transformation performs a full mask of the pattern and not a partial mask. The exact
behavior depends on how the regex is defined.
o If multiple objects appear in the same page with different violations in effect, Block will take
precedence over transformations and the response will be terminated.
o If multiple objects appear in the same page and they all use transformation actions such as X-out
or remove, then each object will be handled according to its protection settings.
o If LOG is enabled, the violation will appear in syslog but so does the Safe Object content that
triggered the violation. For sensitive information, the log action may need to be disabled to avoid
including this information in syslog as another point of exposure.
78
Exercise 4-10: Start URLs with URL Closure / Learning
In this exercise, you will configure application firewall protections for AFWeb to use Start URLs with URL Closure.
Scenario:
The application team for AFWeb has brought up some concerns with the security team. They realize that a portion
of their site is not properly implementing access security. Content available at the /private2.htm page should only
be available to users who properly navigate various gatekeeping pages first, but they want the content denied if
someone attempts to bypass this. Placing the content on a Deny URL list for everyone would be too strict to allow
legitimate site operation.
The application team wants the Application Firewall configuration to be updated to allow for this content. They
also want to verify that future site updates can be identified and accounted for by quickly updating the site.
The security team wants you to implement URL Closure and demonstrate the Application Firewall learning engine
to assist with the re-configuration of the site, using these new settings. This way they can see how to use learning
for future site update cycles.
At this point, the AppFw Profile for AFWeb is configured with Start URLs enabled and URL Closure
Off. The current behavior of AFWeb is determined by the current list of Start URLs and Deny URLs
defined.
79
2. In Firefox, browse to http://afweb.training.lab
Test the following demonstration links on the default page and confirm the results:
Allow Demo: Link takes you to the /allow.demo page. Link is allowed due to previous Start
URL configuration.
Deny Demo: Link attempts to take you to the /denyme.htm page, but is blocked due to the
previous Deny URL configuration.
URL Closure Demo: Link takes you to /closure1.htm.
Closure2 Demo: Link takes you to /closure2.htm.
Private2 Demo: Link takes you to /private2.htm.
All three links are allowed as the URLs conform to the normal Start URL patterns currently
configured.
Manually browse to the following URL paths and confirm the results:
Manually browse to http://afweb.training.lab/private.htm. This is denied due to the
previous Deny URL configuration.
Manually browse to http://afweb.training.lab/private2.htm: This is allowed.
This step demonstrates which URLs are allowed or denied based on the current Start URL (without
URL Closure configuration).
3. Return to the NetScaler Configuration Utility in Chrome. Connect to NS_VPX_01 using the NSIP at
http://192.168.10.101.
4. Update the Application Firewall profile for AFWeb:
Navigate to Security > Application Firewall > Profiles.
Select (check) appfw_prof_afweb and click Edit.
80
6. Update the AFWeb Profile relaxation rules for Start URLs:
Click Relaxation Rules under Advanced Settings.
Select (check) Start URL under Relaxation Rules and click Edit.
Disable the default Start URLs initially configured by the basic profile.
Select (check) the following rule and click Disable and click Yes to confirm.
^[^?]+[.](html?|shtml|js|gif|jpg|jpeg|png|swf|pif|pdf|css|csv)
$
Select (check) the following rule and click Disable and click Yes to confirm.
^[^?]+[.](cgi|aspx?|jsp|php|pl)([?].*)?$
The following rules (4) will remain enabled. Notice that these rules only allow access to the basic
AFWeb content:
Basic AFWeb FQDN
^http://afweb[.]training[.]lab/$
Basic AFWeb VIP
^http://172\.21\.10\.111/$
Content with the .ico extension
^[^?]+[.]ico$
The allow.demo page
/allow[.]demo$
NOTE: The two default Start URLs broadly allow a wide-range of content and therefore should never
be used when URL Closure is enabled. As a best practice, the default URLs should be removed from
an existing profile when enabling URL Closure or start with a new Advanced profile instead. However,
for lab purposes the rules will be disabled, instead of deleted, to allow students the opportunity to
review or restore previous settings after this exercise.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This ensures
any session cookies are also cleared.
81
9. Test how the current Start URLs with URL Closure works with the AFWeb page.
Use the following procedure to test AFWeb and generate learned data for additional Start URL
requirements.
In Firefox browse to http://afweb.training.lab/. Notice not all graphics are returned.
10. Switch to Putty (1) window displaying the syslog (/var/log/ns.log) output:
Click on the following links to navigate to the site, return to http://afweb.training.lab after each test.
It is important that you browse the site from the pages listed and do not manually navigate the site
by manually entering the URLs:
Allow Demo.
Deny Demo.
SQL Injection Demo.
Enter test in the lookup value field and click Submit to navigate to /sql.asp.
Form Field Demo.
Select Standard Checking in account type drop-down list and click Submit.
Select Standard Checking in account type again and click Submit on the /field.asp page.
URL Closure Demo > Closure2 Demo > Private2 Demo.
The current Start URL list does not completely allow access to all required elements of AFWeb, after
the initial test case. Learning will be used to update the required rules. Learning will identify
violations not covered by the current URL Closure rules.
12. Return to the NetScaler configuration utility in Chrome and connect to the NSIP:
http://192.168.10.101.
13. View the learned rules in the Application Firewall profile for AFWeb:
Click Learned Rules under Advanced Settings.
Select (check) Start URL under Learned Rules and click Edit.
View the additional rules identified by Learning with URL Closure enabled:
Four of the rules are dependencies on jpg or png in the /images directory. (You may have
more objects, if additional pages were tested.)
One of the rules identifies the attempt to direct browse to /private.htm.
82
14. Use the Learning Visualizer to view the learned rules and deploy settings:
Select (check) Start URL under Learned Rules.
Click Visualizer.
Use the visualizer to generate a consolidated regular expression and deploy the custom rule to the
Start URL list:
Click on the images/ node in the visualizer graphic:
Verify a consolidated rule similar to the following is displayed in the Selected Rule field. This
rule should allow content from the images/ directory only. (There may be slight variations to
the expression if you tested more links.) Final output should be similar to:
http:\/\/afweb\.training\.lab\/images\/[\.ad-jl-u]{7,13}
Click Deploy to deploy the rule as is to the Start URL list and click Yes to confirm.
83
18. Clear all session state in Firefox before continuing:
Make sure the Firefox window has focus, then enter CTRL+SHIFT+DEL. Alternate method:
click History > Clear Recent History.
Ensure Everything is selected in the Time Range to Clear box and Cookies are included in the
Details.
Click Clear Now.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This ensures
any session cookies are also cleared.
Re-open Firefox. Do not browse to http://afweb.training.lab yet.
19. Demonstrate how URL Closure plus the initial Start URLs successfully allow access to the linked parts
of the site:
Switch to Firefox, browse to http://afweb.training.lab. URL succeeds.
Test the following demonstration links from the default page and confirm the results. Return to the
http://afweb.trainign.lab between tests.
Allow Demo: Link takes you to the /allow.demo page. Link is allowed due to previous Start
URL configuration.
Deny Demo: Link is still blocked due to the previous Deny URL configuration.
URL Closure Demo: Link takes you to /closure1.htm.
Closure2 Demo: Link takes you to /closure2.htm.
Private2 Demo: Link takes you to /private2.htm.
All three links are allowed as the URLs conform to the normal Start URL patterns currently
configured.
Manually browse to the following URL paths and confirm the results:
Manually browse to http://afweb.training.lab/private.htm. This is denied due to URL
Closure.
Manually browse to http://afweb.training.lab/private2.htm: This is allowed since you had
previously been allowed to navigate via the URL Closure Demo links.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This ensures
any session cookies are also cleared.
Re-open Firefox. Do not browse to http://afweb.training.lab yet.
84
21. Attempt to direct browse to the /private2.htm without going to the default page first:
For each of the following tests, type in the URL manually.
All three URLs are blocked as you did not start at a designated Start URL first.
NOTE: If you are watching the violations in syslog (Putty (1)), these will appear as Start URL violations
in syslog.
Use the navigation links to access the specified URLs. Return to the (/) between each test case:
SQL Injection Demo. This loads the /sql.htm page.
Enter test in the Lookup Value field and click Submit. The /sql.asp page displays successfully.
Form Field Demo. This load the /field.htm page.
Click Submit. The /field.asp page displays successfully.
URL Closure Demo > Closure2 Demo > Private2 Demo. This /private2.htm page displays
successfully and is not blocked if access from an allowed Start URL and links covered by URL
Closure. Attempts to direct browse to /private2.htm will fail, if not covered by closure.
NOTE: If you are watching the violations in syslog (Putty (1)), no additional violations should occur
for navigating these links as these pages were covered by URL Closure.
Takeaways:
URL Closure changes the function of Start URLs from a whitelist function to a list of allowed entry points
for the site. Navigation is only allowed via identified entry points or links supplied to users during requests
to an allowed entry point. URL Closure allows users to successfully navigate to all links provided from
entry point URLs and sites descended from these allowed entry points.
The default URLs included in the basic profile should not be used with URL Closure enabled.
URL Closure can be used to selectively block content based on context. If users navigate to authorized
Start URLs, URL Closure will allow navigation to dependent links. However, attempts to directly browse to
sites not covered by URL Closure will be denied.
The NetScaler learning engine learns violations and is therefore dependent on the security state's
configuration for what will be identified.
o It is recommended that minimal initial configurations are made prior to enabling Learning.
o For example, enable URL Closure and at a minimum the root web site URL to provide minimum
required access before performing Learning.
During learning phases, security checks can be set to disable blocking so the Application Firewall functions
in observation mode.
85
Exercise 4-11: CSRF Form Tagging / Referer Header Validation
In this exercise, you will use Start URLs with URL Closure and Referer header validation to prevent a type of CSRF
attack.
Scenario:
The WebGoat application has a newly discovered vulnerability that could allow a CSRF attack from a remote site, if
URLs are called with manipulated query parameters.
To protect against this attack from a remote website, URL Closure with Referer header validation will be enabled
for WebGoat.
However, due to the way that WebGoat constructs legitimate site URLs, the Application Profile for WebGoat will
have to have Form Field Consistency checks disabled, in order to demonstrate the specific attack and protection in
mind. Under normal operations, Referer header validation and Form Field Consistency checks should remain
enabled to provide a range of protections.
During the attack, the goal is to get a remote site (AFWeb) to issue a custom URL to WebGoat that will result in the
transfer of secure funds. This will require that URL Closure is properly configured for WebGoat, Form Tagging is
enabled, and Referer header validation is enabled.
First, this exercise will demonstrate the attack from a rogue server (AFWeb) against WebGoat while no
application firewall protections are enabled.
Next, the WebGoat Application Firewall profile will be updated so that URL Closure is enabled. Learning
will also be enabled to quickly update the required Start URLs with additional patterns. At the end of this
task, verify the following:
o Ensure that the Start URLs with URL Closure are properly configured to allow successful
navigation of WebGoat's regular pages.
o Disable Form Field Consistency, to prevent conflicts with regular site navigation and the CSRF
attack demonstration.
Then, repeat the CSRF attack with URL Closure enabled (but no Referer Header Validation protection).
This will show the difference in URL Closure protection vs. Referer Header Validation.
Finally, demonstrate the attack prevention using Referer Header validation on WebGoat.
In this exercise, you will perform the following tasks:
86
2. Open Firefox and browse to http://webgoat.training.lab/WebGoat/attack.
Log on as guest / guest, if prompted.
Click Start WebGoat, if required.
The objective of this attack is to get a URL to submit data to this page and include the
"transferfunds=4000" as an additional query parameter. For our lab exercise, we are going to
initiate the attack against WebGoat from AFWeb.
Take note of the WebGoat URL that corresponds to the CSRF attack page. Due to the way
WebGoat works, the Screen query parameter will vary per student. Take note of the Screen
value in the URL for your instance of WebGoat. Copy the URL to notepad or write it down.
http://webgoat.training.lab/WebGoat/attack?Screen=XXXX
&menu=900
Screen ID:______________________________
NOTE: The WebGoat load balancing virtual server is using a 24-hour long persistence value.
However, if you repeat the test multiple times or reset Firefox, the URL query parameter
changes. If you are having issues with this exercise, return to this page in WebGoat and confirm
the parameter value before performing the attack.
Enter the following text in the Custom Message field (or copy and paste from within the page):
<a href="http://webgoat.training.lab/WebGoat/attack?
Screen=XXXX&menu900&transferFunds=4000">Safe to Click</a>
Replace the XXXX with the correct set of numbers for your instance of WebGoat.
Click Submit.
5. Click on the link Safe to Click.
This will result in the malicious link navigating to WebGoat's CSRF demonstration page. WebGoat
then confirms that you have successfully completed the electronic funds transfer:
87
6. In WebGoat, Reset the lesson state before continuing:
Navigate to Cross-Site Scripting (XSS) > Cross Site Request Forgery (CSRF) and click
Restart this Lesson. (You must re-navigate to the page for this to work.)
Verify the lesson state reverts and the green checkbox next to the lesson name in the
navigation pane is gone.
2. Return to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
3. Disable the App Firewall policy on AFWeb (temporarily):
Navigate to Security > Application Firewall > Policies > Firewall.
Select (check) appfw_pol_afweb and click Edit.
Change the expression from true to false.
Click OK to close the policy.
NOTE: This is being done to temporarily disable AFWeb from protection with Application
Firewall and URL Closure, without unbinding policies or changing the last state configured. The
Application Firewall protections will be restored after this exercise.
For this exercise, AFWeb is acting as a rogue website and is being used to attack WebGoat.
88
7. Disable Form Field Consistency Protection:
Disable (uncheck) Block, Log, and Stats next to Form Field Consistency check in the
Security Checks summary view.
Click OK under Security Checks to apply settings.
NOTE: Due to some of the dynamic page IDs and handling of query parameters in WebGoat, the
Form Field Consistency check would prevent part of the CSRF attack demonstration and prevent
the demonstration of Referer Header validation. The Form Field Consistency check will be
disabled for this exercise.
Disable the default Start URLs initially configured by the basic profile.
Select (check) the following rule and click Disable and Yes to Confirm
^[^?]+[.](html?|shtml|js|gif|jpg|jpeg|png|swf|pif|pdf|css|c
sv)$
Select (check) the following rule and click Disable and Yes to Confirm.
^[^?]+[.](cgi|aspx?|jsp|php|pl)([?].*)?$
The following rules (2) will remain enabled. Notice that these rules only allow access to the basic
WebGoat content:
Basic WebGoat FQDN:
^http://webgoat[.]training[.]lab/WebGoat/attack([?].*)?$
WebGoat favicon:
/favicon[.]ico$
89
9. Switch to Firefox and test WebGoat. Learning will be used to help identify any additional
WebGoat URLs required with the current URL Closure configuration.
Use the WebGoat navigation pane and access the following pages:
Navigate to Introduction.
Navigate to General > HTTP Basics.
Navigate to Parameter Tampering > Exploit Hidden Fields.
Navigate to Injection Flaws > String SQL Injection.
Navigate to Cross-Site Scripting (XSS) > Cross Site Request Forgery (CSRF).
Take note of the value of the Screen=XXXX parameter while here.
Screen ID:______________________________
This should generate enough learning data to identify additional Start URL requirements for use
with URL Closure.
Review the learned rules and confirm that all of the objects are .jpg or .gif images located under
the /images/buttons/ directory, the images/headers/ directory or the /images/menu_images/
directory. Therefore, all of this content is safe to allow.
90
12. View the rules in the Visualizer:
Select (check) Start URL under Learned Rules and click Visualizer.
Use the visualizer to consolidate and deploy three rules for the buttons/ directory, the header/
directory, and the menu_image directory:
Click on the buttons/ node and view the consolidated rule. Click Deploy and click Yes.
Click on the header/ node and view the rule. Click Deploy and click Yes.
Click on the remaining node http://web[1] which represents the menu_image/ node
and view the rule. Click Deploy and click Yes..
NOTE: The exact visualization of the learned rules and expression deployed may vary from the
image in this lab guide, depending on the exact test procedure followed.
Click Close.
91
1. Clear all session state in Firefox before continuing:
Make sure the Firefox window has focus, then enter CTRL+SHIFT+DEL. Alternate
method: click History > Clear Recent History.
Ensure Everything is selected in the Time Range to Clear box and Cookies are included
in the Details.
Click Clear Now.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
Re-open Firefox.
2. Open a new tab in Firefox (Tab 1), browse to the CSRF page in WebGoat and verify the current
Screen parameter:
Browse to http://webgoat.training.lab/WebGoat/attack:
o Enter credentials guest / guest.
o Click Start WebGoat.
Navigate to Cross-Site Scripting (XSS) > Cross Site Request Forgery (CSRF).
Take note of the current value assigned to the Screen parameter in the URL:
http://webgoat.training.lab/WebGoat/attack?
Screen=XXXX&menu900
Copy the URL to Notepad or write down the value for Screen.
Screen ID:______________________________
This value may have changed from the previous test, if you reset Firefox.
o Open a second Tab (Tab 2) in Firefox, browse to the CSRF Attack page in AFWeb:
Browse to http://afweb.training.lab/.
Click on the CSRF Demo.
92
4. Return to the AFWeb tab (Tab 2), in Firefox and perform the CSRF attack:
Enter the HREF sample into the custom message field.
<a href="http://webgoat.training.lab/WebGoat/attack?
Screen=XXXX&menu900&transferFunds=4000">Safe to Click</a>
Replace XXXX with the current value for the WebGoat CSRF attack page screen value.
Click Submit.
Click Safe to Click.
Explanation: The attack was not blocked by the Application Firewall. The URL Closure ensured
that WebGoat was navigable and all required content loaded. Attacks that result in direct
browsing to hidden links will fail. However, the CSRF attack originates from a different website,
and URL Closure alone doesn't prevent this attack.
Result: The Referer header confirms that the request to the WebGoat page originated from a
remote server at http://afweb.training.lab/csrf.php.
93
CSRF 4: Test Referer Header Validation Protection to Prevent the CSRF Attack
Step Action
1. Clear all session state in Firefox before continuing:
Make sure the Firefox window has focus, then enter CTRL+SHIFT+DEL. Alternate
method: click History > Clear Recent History.
Ensure Everything is selected in the Time Range to Clear box and Cookies are included
in the Details.
Click Clear Now.
IMPORTANT:
Close all instances of Firefox, then re-open a new window, before continuing. This
ensures any session cookies are also cleared.
Re-open Firefox. Do not browse to WebGoat or AFWeb yet.
2. You should be able to repeat the test with the current setup.
If you reset Firefox between attempts, then the Screen ID may change again.
The initial steps will reconfirm the setup before performing the attack.
Screen ID:______________________________
94
4. Switch to Tab 2 in Firefox which is already on AFWeb's CSRF demo page (/csrf.htm).
Result: This time the attack is blocked by Application Firewall and the WebGoat blocked page is
displayed.
5. Switch to the Putty (1) window displaying the syslog (/var/log/ns.log) output:
NOTE: If the AFWeb URL is added to the WebGoat Start URL list, then this referral would be
valid.
Takeaways:
CSRF Form Tagging and Referer Header Validation protection are two types of CSRF attack preventions.
o CSRF Form Tagging is slightly more CPU intensive than Referer Header validation.
o CSRF Form Tagging and Referer Header validation requires that Form Tagging is enabled at the
profile settings.
o With CSRF, each response sent to users is tagged with a custom Form ID. Any request submitted
to the NetScaler, must contain a valid Form ID or it will be in violation.
Both CSRF Form Tagging and Referer Header validation depends on the Start URLs being properly
configured. Do not enable either security check until Start URLs (with or without Closure) is configured for
regular site navigation.
95
Referer Header validation requires that requests to a protected Website must originate from a source
covered by the Start URLs or otherwise covered by URL Closure.
CSRF Form Tagging automatically identifies a violation if an action URL is triggered from an origin URL in a
different Domain than the action URL (example.com vs. example.net).
96
Module 5: Application Firewall Logs and
Troubleshooting
Overview:
In this module, you will perform hands-on exercises using Application Firewall violations in syslog to aid in
troubleshooting. This module will examine creating custom error pages that integrate Application Firewall log
details and viewing Security Insight AppFlow data within NetScaler Insight Center.
View Application Firewall events in syslog and identify the violation that has occurred (based on Module 4
exercises).
Use Application Firewall events in syslog to update the Application Firewall based on Module 4 exercises.
Create a custom error page for import onto the NetScaler that includes Application Firewall log event details.
Integrate Security Insight reporting and interpret the Security Insight Dashboard reports in NetScaler Insight
Center.
This module contains the following exercises using the NetScaler Configuration Utility GUI:
97
Exercise 5-1: Custom Application Firewall Error Page
In this exercise, you will import a custom error page for Application Firewall violations that will include Application
Firewall log information such as Transaction ID, Application Firewall Session ID, and violation details. The error
page is useful for detailed debugging and demonstrates how certain parameters can be retrieved from the
NetScaler using variables in the page content.
This information may be useful for providing debug information when users report blocked content. Care should
be exercised in its use as the page in its current form clearly identifies the presence of NetScaler Application
Firewall in use within the environment. Page content may be appropriate for use by internal users during initial
acceptance testing while adjusting the Application Firewall configuration. The page may require modifications to
obscure references to the NetScaler Application Firewall prior to being used in production.
Import a custom error page from an existing file that contains variables to report Application Firewall
violation details.
Configure the custom import as a "block" page for violations within an Application Firewall profile.
For reference, the custom HTML Page consists of the following code:
<html>
<head>
<title>Application Firewall Block Page</title>
</head>
<body>
<h1><B>Your request has been blocked by a security
policy<B><BR></H1>
<H3>Access has been blocked - if you feel this is in error,
please contact the site administrators quoting the following
details: </H3>
<UL>
<li>NS Transaction ID: ${NS_TRANSACTION_ID}
<li>AppFW Session ID: ${NS_APPFW_SESSION_ID}
<li>Violation Category:
${NS_APPFW_VIOLATION_CATEGORY}
<li>Violation Details: ${NS_APPFW_VIOLATION_LOG}
</UL>
</body>
</html>
98
IMPORTANT: This page content is useful when used as an application firewall blocked page
during limited types of controlled User Acceptance Testing (UAT). It advertises a lot of sensitive
information about the Application Firewall, violations, and security settings. This level of
information means it is not appropriate as a production blocked page that any malicious user
could see.
Do not use this type of page content as a blocked page for a production Application Firewall
profile.
2. Return to the NetScaler configuration utility and connect to the NSIP: http://192.168.10.101.
Click Continue.
Click Done to close the HTML Error Page Import Object screen.
NOTE:
The file contents can be edited on the NetScaler after import.
Imported files are located in: /var/download/.
This file will display the Application Firewall violation details found in syslog including
the NetScaler Transaction ID, Session ID, Violation Category, and Violation Log message.
Click OK.
6. Switch to Firefox:
Browse to http://webgoat.training.lab/WebGoat/attack.
Navigate to Parameter Tampering > Bypass HTML Field Restrictions.
99
7. Use Web Developer Extension to perform the attack in WebGoat:
Click Tools > Web Developer Extension > Forms > Display Form Details.
Delete contents of field as_fid. (This violates the form field consistency validation.)
Click Submit.
9. Compare the error page results with the violation in the Putty (1) session displaying syslog
output.
Confirm that Syslog displays the same information present in the custom error page:
NetScaler Transaction ID
AppFW Session ID
Violation Category
Violation Details
Takeaways:
On block violations, the Application Firewall can redirect users to the default page ("/"), another server
hosting a dedicated error page, or custom content can be uploaded or generated on the NetScaler and
delivered from itself.
Custom error pages can integrate NetScaler variables which allows displaying event ID's and other
descriptive information in the error page. This information can be useful for debugging.
For test purposes, it can be useful to confirm when an Application Firewall violation occurred and the
details of that violation. In production, usually it is better to provide an event ID that can be tracked by
support teams, but no overt information regarding the security violation prevented or the mechanism
used to provide the protection. Be cautious when constructing error pages for production use so that you
are not providing information on how to circumvent required security.
100
Exercise 5-2: NetScaler Insight Center: Security Insight
In this exercise, you will enable Security Insight with NetScaler Insight Center and review the logging information
available in Security Insight dashboard.
NetScaler Insight Center integration with the NetScaler was initially configured in Module 2. During this exercise,
the final integration will be configured to enable Security Insight data reporting. Once reporting is enabled,
additional application attacks will be performed to generate new Application Firewall violation data. The Security
Insight data for AFWeb and WebGoat will be reviewed.
The lab will show the basic interactions with the Security Insight dashboard. Students may explore Security Insight
data in more detail.
Click OK.
Note:
For reference, the command line equivalent for the above parameters are:
set appflow param -SecurityInsightTraffic ENABLED
set appflow param -SecurityInsightRecordInterval 60
The NetScaler Insight Center "enable Security Insight" wizard does not enable the above
settings. Security Insight AppFlow reporting is not enabled until the "Security Insight Traffic"
parameter is enabled.
101
4. Generate Application Firewall violations for AFWeb:
6. Switch to Chrome and open a new tab for NetScaler Insight Center:
Browse to http://192.168.10.13.
Log on as nsroot / nsroot.
102
7. View the Security Insight Dashboard:
Click Dashboard tab.
Navigate to Security Insight.
Click Get Started.
It may take a few minutes before data for both applications have been reported. Times will vary,
but it may take up to 10 minutes before data is displayed. Try repeating the attack in steps 4-5 if
data still hasn't populated.
103
9. Review the Application Summary:
GeoIP reporting is not enabled, so the geographical origins of the attacks are not being
reported (and is being affected by the lab IP scheme, as well.)
Notice that in the Summary pane, the following areas are clickable and can be used to
drill-down into the attacks:
o Total Violations
o Violations by Severity
o Violations by Action
o Violations by Category
The following areas allow you to switch between Threats (views of attacks) vs. Safety
(profile configuration/protections applied).
o Threat Index
o Safety Index
The lower half of the chart, displays the breakdown of the current view. Clicking on an
attack violation type, displays the attacks reported for that violation.
104
Note:
NetScaler Security Insight only retains minutely data for 2 hours.
Hourly data persists for 1 Day.
Daily data persists for 31 Days.
105
11. Review the Application Firewall Profile sumamry for lb_vsrv_afweb:
Details Protections and configured actions.
Alternate method, use the CLI in Putty (2) to disable Security Insight Traffic:
Run the following command in the NetScaler CLI:
set appflow param -SecurityInsightTraffic DISABLED
14. Switch to Putty (2) and disable the Application Firewall feature using the NetScaler CLI:
Run the following command to disable Application Firewall:
disable ns feature appfw
NOTE: Feature is being disabled to prevent interference with later exercises. Policies are still in
place, if students want to revisit Application Firewall testing later.
15. Save the NetScaler configuration.
Takeaways:
Security Insight uses AppFlow to report Application Firewall violations and statistics to NetScaler Insight
Center. It includes reporting for Application Firewall security check violations, signature violations, and IP
Reputation.
106
The NetScaler Insight Center summarizes violation events and provides an assessment/summary of each
integrated applications, threat index and safety index. Threat Index is affected by the number of and type
of observed attacks. The safety index is affected by the comprehensiveness of settings integrated and can
be used to identify additional security protections that can be applied.
107
Module 6: Advanced Security and Filtering
Overview:
In this module, you will perform hands-on exercises that will demonstrate other security and traffic filtering
capabilities on the NetScaler that can be used in addition to the NetScaler Application Firewall features. These
features include HTTP Callouts, IP Rate Limiting, App QOE, and IP Reputation. HTTP Callouts, IP Rate Limiting, and
IP Reputation features can be used to define entities that can be incorporated into advanced policies for features
such as Responder and Application Firewall, as needed.
Configure an HTTP Callout expression that can be incorporated into an advanced policy feature, such as a
responder policy.
Configure an IP Rate Limit identifier and selector that can detect request rates per URL that exceed a
specific threshold.
Enable the NetScaler's built-in HTTP challenge-response capabilities and configure AppQOE policy
thresholds to trigger the validation process when traffic exceeds certain thresholds.
Enable IP Reputation and test traffic filtering using this service.
This module contains the following exercises using the NetScaler Configuration Utility GUI:
108
Exercise 6-1: HTTP Callouts
In this exercise, you will construct an HTTP Callout that can pass a client IP Address to a remote callout agent and
determine whether the traffic is or is not on the blacklist. The HTTP Callout will be incorporated into a Responder
policy to filter unwanted traffic.
Scenario:
As the administrator for the NetScaler, you were asked to integrate a traffic filtering mechanism that will allow the
NetScaler to compare IP Addresses of incoming traffic against the internally generated security blacklist.
The blacklist is being maintained on an existing system separate from the NetScaler. The internal blacklist system
maintains a database. The blacklist system already has a query mechanism configured via a web page that can be
used to retrieve the contents of the database or the web script can evaluate whether a given IP address is found in
the database.
The security team would like you to demonstrate the NetScaler filtering capabilities by incorporating a traffic filter
on the NetScaler that can compare traffic against the blacklist database and take an appropriate filter action. They
can then determine how to apply to a broader range of applications at a later point in time.
Construct an HTTP Callout that can pass an IP Address to the callout agent and identify if the IP Address is
or is not on the blacklist.
Use the HTTP Callout to trigger a responder policy to drop blacklisted IP Addresses.
Test the policy against the RBG load balancing virtual server.
At the end of the demonstration, the policy will be unbound.
Callout Details:
Entity Value
Callout Server IP (Backend) 192.168.30.79
Load Balancing vServer IP (lb_vsrv_callout) 172.21.10.119
Callout Script Path /cgi-bin/check_client.pl
View the HTTP Callout agent and identify how to pass and retrieve data from the agent.
Configure an HTTP Callout that identifies whether the Client IP Address is or is not on the blacklist by
evaluating the callout response
Configure HTTP Callouts with both a Boolean and Text-based return types to examine different ways an
HTTP Callout can be used to process data.
Configure a responder policy to drop unwanted traffic based on the HTTP Callout evaluation.
109
Configure HTTP Callouts for IP Blacklist Evaluation
Step Action
1. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
Prior to creating the callout and the responder policy to filter traffic, any request can successfully
reach the RBG virtual server.
110
6. Create a load balancing virtual server for the callout server:
Navigate to Traffic Management > Load Balancing > Virtual Servers.
Click Add.
Enter lb_vsrv_callout in the Name field.
Verify Protocol is set to HTTP.
Enter 172.21.10.119 in the IP Address field.
Verify Port is set to 80.
Click OK.
NOTE: The callout virtual server (lb_vsrv_callout) may initially appear as DOWN after creation.
The in-page refresh should result in it displaying in an UP state.
This particular callout generates two types of output. The first just returns the complete IP
Address blacklist table, which could allow the NetScaler to evaluate the blacklist itself. The
second type of output results when the remote Callout server evaluates the IP Address and
determines if the request is or isn't in the blacklist. In this case, the callout returns the phrase IP
Failed or IP Matched.
9. Test the HTTP Callout agent manually with an IP Address in the blacklist:
In a new tab (Tab 2), open Live HTTP Headers in Firefox:
Click Tools > Live HTTP Headers.
o If it was already open, click Clear to clear the existing output.
Switch to Tab 1, manually browse to the URL:
http://172.21.10.119/cgi-bin/check_client.pl?cip=192.168.10.10.
Switch to the Live HTTP Headers tab (Tab 2) and view the GET request associated with this URL
and the response headers it generates.
10. Test the HTTP Callout agent manually with an IP Address not in the blacklist:
Switch to Tab 1, manually browse to the URL:
http://172.21.10.119/cgi-bin/check_client.pl?cip=12.178.35.10.
111
12. Create an HTTP Callout to the check_client.pl script.
Navigate to AppExpert > HTTP Callouts.
Click Add.
Enter hc_blacklist in the Name field.
Define settings for the callout destination under the Server to receive callout request section:
Select Virtual Server.
Select lb_vsrv_callout under the Virtual Server drop-down list.
13. Define the HTTP Callout web request settings under the Request to send to the server section:
Select Attribute-based under Request Type.
Select Get under Method.
Enter "172.21.10.119" in the Host Expression field. (Quotes required where included.)
Enter "/cgi-bin/check_client.pl" in the URL Stem Expression.
NOTE: These parameters define the HTTP request to generate when performing the Callout. The
scheme (HTTP or HTTPS) needs to correspond with the destination callout protocol, whether it is
a LB virtual server or a direct IP destination. If the virtual server is SSL, be sure the scheme is
specified as HTTPS.
14. Define the HTTP Callout web response settings under the Server Response section:
Select BOOL under Return Type.
Enter the following expression in the Expression field to extract data from the response
body (or use the Expression Editor to build the expression):
HTTP.RES.BODY(1000).CONTAINS("IP Matched")
Click Create.
NOTE: This particular callout evaluates whether the remote agent determined if the IP address
was or wasn't on the blacklist and outputs a Boolean result TRUE or FALSE. Comparison is case-
sensitive.
112
15. Create a second HTTP Callout with slightly modified settings, based on the existing callout:
Select (check) hc_blacklist in the HTTP Callouts list and click Add. This will create a
duplicate callout based on the existing settings.
Enter hc_blacklist2 in the Name field.
Scroll down to the Server Response section.
Select Text under Return Type.
Enter the following expression in the Expression to extract data from the response field:
HTTP.RES.BODY(1000)
Click Create.
NOTE: This callout returns the list of IPs from the callout server, allowing the NetScaler itself to
evaluate if an IP Address is or isn't on the blacklist at the time the callout is used. This particular
callout could be cached, as the blacklist is unlikely to change frequently.
This example is used to demonstrate how the response expression and the callout data type are
related.
Click Create.
113
17. Create a second responder policy, using the alternate Callout (hc_blacklist2):
Deselect (Uncheck) rs_pol_drop_bycallout.
Click Add (to add a new, blank callout).
Enter rs_pol_drop_bycallout2 in the Name field.
Select Drop under Action.
Enter the following expression in the Expression field or use the Expression Editor:
SYS.HTTP_CALLOUT(hc_blacklist2).CONTAINS("IP Matched")
Click Create.
This policy demonstrates how to create an expression that evaluates the results of the Callout
when the callout returns a text-based output.
18. Bind the responder policy to the RBG virtual server, and verify traffic is blocked:
Click Done.
114
22. Switch to Firefox and browse to http://rbg.training.lab/home.php.
Verify the content is permitted.
NOTE:
If a callout destination server or virtual server is inaccessible the Callout is down and is
not invoked. The policy referencing the callout receives an automatic false, which
usually means the policy does not apply.
When configuring HTTP Callouts, use virtual servers and be sure to include backup
virtual servers to ensure continued availability of the HTTP Callout function.
23. Unbind the policy from lb_vsrv_rbg to avoid conflicts with later exercises:
Click Done.
Takeaways:
HTTP Callouts can be used to make HTTP or HTTPS requests against a remote agent and retrieve and parse
the web response.
While HTTP Callouts are often associated with filtering traffic as part of Responder or Application Firewall
policies, HTTP Callouts can be used with other default policy engine features, including Rewrite and token-
based load balancing.
The HTTP Callout consists of three types of settings: the traffic destination by IP Address or virtual server,
the HTTP Request, and the output to evaluate in the HTTP Response. How the HTTP response is processed
determines the output return type of the HTTP Callout.
If the destination for the HTTP Callouts is down, the HTTP Callout does not get invoked and returns an
automatic "False" value. This could apply whether the callout points to a direct IP Address destination or a
virtual server. In most cases, this will result in the policy where the Callout is referenced not being
triggered. In most situations, it is therefore recommended to point the HTTP Callout to a load balancing
virtual server with multiple bound services or a backup entity specified to avoid a single point of failure.
115
Exercise 6-2: IP Rate Limiting
In this exercise, you will create an IP Rate Limit that will trigger a high threshold based on a request rate per URL.
The IP Rate Limit will be incorporated into a Responder policy that will redirect traffic to an error page for requests
that exceed the limit threshold.
Scenario:
After the HTTP Callout demonstration, one of the security administrators wants to examine other ways of
selectively filtering unwanted traffic based on request rates. The security administrator wants you to limit the
number of requests per second that can be sent to a given application and wants the requests limit to be tracked
per URL.
For demonstration purposes, the request rate threshold will be set artificially low.
Configure a rate limit that will track requests per URL with a threshold of 5 requests per 10 second
interval.
Upon violation of the request rate, use a responder policy to present a custom error message indicating
the request rate as the issue.
Test the rate limit condition using the WebGoat load balancing virtual server, while Application Firewall is
disabled.
At the end of the exercise, the policy will be unbound.
In this exercise, you will perform the following tasks:
Create a Limit Selector and Limit Identifier with the thresholds specified.
Import an HTML page for use with responder.
Configure the IP Rate Limit to trigger a responder redirect policy.
IP Rate Limit
Step Action
1. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
Click Create.
116
3. Create a Rate Limit Identifier that places a limit on the request rate observed per URL.
Navigate to AppExpert > Rate Limiting > Limit Identifiers.
Click Add.
Click Create.
NOTE: Responder policy imports are separate from Application Firewall imports as far as object
types go.
Responder imports are managed in the GUI under AppExpert > Responder > HTML Page
Imports and in the CLI as "[show | import] responder htmlpage".
Application Firewall imports are managed in the GUI under Security > Application
Firewall > Imports and in the CLI as "[show | import] appfw htmlerrorpage".
All imports for both features are stored /var/download/.
Click Create.
117
6. Create a Responder Policy that is triggered by exceeding the rate limit:
Navigate to AppExpert > Responder > Policies.
Click Add.
Enter rs_pol_respondwith_err_reqrate in the Name field.
Select rs_act_respondwith_err_reqrate in the Action field.
Enter the following expression in the Expression field. Use the inline editor or the
expression editor to construct the expression.
http.req.url.contains("/WebGoat/") &&
SYS.CHECK_LIMIT("limit_highreqrate_byurl")
Click Create.
NOTE: Quotes are required around the limit identifier name in the SYS.CHECK_LIMIT() operator.
NetScaler 11.0 omitted these quotes when using the Expression Editor. NetScaler 11.1 includes
them when using the Expression Editor. However the inline editor does not include them. You
will receive a syntax error if the quotes are omitted.
Click Done.
NOTE: The page will generate errors before the action is applied due to the low threshold
specified and the number of requests in the initial page load.
118
10. View the policy hits and stats for the Rate Limit Identifier:
11. Switch to Firefox and refresh the page one or twice (not enough to exceed the threshold):
http://webgoat.training.lab/WebGoat/attack.
119
Takeaways:
The Rate Limiting feature is another protection feature of the NetScaler that can be incorporated into
default-policy engine features, like Responder, Application Firewall, DNS, rewrite, and Integrated Caching.
The feature is useful when filtering unwanted traffic exceeding certain connection, request rate, or
bandwidth thresholds during high-volume traffic events associated with an attack.
Selectors are optional filters that can be incorporated with Rate Limit Identifiers. The Selectors provide a
filter that can be used to categorize traffic. The Limit Identifier is then used to specify the threshold of
interest per category of traffic identified by the selector.
The Limit Identifier returns true when the threshold is exceeded. This allows the Limit Identifier to trigger
the required action in the policy it is associated with. Rate Limiting is usually used to drop, reset, or
redirect high threshold traffic exceeding the limit identifier.
120
Exercise 6-3: App QOE
In this exercise, you will configure an AppQOE policy to trigger a user request validation in the form of an HTTP
challenge response to identify legitimate traffic under high traffic load conditions.
AppQOE integrates multiple policy-based security features into one integrated feature. This feature provides an
updated mechanism for managing protections previously handled by Priority Queuing, HTTP Denial of Service
protection, and SureConnect. AppQOE also integrates a fair queuing system that works at the virtual server level
instead of at the service level, allowing traffic handling to occur prior to load balancing instead of afterwards. This
exercise will demonstrate denial of service protection using the NetScaler's built-in challenge response/Captcha
feature.
Scenario:
The security team has, once again, asked you to assist them with a problem. The security team has asked you to
help them simulate a high traffic load condition to see how the App QOE feature can be used to protect a specific
application with an integrated Captcha response. To simulate high volume traffic a load generation script will be
used.
Configure AppQOE parameters and policy to protect the RBG web application.
Unbind the policy at the end of the demonstration.
Configure App QOE for DOS Protection with NetScaler Integrated CAPTCHA
Step Action
1. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
121
3. Configure AppQoE Parameters:
Navigate to AppExpert > AppQoE.
Click Configure AppQoE Parameters in the right-pane.
Click OK.
NOTE: These thresholds are being set low for demonstration purposes in the lab environment.
These thresholds may not be suitable for production traffic volumes and may result in
premature AppQOE impacts on legitimate traffic volumes.
Click Create.
122
6. Bind the AppQoE policy to the RBG load balancing virtual server:
Navigate to Traffic Management > Load Balancing > Virtual Servers.
Select lb_vsrv_rbg and click Edit.
NOTE:
This command is available from BSD shell only.
The nsapimgr commands applied at shell are not retained after a reboot, as these are
applied to RAM but not part of the running config and they are not preserved in the
save config.
To make nsapimgr commands persistent, they must be added to the
/nsconfig/rc.netscaler file (See next step).
123
8. OPTIONAL: Append nsapimgr command to rc.netscaler file (to preserve between reboots)
View the contents of the directory and verify rc.netscaler file is present:
ls
Some existing commands are present, therefore any additional commands need to be appended
to the file. Run the following command to preserve the nsapimgr settings and append the new
command to the end of the file:
echo "nsapimgr -ys appqos_captcha=1" >> rc.netscaler
For Reference, the final file should contain the following lines:
/bin/sh /etc/ntpd_ctl full_start
nsapimgr -ys appqos_captcha=1 >> rc.netscaler
124
11. ABOUT Running the PYTHON script to generate load.
==============================================================================
DO NOT direct the script to ANY OTHER WEBSITE than the test site in the lab environment.
DO NOT attempt to use the script on ANY public website.
==============================================================================
IMPORTANT: The Python script that is used to generate load DOES NOT stop running, even after
sending the usual CTRL+C command. As a result, we will run two elevated CMD prompts side-by-
side. One will be used to execute the script, the other will be used to terminate the Python
engine. In this way, you can start and stop the script as needed.
A text file with both commands is located in C:\resources\hulk_commands.txt, so you can copy-
and-paste the commands to the appropriate CMD prompts.
Prepare to run the script by setting up the following commands. Do not run the scripts yet.
During the test, keep both CMD prompts running with access to the commands during the next
several steps and you can start/restart the Python script and terminate the process as needed.
When the test is done, remember the following:
If you have issues terminating the script, use task manager to terminate any running
python processes.
Be sure the hulk.py process is stopped before continuing after this exercise.
125
13. Perform the load generation with AppQOE test:
In CMD Prompt (1), start the hulk.py command:
c:\hulk.py http://rbg.training.lab/home.php
Switch to Firefox and refresh http://rbg.training.lab/home.php a few times.
Wait for the Captcha prompt to be generated on the NetScaler.
Complete the Captcha response and confirm you are directed successfully to the page
content.
o In a few cases, you will not receive the RBG content as the server is under
extreme load. If it does not redirect after a few seconds of completing the
captcha, stop the load script anyway.
When you are done with testing, stop the hulk.py Python script from running:
In CMD Prompt (2), stop the Python engine:
taskkill /im Python.exe /F
Verify the hulk.py output terminated in CMD Prompt (1).
Click OK.
Takeaways:
AppQOE integrates multiple policy-based security features into one integrated feature. This feature
provides an updated mechanism for managing protections previously handled by Priority Queuing, HTTP
Denial of Service protection, and SureConnect.
AppQOE can provide traffic prioritization and queuing functions. AppQOE policies can be used to identify
traffic and prioritize traffic into higher priority queues or lower priority queues.
126
Exercise 6-4: IP Reputation
In this exercise, you will enable IP Reputation for traffic filtering based on the IP Reputation database of malicious
addresses maintained by WebRoot. IP Reputation reports on IP Addresses and provides additional metadata
regarding the threat category of the IP Address.
Once enabled, the NetScaler downloads the database from WebRoot. Data is checked for updates once every five
minutes. Delta changes will be downloaded when updates are available.
IP Reputation expressions can then be incorporated into Application Firewall, Responder, and other advanced
policy engine features to trigger drop/reset or other filter actions. Traffic can then be identified as malicious if it
falls into any identified threat category in the IP Reputation database or the traffic can be filtered if it belongs to a
specific threat category (Spam, Botnets, Scanners, or other…).
IP Reputation can be used in place of an internally maintained blacklist or in conjunction with internally maintained
whitelist and blacklist systems.
Scenario:
After the HTTP Callout demonstration, the security administrator was curious about integrating IP Reputation
checks from the WebRoot service with the NetScaler traffic filtering capabilities. At the moment, the security
administrator just wants to see how to enable IP Reputation and incorporate the IP Reputation check into the
NetScaler for traffic filtering purposes in place of the previous HTTP Callout blacklist example. The security
administrator will look at whether to combine the solutions later.
Enable IP Reputation on the NetScaler and verify IP Reputation initialization in the IPrep log.
Construct an Application Firewall block policy that will drop traffic that fails an IP Reputation check and
bind the policy so that IP Reputation traffic is dropped prior to full Application Firewall protections are
processed.
127
Configure IP Reputation
Step Action
1. Connect to the NetScaler configuration utility for NS_VPX_01 using the NSIP at
http://192.168.10.101.
NOTE: It will take up to 5 minutes before IP Reputation has connected to the BrightCloud service
and downloaded the database.
128
4. From the NetScaler CLI, verify the NetScaler can ping the WebRoot BrightCloud IP Reputation
service:
Ping the BrightCloud service to verify name resolution:
ping api.bcss.brightcloud.com
NOTE: The ping will not return an ICMP response, but it will confirm if the NetScaler
can resolve the name to an IP Address.
Enter CTRL+C to stop the ping attempt.
NOTE: In the lab environment we are using a wildcard certificate so we can resolve
api.bcss.brightcloud.com correctly however, if you need to setup a proxy for IP reputation you
must Connect Method and use ping api.bcti.brightcloud.com (which is the correct
FQDN). Currently even citrix documentation state the incorrect information.
ls
Run the following command to view the IPReputation log output as it occurs:
tail -f /var/log/iprep.log
129
5. Import a custom Error Page for traffic blocked by IP Reputation failures:
Navigate to Security > Application Firewall > Imports.
Click Add.
Enter ErrorIPReputation in the Name field.
Select File under Import From.
Click Choose File.
Browse to C:\Resources\ and select ErrorIPReputation.html and click Open.
Click Continue.
Click Done.
7. Create an Application Firewall Policy that can block traffic based on IP Reputation:
Navigate to Security > Application Firewall > Policies > Firewall.
Click Add.
Enter appfw_pol_ipreputation in the Name field.
Select APPFW_BLOCK from the Profile drop-down list.
Configure the Expression to evaluate the IP Reputation. Use the inline editor or the
Expression Editor to build the expression:
CLIENT.IP.SRC.IPREP_IS_MALICIOUS
Click Create.
If retrieving the Source IP from a Layer 7 header (like x-forwarded-for), then the IP Address can
be retrieved from the header and typecast to an IP Address, such as:
http.REQ.HEADER("x-forwarded-for").TYPECAST_IP_ADDRESS_T.IPREP_IS_MALICIOUS
130
8. Bind the policy to the AFWeb load balancing virtual server (at a higher priority than the previous
Application Firewall policy).
9. Open Firefox:
Browse to http://afweb.training.lab/.
Verify the content is not blocked as your student desktop should not be on any IP
Reputation blacklists.
12. Change the policy to temporarily treat your Student Desktop as a malicious IP address:
Select appfw_pol_ipreputation and click Edit.
Update the expression to trigger if your source IP is NOT malicious. Include the
negation operator (!). Enter the following expression:
!CLIENT.IP.SRC.IPREP_IS_MALICIOUS
Click OK.
NOTE: The IP Reputation Error page is being used for demonstration purposes. Normally, traffic
failing an IP Reputation test would be dropped using the APPFW_DROP profile.
131
16. Restore the policy to expression to the regular state:
Select (check) appfw_pol_ipreputation and click Edit.
Update the expression to its normal state: Enter the following expression:
CLIENT.IP.SRC.IPREP_IS_MALICIOUS
Click OK.
Takeaways:
IP Reputation allows the NetScaler to download a list of malicious IP addresses and their threat
categorization from list maintained by WebRoot.
Once enabled, the NetScaler checks for and downloads updates to the database every 5 minutes.
The NetScaler can then compare source and destination IP Addresses in traffic flows against the database
using the IPrep_IS_Malicious and IPrep_threat_category expression operators. These operator can
identify traffic and be used to trigger policy feature actions to drop or filter the unwanted to traffic.
132
133
Appendix A: Transition from the CNS-318 to CNS-319
Overview:
These steps allow students completing the Part 1 content (CNS-318, Mon-Wed) to transition to the starting state
required for Part 2(CNS-319, Thu-Fri).
2. Run the following commands to set the config for the new start state:
Restore the dependent files for the configuration from part 1(signatures, imports, and SSL certs):
batch -filename
/var/labstuff/restore/restorefiles_part1end.bat
Restore the dependent files for the configuration (signatures, imports, and SSL certs):
batch -filename
/var/labstuff/restore/restorefiles_part2start.bat
NOTE: This configuration keeps all of the load balancing virtual servers and policies from part 1,
with the exception of AppFlow integration with Insight has been removed. The AppQoE and IP
Reputation features are disabled and their policies are no longer bound to the associated virtual
servers. AppFw feature is disabled, but the policies are still bound to the WebGoat and AFWeb
virtual servers, for later demonstrations.
The transition scripts add an SSL certkey pointing to an expired certificate for *.training.lab. The
SSL certkey is in use by two additional lb vservers for WebGoat and AFWeb on SSL and 443.
134
4. Verify the configuration with the following commands:
show lb vserver -summary
Alternate command:
show lb vserver -summary -fullvalues
Verify all the following load balancing virtual servers are present.
lb_vsrv_rbg
lb_vsrv_afweb
lb_vsrv_webgoat
lb_vsrv_callout (will be listed as down)
lb_vsrv_afweb_ssl (NEW)
lb_vsrv_webgoat_ssl (NEW)
Note: If dependencies referenced in the configuration such as Signatures or imported pages are
not present on the NetScaler, the depdendent objects such as policy actions or profiles will be
missing. Repeat step 2 and run all three scripts to fix the issue and reboot.
Verify the three custom responder policies are included in the summary list:
rs_pol_drop_bycallout
rs_pol_drop_bycallout2
rs_pol_respondwith_err_reqrate
Verify the one custom responder action is included in the summary list:
rs_act_respondwith_err_reqrate
135
11. Open XenCenter and connect to your assigned XenServer:
Use XenCenter shortcut on Desktop.
Shutdown NetScaler Insight Center VM and start NetScaler MAS Virtual Appliance:
Right-click NS_InsightCenter in left pane and click Shutdown.
Right-click MAS Virtual Appliance in left pane and click Start, if not running.
136
Appendix: Challenge Question Answers
Overview:
This section presents a deeper examination and explanation of some of the decisions made when configuring the
Application Firewall Profiles and Start URLs in Exercise 4.1.
Why were AFWeb's and WebGoat's base URLs initially blocked by the default URLs in the basic application firewall
profile?
Rule 1: ^[^?]+[.](html?|shtml|js|gif|jpg|jpeg|png|swf|pif|pdf|css|csv)$
Rule 2: ^[^?]+[.](cgi|aspx?|jsp|php|pl)([?].*)?$
And the base URLs referred to are:
For AFWeb: The base URL for AFWeb terminates in "/" and does not conform to the extensions expected in Rule 1
(basic web content) or the script extensions with or without query strings in Rule 2 (script/query content).
Attempts to connect to http://afweb.training.lab/index.htm would succeed with the default URLs.
For WebGoat: The base URL for WebGoat terminates without an extension at all, using /WebGoat/attack.
Otherwise, basically the same issue as with AFWeb in that the URL structure does not conform to expected web
content or script formats.
Question 2
When updating the AFWeb profile to allow the base URL path ("/") to be allowed, why was the following URL used:
^http://afweb[.]training[.]lab/$
As opposed to, this one:
^http://afweb[.]training[.]lab/
At this point, the profile is still in "basic" mode and relying on the default Start URLs (without URL Closure).
Answer 2:
This was the narrowest URL that would allow successful navigation to the default path ("/") without automatically
granting access to all other content. This ensured unexpected content, like the /allow.demo page or even the .ico
files would not be permitted without additional Start URLs to permit access. Content not allowed, would continue
to be denied, even if deny URLs hadn't been created yet.
137
Question 3
For WebGoat: The base URL for WebGoat was added to the Start URL list, and while this allowed navigation to the
default page to succeed, all other navigational links failed.
Why was this addition of the base URL not enough? Especially, if WebGoat navigates using query string
parameters.
At this point in the configuration, the following Start URLs are in effect:
Rule 1: ^[^?]+[.](html?|shtml|js|gif|jpg|jpeg|png|swf|pif|pdf|css|csv)$
Rule 2: ^[^?]+[.](cgi|aspx?|jsp|php|pl)([?].*)?$
Rule 3: ^http://webgoat[.]training[.]lab/WebGoat/attack$
Example URLS for WebGoat navigation include:
http://webgoat.training.lab/WebGoat/attack?Screen=XXXXX&Menu=YYYY
http://webgoat.training.lab/WebGoat/attack?Screen=XXXXX&Menu=YYYY&otherparams=othervalues
Answer 3:
Even though the WebGoat URL contains query strings, because the URL does not include a standard script
extension for cgi/asp/php or other, the URL query strings used for navigation do not confirm to the script/query
string content defined in Rule 2. While the custom Rule 3 allowed initial access to WebGoat, all other navigation
links failed.
Rule 3 was then replaced with a pattern that allowed content to /WebGoat/attack and borrowed the query
portion of the pattern from Rule 2. The updated regular expression deployed for lab purposes allowed the
inclusion of any parameter string name-value pair, and not just the use of Screen and Menu pairs. If additional
attack content hadn't need to be supported, an alternate URL to limit the types of query parameters allowed might
have been used instead.
138
139