Lab Guide Web Application and API Security
Lab Guide Web Application and API Security
Lab Guide
FFT-WEB-r04-1746804374
Table of contents
1. Web application and API Security ............................................................................................. 4
1.1. FastTrack Program ............................................................................................................ 5
1.2. Agenda ................................................................................................................................ 6
1.3. Topology .............................................................................................................................. 7
2. Initial Configuration ..................................................................................................................... 8
2.1. Perform Initial Configuration ........................................................................................... 9
2.2. Verify Network Communications ................................................................................... 11
2.3. Create a Signature .......................................................................................................... 13
2.4. Create a Web Protection Profile .................................................................................... 14
2.5. Configure Server Policy .................................................................................................. 16
3. Configure Local/Remote Logging & Sensitive Data Masking .............................................. 17
3.1. Initialization ...................................................................................................................... 18
3.2. Configure Local Logging ................................................................................................. 19
3.3. Test Local Logging .......................................................................................................... 21
3.4. Secure Local Logging by Masking Sensitive Data ...................................................... 23
3.5. Test Sensitive Data Masking ......................................................................................... 25
3.6. FortiAnalyzer Logging ..................................................................................................... 26
4. Credential stuffing, User Tracking and Authentication ....................................................... 28
4.1. Initialization ...................................................................................................................... 29
4.2. Credential Stuffing .......................................................................................................... 30
4.3. Test Credential Stuffing Defense .................................................................................. 33
4.4. Enable User Tracking ...................................................................................................... 34
4.5. Test User Tracking ........................................................................................................... 36
4.6. Enable HTTP Authentication .......................................................................................... 37
4.7. Test HTTP Authentication .............................................................................................. 42
5. Implement Certificates and Encryption .................................................................................. 43
5.1. Initialization ...................................................................................................................... 44
5.2. Uploading a Server Certificate and Private Key ......................................................... 45
5.3. Implementing HTTPS Offloading ................................................................................... 48
5.4. Rewriting and Redirecting HTTP to HTTPS .................................................................. 50
6. Protect Against Zero-Day Attacks Using Machine Learning ............................................... 51
6.1. Initialization ...................................................................................................................... 52
6.2. Configuring Machine Learning Anomaly Detection .................................................... 53
6.3. Establishing The Model ................................................................................................... 57
6.4. Protecting and Adapting ................................................................................................ 60
7. Known Bot Mitigation ................................................................................................................ 62
7.1. Initialization ...................................................................................................................... 63
7.2. Known Bot Test ................................................................................................................ 64
7.3. Known Bot Protection ..................................................................................................... 65
7.4. Test Known Bot Protection. ........................................................................................... 66
8. Injection ....................................................................................................................................... 67
8.1. Initialization ...................................................................................................................... 68
8.2. SQLi Attack and FortiWeb Protection .......................................................................... 69
8.3. XSS Attack and FortiWeb Protection ............................................................................ 72
9. Securing Your Cookie ................................................................................................................ 75
9.1. Initialization ...................................................................................................................... 76
In this hands-on workshop, you explore the features and capabilities that FortiWeb offers to help you protect your web
application, achieve PCI DSS compliance, and OWASP Top10 mitigation within your network.
• Local logging, sensitive data masking, and FortiAnalyzer remote logging (optional)
• Injection (optional)
Many of these activities can be done as independent tasks. The duration of this workshop is insufficient for you to complete
all of the above activities, so you should focus on those topics that are of the greatest interest to you. If time remains, you
may also have the opportunity to attempt others.
Tasks
The blue button at the top of this page is the primary action button. When an action can be completed on the page, this
button will change accordingly.
When ready, click the blue Continue button in the menu at the top of the page to get started.
FAST TRACKS are free instructor-led hands-on workshops that introduce Fortinet solutions for securing your digital
infrastructure. These workshops are only an introduction to what Fortinet security solutions can do for your organization.
For more in-depth training, we encourage you to investigate our full portfolio of NSE training courses at
https://training.fortinet.com.
Agenda
This lab consists of two sections: core and optional. You must complete all exercises in the core section before the optional
section becomes available.
Core
Optional
Tasks
Topology
Below is the topology you use in the exercises to demonstrate FortiWeb functionality. It includes FortiWeb in the DMZ, as
well as a web server in a data center. Traffic flow is from the Kali Linux to the FortiWeb, to the web server, and back.
The FortiGate-Edge device is configured with a Virtual IP of 100.65.0.124 on the Internet-facing port, which is then mapped
to the FortiWeb’s Port 2 address of 172.16.99.124
Tasks
This will be the last time we specifically state to click on the Continue button, from now on it is assumed that the user
understands how to move forward.
The first step in using FortiWeb to help achieve application protection is to deploy your FortiWeb device and perform some
basic configuration.
For this Fast Track, your FortiWeb has already been configured for management access via the GUI. You must still configure
the basic elements of the configuration to allow FortiWeb to communicate with, and protect, your web application.
After you defined the basic connectivity between your FortiWeb and the back-end web application. To protect the web
application, you create a protection profile, which you assign to the server policy. FortiWeb requires three basic elements: a
signature (or rule), a profile, and a policy.
You should always begin by building the signature first, then the profile, and then link them together in the policy.
Objectives
Time to Complete:
Estimated: 15 minutes
Background
When configuring FortiWeb, there are several linked elements that you must configure in a specific order. The basic
sequence is to build a rule, link the rule to a profile, and then link the profile to a policy. The policy governs all aspects of
traffic flow between FortiWeb and the web application/server.
In this exercise, you create a Server Policy to protect the Web Application. To create the Server Policy, you first need to
create two Server objects: a virtual server, which represents the service IP address that the clients will be connecting to, and
a server pool, which represents the IP address of the actual web server that FortiWeb protects.
Tasks
1. From the Lab Activity: FortiWeb sidebar menu, access FortiWeb using the HTTPS option.
4. Edit vServer_ACMECORP
8. Click Ok
2. Edit ServerPool_ACMECORP
6. Click OK
Background
Now that you have configured a server policy, your clients should be able to connect to the back-end web application. In this
exercise, you will verify that the Kali Linux client can reach the ACMECORP website.
Before you configure any of FortiWeb’s protection features, you should make sure you can connect to the Web Application
via FortiWeb working in reverse proxy mode with the Server Policy that you just created.
Tasks
1. From the Lab Activity: FortiWeb sidebar menu, access Kali using the RDP option.
2. Click Start.
NOTE: If you are not able to access the login page, check your configuration before continuing.
Question
Which of the FortiWeb configuration element identifies the IP Address that clients will use to access your web application?
Virtual server
Server policy
Background
While FortiWeb has predefined signatures for many common web applications, such as Drupal and WordPress, you cannot
directly modify these for use with custom applications, such as ones built in-house by your business unit or IT department.
To protect those custom applications, you need to create a custom signature. There are three ways you can accomplish this:
Find a prebuilt signature that is close to your needs, clone it, and modify it
Tasks
3. Set the Name to signature1 and leave all other settings at the default value.
4. Click OK.
Background
In this exercise, you create a web protection profile that will utilize the signature you created in the previous activity.
Inline protection profiles combine previously configured rules, profiles, and policies into a comprehensive set that can be
applied by a policy. Inline protection profiles contain only the features that are supported in inline topologies, which you use
with operation modes such as Reverse Proxy and True Transparent Proxy.
Tasks
4. Verify that Client Management is on. This adds a cookie to the reply for FortiWeb to track the state of web applications
across multiple requests
6. In the IP Protection section, ensure IP Reputation is turned on. This ensures that FortiWeb uses a blacklist, supplied by
FortiGuard, to protect your network from known malicious source IP addresses.
7. Click OK.
Background
Now that you have created a signature, and linked it to a protection profile, you need to assign it to the server policy. This is
how you define what protections and rules FortiWeb will apply to each server pool.
In this exercise, you modify the server policy that you created during the initial setup.
Tasks
2. Click ServerPolicy_ACMECORP.
3. Click Edit.
4. In the Security Configuration section, use the Web Protection Profile drop-down list to select protection1.
5. Click Ok.
In this lab, you configure local logging on the FortiWeb and secure stored data with sensitive data masking.
Both logging and sensitive data masking are key requirements for PCI DSS compliance. Logging is considered critical for
forensic purposes in the event of a breach, and masking of sensitive data is critical to reduce the risk of this data being seen
or used by unauthorized individuals.
External logging to something like a FortiAnalyzer or FortiSIEM is strongly recommended and part of the OWASP Top 10
requirement, you will go through FortiAnalyzer integration with FortiWeb, viewing FortiWeb reports and logs on
FortiAnalyzer.
Objectives
• FortiAnalyzer logging
Time to Complete:
Estimated: 20 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
In this exercise, you will configure and implement local logging. You will then generate traffic and attacks to generate log
entries. Lastly, you will review and verify the collected log data.
For this exercise, you will utilize some settings that are not typically recommended for day-to-day use in a live deployment.
These settings would generate an excessive volume of log data, resulting in increased disk usage, and CPU cycles. These
settings are being used here for demonstration purposes only
Before you configure FortiWeb to send logs to centralized storage, enable local logging and verify that expected events are
being recorded.
Tasks
1. On FortiWeb, Click Log&Report > Log Config > Global Log Settings.
2. Verify that the Disk is turned on and the Log Level is set to Information.
3. Click Apply.
FortiWeb(ServerPolicy_A~M)# end
FortiWeb(traffic-log)# end
Tasks
1. Click Log&Report > Log Access > Event. You can view many events, such as:
Login attempts
Periods when the web servers are unreachable by the server health monitors
Attempts to connect through the virtual server, in the traffic log, even if the attempt was blocked. In cases where the
attempt was blocked, there will be a request, but no corresponding response from the server.
6. Locate the log entry for the credit card transaction. It should be the topmost entry and list post in the Method column.
In the Raw Body section, you can see the full details of the credit card data entry, including name, card number, and so
on. Storing cardholder data in this manner, even in the local logs, is a direct breach of PCI DSS requirements.
Background
One of the many PCI DSS compliance requirements is the masking of sensitive data stored in logs. As you saw in the
previous activity, by default, FortiWeb local logs store data in plain text.
FortiWeb provides predefined rules that can be applied in most cases, however, in some cases, you may need to use custom
rules. Since the web application used in this lab is a custom application, built in-house, the sensitive fields do not necessarily
follow the conventions expected by the prebuilt rules. As a result, you will build a few custom rules to mask credit card
numbers and CVV values.
Tasks
6. Set the Field Name to number. This must match the field value name in the web application. This identifies which field
the rule applies to, in this case, the actual card number.
\d indicates that the rule should replace a numerical digit, and {16} indicates that it should replace 16 consecutive digits
(the normal length of most credit card numbers).
12. Set the Field Name to cvv. This rule applies to the card verification value number.
\d indicates that the rule should replace a numerical digit, and {3} indicates that it should replace 3 consecutive digits
(normal length of Card Verification Value numbers)
14. Click Ok
17. Locate the traffic log from the previous credit card activity. Double-click the log entry to access the details
18. In the Raw Body section, you can still see the full details of the credit card data entry, because sensitive data logging
rules do not apply retroactively. Only new log entries will be masked by the new rules.
Tasks
1. On Kali, launch Mozilla Firefox, and click the Credit Card Input browser bookmark.
4. In the Raw Body section, both the number field and the cvv field are masked.
Background
It’s important to have data logging on local storage as well as sending data to remote storage as recommended by the
OWASP Top10. In the lab, you will be viewing the FortiWeb integration with FAZ, and viewing the logs and weekly reports on
FAZ.
Tasks
1. On FortiWeb, click Log&Report > Log Access > Attack to view attack logs.
6. Click Log&Report > Log Config > Global Log Settings to view settings.
1. From the Lab Activity: FortiWeb sidebar menu, access FortiAnalyzer using the HTTPS option using the following
credentials
Username: admin Password: Fortinet1!
3. Search for Fortiweb using the search on the top right corner, then select FortiWeb Default Report.
7. Click on the Reports in the top left corner and browse to Log View
8. Expand the FortiWeb tab to view different logs (Attack, Event, and Traffic)
In this lab, you use FortiWeb advanced protection to track users connecting to a website, enable credential stuffing defense
and enforce authentication to specific hostnames. Before you provide a login form to users, it is a best practice to:
• Apply SSL/TLS to encrypt the channel when usernames and passwords are transmitted
Objectives
Time to Complete:
Estimated: 25 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
Attackers have easy access to millions of unique compromised user credentials stolen from multiple breaches. Hackers can
re-use these passwords to infiltrate other user accounts with the same username/password combinations.
Fortinet’s Credential Stuffing Defense identifies login attempts using credentials that have been compromised, using an
always up-to-date feed of stolen credentials. Administrators can configure their supported devices to take various actions if a
suspicious login is used including logging, alerts, and blocking. In this lab, you use FortiWeb advanced protection to track
users connecting to a website and block stolen credential access.
Tasks
In this exercise, you will log in to the DVWA website using stolen credentials before applying FortiWeb credential defense.
1. On FortiWeb click Tracking > User Tracking > User Tracking Rule.
Name: tracking-rule-ACMECORP
Severity: High
3. Click Ok
6. Click OK.
4. Click OK
Tasks
1. On Kali open Firefox and click the DVWA browser bookmark. Use the following credentials to sign in:
1. On FortiWeb, click Log&Report > Log Access > Attack and review the most recent entry.
Question
FortiGuard Database
Background
In this exercise, you enable user tracking on FortiWeb. This allows you to track sessions by user and to capture a username
to reference in log messages. This information gives you more granular control over access to web resources, as well as
improving post-attack forensic analysis.
Tasks
1. On Fortiweb. Click Tracking > User Tracking > User Tracking Rule.
Timeout: 1
3. Click Ok
Value: /index.php
3. Click OK.
# edit tracking-rule-ACMECORP
# end
Tasks
1. On Kali, using Mozilla Firefox, click the DVWA browser bookmark. Use the following credentials to sign in:
2. Click Command Injection and enter the following command: www.acmecorp.net;cd ../../;ls
4. Wait one minute without interacting with the website to allow the timeout period to pass.
1. On FortiWeb, click Log&Report > Log Access > Attack and review the most recent entries
2. Select the generated attack log. In Detailed Information, click More Details. Locate the Username field. It indicates
that the attack was generated by the admin.
Background
In this exercise, you apply HTTP authentication to protect defined websites using their hostnames. This supports PCI DSS
requirements by limiting access to resources for specific users and user groups.
Although many web applications may provide their authentication capabilities, using FortiWeb authentication ensures that
even web applications without native authentication capabilities are covered. It also allows for a single, centrally managed
user authentication mechanism, rather than managing each application separately.
An HTTP authentication policy can include many websites with common connection timeouts, session caches, and other
identical settings. During the testing phase of this lab, you view all authentication attempts, not just failures, so you will also
log successful attempts.
Tasks
5. Click OK.
13. Click Ok
Note: If this server hosts websites for many domains, including subdomains such as store.example.com, you should add
all the domain names as hosts.
3. Click OK.
8. Click OK.
Name: ACMECORP-realm
Host Status: On
Host: www.acmecorp.net
4. Click OK.
5. While still on the same page, click Create New to add a new authentication rule.
Auth Path: /
7. Click Ok
Name: HTTP-Auth-settings-ACMECORP
Turn on Cache
Cache Timeout: 15
Note: The configured cache timeout is set to 15 seconds in this exercise for testing purposes, so you do not have to
wait long for the authentication session to expire. In a production environment, you should set to cache timeout to 300
seconds or higher.
3. Click OK.
4. Click OK
Tasks
Note: You must wait 15 seconds between each test and then restart your browser.
2. Open a new tab and connect to the virtual server IP address: http://100.65.0.124/.
3. Open a new tab and visit http://www.acmecorp.net/. It prompts for authentication, as expected.
Question
Why did you not get a user authentication prompt when browsing to http://100.65.0.124/?
Only the domain name was specified in the host configuration of authentication rule
PCI DSS requirements state that you must encrypt all cardholder data across open, public networks. This is achieved by
using SLL/TLS-secured HTTP, otherwise known as HTTPS.
In this lab, you prepare FortiWeb to take on the SSL security functions offered by your website. You will upload the
certificates and keys to FortiWeb and then offload the SSL (HTTPS) functions to FortiWeb. This ensures that all connections
to your website are secured by FortiWeb already. In this way, you can use SSL from the client to FortiWeb.
Finally, you implement HTTPS redirection to ensure that all traffic between the client and the web server is secured.
Objectives
Redirect HTTP requests to secure HTTPS and configure clients to use HTTPS-only access for subsequent requests
Time to Complete:
Estimated: 25 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
In this exercise, you upload a preconfigured certificate and key to FortiWeb to use for HTTPS and SSL connections to your
website.
You also configure FortiWeb to offer HTTPS (performing the certificate and cryptographic operations) to clients for all
backend web servers.
Tasks
1. From the Lab Activity: FortiWeb sidebar menu, access Jumpbox using the RDP option.
2. Open the Mozilla Firefox browser and browse to the bookmarked FortiWeb page
3. Click Server Objects > Certificates > Local and click Import.
5. Click Upload to select the Certificate file and Key file. The files for both, server.crt and server.key, are located in the
Web Server-Certificate file on the Desktop. Password is Fortinet1!
6. Click Ok
2. Select Backup and Backup entire configuration. Leave all settings at default.
5. On Firefox, browse to the download arrow icon on the top right corner and browse to the download folder.
7. Create a second backup file, this time turning on Encryption and setting the Password to Fortinet1!
8. Click Backup.
10. In the download folder, extract both configurations from the downloaded ZIP files, right-click on each file, and click 7-zip
> Extract files, when extracting the encrypted file, you will need to use the password.
Note: if you try to extract encrypted file using extract all the extraction will be errored.
11. Open both configuration files in a text editor, such as Notepad++, and compare their contents.
Virtual IP addresses
Server certificate
Background
In this exercise, you configure FortiWeb to manage all of the HTTPS communications with your website rather than
depending on the web server itself. This is called HTTPS offloading.
With HTTPS offloading, FortiWeb handles all of the secure connections with the client, while the connection between
FortiWeb and the web application is left unsecured. This moves the workload of encrypting and unencrypting closer to the
client and off of the server, allowing the server to focus its resources on serving the web application.
Tasks
5. In the SSL Connection Settings section, set the SSL/TLS Encryption Level to High.
6. Click OK.
8. Click OK
2. The ACMECORP Billing Portal page opens. Note the padlock icon and https:// in the address bar.
Question
Secure access using HTTPS is now working. What do you think would happen if you were to attempt to visit the site using the
plain HTTP URL http://www.acmecorp.net ?
Request would successfully complete and the unsecured site would be shown.
Background
To ensure your website is as secure as possible, it should only use HTTPS. In this exercise, you configure FortiWeb to redirect
HTTP requests to HTTPS for all web requests so all clients are automatically directed to the secure, encrypted, protocol.
Tasks
2. Edit ServerPolicy_ACMECORP.
1. On Kali, open Mozilla Firefox and click on the AcmeCorp Login bookmark.
2. The ACMECORP Billing Portal page opens. Note the padlock icon and https:// in the address bar.
In this lab, you implement the FortiWeb machine learning anomaly detection feature. This feature will allow you to quickly
and easily provide a high level of protection for your web application.
You also use some penetration testing tools to test, observe, and review machine learning anomaly detection in action.
Objectives
Configure anomaly detection to observe the traffic of your web applications and anticipate security needs
Use penetration testing tools to teach anomaly detection of normal traffic patterns
Time to Complete:
Estimated: 45 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
In this exercise, you configure FortiWeb machine learning anomaly detection to more effectively protect your web
application.
Although the currently configured policy has protection enabled, the protection1 profile is configured in such a way that
FortiWeb only blocks known attacks, based on defined signatures.
By enhancing FortiWeb with machine learning anomaly detection, FortiWeb can block unknown, suspicious traffic for which
signatures do not yet exist. These are often referred to as zero-day attacks.
By default, when machine learning is in its collecting phase, FortiWeb will accept only 30 requests from the same IP. For
testing purposes, you configure the policy to accept unlimited samples from the same IP.
FortiWeb ML by default is set to receive HTTP requests containing the parameter/argument from a minimum number of 3 (ip-
expire-cnts) different source IP addresses within the given period of 4 hours (ip-expire-intval). In this Lab FortiWeb will
receive HTTP requests from one IP address, you will need to change ip-expiry-cnts to 1 later in this exercise to avoid having
the HMM learning stage showing Unconfirmed.
Machine learning anomaly detection is the last layer in the FortiWeb protections. It is applied after all other protection
features have already been applied, such as IP reputation, DoS protections, antivirus, signatures, and so on.
Tasks
3. In the Security Configuration section, set Web Protection Profile to <blank selection> as shown in the image below
to disable this profile.
Note: Web protection is disabled in this exercise for demonstration purposes only, to ensure that later results are
obtained using machine learning anomaly detection.
6. Expand the Machine Learning section, select Anomaly Detection, and click Create.
8. Click OK.
9. Icons appear under Machine Learning. The gear icon indicates that machine learning is turned on.
10. Click Ok
Note: In a production environment, you should use a higher threshold for the strictness level.
4. Click OK.
7. Click the Tree View tab. No data is shown because the web server is not currently receiving HTTP requests.
8. Click the Parameter View tab. No data is shown because the web server is not currently receiving HTTP requests.
1. Click the console icon ( ), in the upper right of the GUI, to connect to the CLI.
2. Click the detach icon ( ) to open the web console in a new browser tab.
edit 1
set sample-limit-by-ip 0
end
4. Type show waf machine-learning-policy and confirm that the settings you entered appear.
Background
Although FortiWeb is currently configured to perform machine learning anomaly detection, the device has not yet learned
anything about the normal traffic patterns for the network.
In this exercise, you send HTTP requests to the web application to see how machine learning works. You first teach FortiWeb
about normal traffic patterns and then you send abnormal traffic to see how anomaly detection protects your servers.
It can take a while for the collecting, building, testing, and running stages to complete, but clicking the refresh button, as
indicated below, allows you to see the percentage of the stage that is completed.
Tasks
1. On Kali. Click the terminal icon on the system bar (upper left corner of the screen).
2. Enter ./wfuzzscript.sh test1 5 and then press Enter. This script makes 2000 unique HTTP GET requests, looping
five times to give machine learning enough time to build a traffic model. The console shows the requests being sent to
FortiWeb.
3. Leave the script running and the Kali browser tab open.
7. Click the Parameter View tab. FortiWeb shows information about the productID parameter that was discovered from
monitoring the HTTP requests destined for the web application. Note that the HMM Learning Stage is Collecting.
9. Continue clicking refresh every 30 seconds to see the HMM Learning Stage change to Building.
10. Continue clicking refresh, every 30 seconds to see the HMM Learning Stage change to Running.
11. Return to the Kali browser tab and enter Ctrl + C in the terminal window to end the script.
1. On FortiWeb, click the Tree View tab. Expand URLs and click productlookup
2. View the parameters linked to productlookup, as well as what learning stage each parameter is in.
3. Click the Overview tab. The lower-right widget shows the machine-learning events.
4. Event logs show <ProductID> change from None to Collecting, Collecting to Building, Building to Running.
6. View the Distribution of Anomalies triggered by HMM table. It displays which samples were considered anomalies
when the HMM model was being built, as well as the sample length. In this example, there are no anomalies.
1. On Kali, open Mozilla Firefox and click the Product Lookup browser bookmark.
3. The site accepts the input on the Product Lookup page, and responds with a message indicating the product is not
found.
4. From the sidebar menu, access FortiWeb using the HTTPS option.
5. Click Log&Report > Log Access > Attack. There are no log entries.
Question
Why did FortiWeb not block the AAAAA input on the Product Lookup page?
Background
In this exercise, you use scripts to generate attacks against your protected web servers.
By reviewing log entries and threat models, you can see how FortiWeb protects your web applications.
You also change the format the web application uses for the product ID, to see how the machine learning model can learn
about, and automatically adjust to, changes to the web application.
Tasks
To generate an attack
2. Enter the following command to send malicious requests to the web application’s ProductID parameter:
./wfuzzscript.sh attacks 1
3. There is a 500 response code in the script's outputs, indicating that the attack was not allowed through to the destination.
2. Hover your mouse pointer over the header bar until the settings icon appears on the left side.
Question
When FortiWeb is scanning traffic for threats, at what point in the scan sequence is the machine learning applied?
Known Bots protects your websites, mobile applications, and APIs from malicious bots such as DoS, Spam, and Crawler,
etc, and known good bots such as known search engines without affecting the flow of critical traffic. In this section, you will
be testing Wotbox known bot using curl and enable known bot protection to deny the wotbox curl request.
Objectives
Time to Complete
Estimated: 15 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
In this lab you will use a known bot called Wotbox, you will run a curl command with the Wotbot user agent to get acme
corp's login webpage content.
Tasks
1. On the Kali machine, open the terminal from the left sidebar.
3. You will get the page content since known bot mitigation is not enabled yet.
Background
In this lab, you will be configuring Known Bot protection, applying it to the Bot Mitigation Policy, applying the policy to the
protection1 profile, and testing known bot protection.
Tasks
4. Click OK.
9. Click OK.
13. Click Ok
Tasks
2. The request will be blocked, and the output will be random characters.
3. On the FortiWeb click Log&Report > LogAccess > Attack to view the deny log.
As stated by OWASP Top 10 2021, injection slides down to the third position compared to OWASP Top 10 2017. 94% of the
applications were tested for some form of injection with a max incidence rate of 19%, an average incidence rate of 3%, and
274k occurrences.
As there are many Injection attacks, in this lab, you will perform injection attacks on the DVWA specifically SQLi and Cross
Site Scripting. Injection is listed as A03:2021-Injection under the OWASP Top 10 2021. After performing the attacks, you will
deploy a protection profile on the FortiWeb and test how FortiWeb protects against SQLi and XSS attacks.
Objectives
Time to Complete
Estimated: 30 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
An SQL injection attack is one of the most dangerous web application attacks listed in OWASP's top 10 A03:2021
vulnerabilities which mostly occur due to insufficient user input validation. It’s a technique where SQL code/statements are
inserted in the execution field to alter the database contents, dumping useful database contents to the hacker, causing
repudiation issues, spoofing identity, and much more.
In this exercise, you will perform an SQLi attack on DVWA and test the FortiWeb protection against SQLi.
Tasks
1. From the Lab Activity: FortiWeb sidebar menu, access Kali using the RDP option.
2. Open Mozilla Firefox and access the bookmarked page DVWA using the following credentials to sign in.
5. Click Submit. As you can see this site accepted the SQLi and displayed the user’s info.
1. From the Lab Activity: FortiWeb sidebar menu, access FortiWeb using the HTTPS option
4. Enable the SQL Injection Signature and make sure the Action is set to Alert&Deny.
5. Click OK
9. Click OK
15. Enter the User ID: %' or 0=0 union select null, user() # this is SQL Injection that displays database Users.
19. On FortiWeb browse to Log&Report > LogAccess > Attack to view the SQL Injection attack log. Please add the Main
Type and Sub Type columns back. You can double-click on that log for more details.
Background
An XSS attack occurs when an attacker uses a web application to send malicious code or a browser-side script, to a different
end user. The victim has no way of knowing that the script is malicious thus believing that it is from a trusted source. The
malicious script can access cookies, session tokens, or other sensitive information stored by the browser and used with the
site.
The bad news is XSS is widespread and can be very dangerous making it one of the OWASP Top 10 vulnerability A03:2021-
Injection. The good news is it can be easily prevented through proper sanitization of user inputs.
While the goal of an XSS attack is always to execute malicious JavaScript in the victim's browser, there are a few
fundamentally different ways of achieving that goal. XSS attacks are often divided into three types:
Persistent XSS, where the malicious string originates from the website's database.
Reflected XSS, where the malicious string originates from the victim's request. The website then includes this malicious
string in the response sent back to the user.
DOM-based XSS, where the vulnerability is in the client-side code rather than the server-side code. DOM-based XSS is a
variant of both persistent and reflected XSS. In a DOM-based XSS attack, the malicious string is not parsed by the victim's
browser until the website's legitimate JavaScript is executed.
Tasks
1. On the Kali machine, open Mozilla Firefox and access the browser bookmarked page DVWA.
4. Click Submit. As you can see the output indicates the website is vulnerable to XSS.
5. Click OK.
6. Close browser.
1. On the FortiWeb, click Web Protection > Known Attacks > Signatures
3. Enable the Cross Site Scripting Signature and make sure the Action is set to Alert&Deny
4. Click OK
8. Click OK
14. Enter in the What’s your name: “ <script> alert('this is xss') </script> “
18. On FortiWeb browse to Log&Report > LogAccess > Attack to view the Cross Site Scripting attack log. You can
double-click on that log for more details.
As stated by OWSAP Top 10, 90% of applications were tested for some form of misconfiguration, with an average incidence
rate of 4%, and over 208k occurrences of a Common Weakness Enumeration (CWE) in this risk category. Web application
misconfiguration can be for many reasons, defaults account and their passwords are enabled, and unchanged, unnecessary
features are enabled, and more.
This Lab will go through CWEs like the Sensitive Cookie in HTTPS session without secure attribute and HttpOnly flag and how
FortiWeb cookie security policy allows you to prevent cookie-based attacks.
Objectives
Time to Complete
Estimated: 30 minutes
Communications with the FortiWeb will be briefly interrupted while the restore process completes.
Background
Using the HttpOnly flag when generating a cookie helps mitigate the risk of a client-side script accessing the protected
cookie (if the browser supports it).
If the HttpOnly flag is included in the HTTP response header, the cookie cannot be accessed through a client-side script.
As a result, even if an XSS flaw exists and a user accidentally accesses a link that exploits this flaw, the browser will not
reveal the cookie to a third party.
The “HttpOnly” cookie attribute instructs web browsers not to allow scripts (e.g. JavaScript or VBscript) an ability to access
the cookies via the DOM document.cookie object. This session ID protection is mandatory to prevent session ID stealing
through XSS attacks.
This lab will go through the exercise where the attacker reveals the value of the cookie as the HttpOnly flag is not enabled
for the DVWA website and how FortiWeb prevents this by enforcing the HttpOnly using the Cookie Policy. The HttpOnly flag
tells the browser that the cookie can only be accessed through HTTP.
Tasks
1. From the Lab Activity: FortiWeb sidebar menu, access Kali using the RDP option.
2. Open Mozilla Firefox and access the bookmarked page DVWA using the following credentials to sign in:
3. On the top right corner click on Menu then click Web Developer.
5. You will see that table.header.cookies.isHttpOnly field is set to false for both PHPSESSID and security, if you click
on any of those you will see in the Data Section on far right HttpOnly:false, which means that the HttpOnly flag is off.
10. You will see that the browser revealed the PHPSESSID and security cookies values when subject to XSS because the
HttpOnly flag is misconfigured on the DVWA web server.
11. Click OK
13. From the Lab Activity: FortiWeb sidebar menu, access FortiWeb using the HTTPS option.
19. Click OK
Note: Just for the purpose of this exercise, the Signature in the protection profile is not set to any. To demonstrate XSS is
not being blocked.
Tasks
1. On the Kali machine, open Mozilla Firefox and browse to the DVWA booked marked page, click again on
XSS(Reflected), and enter in the What’s your name field:”<script> alert(document.cookie)</script>“.
2. You will notice that the browser did not reveal the cookie's value when subject to XSS and having the browser asked by
Java script to reveal the cookie value.
Note: make sure a new browser session is opened when doing step 24.
Background
A cookie is subject to vulnerability if the secure attribute is not set. If an attacker can intercept HTTP traffic using a man-in-
the-middle attack, they may be able to steal another user’s cookie and impersonate them.
Set your cookies to be secure, so they can only be sent over HTTPS. This will prevent all but the most sophisticated man-in-
the-middle-attacks, and prevent cookies from being observed by unauthorized parties due to the transmission of the cookie
in clear text.
In this exercise will demonstrate how FortiWeb sets secure attributes in the HTTP response using the cookie security policy.
Tasks
4. Click OK.
Note: make sure the browser is closed and a new browser session is opened in the next exercise.
Tasks
1. On the Kali machine, open the browser and access the bookmarked page DVWA.
2. On the top right corner, click on Menu, then click on Web Developer
4. As you can see cookie information (PHPSESSID and security) is not available when browsing the DVWA.
6. Click on Network
8. You can drag the Dev tap up higher to view more info, under the Request headers check the cookies sent by the
browser, you will notice PHPSESSID and Security were not sent.
9. Navigate to the Response headers to check the response from FortiWeb/DVWA, under both the security and
PHPSESSID cookie, the secure flag is present.
Question
secure attribute is enabled for cookies thus browser is not sending cookie using HTTP
After completing this Fast Track module, you should now understand how to:
Congratulations!! You have completed the Web Applications and API Security workshop.
For continued learning about this solution, please consider looking at the following Fortinet NSE training course:
https://training.fortinet.com/local/staticpage/view.php?page=library_fortiweb-administrator