Fortigate Firewall Security Pocket Guide
Fortigate Firewall Security Pocket Guide
Configuring A Sensor 32
Fine Tune Your IPS Settings 37
set fail-open 39
“set database” 39
“Set engine count” 40
Optimizing Your IPS 40
Web Filter 44
Override a category 52
Web Filter optimization 54
Application Control 66
The order of the operation is quite significant !!! 68
Anomalies 82
Quarantine attackers 87
Web Application Firewall 91
Explicit Proxy 105
Proxy Auto-Config 111
Block IP Domains 117
Final Words 129
In my first book “Fortigate Admin Pocket Guide” you have learned how to
configure your network interfaces, set up policy rules, and analyze logs
You have also learned how routing works, What are sessions on your fortigate
firewall, how to see and analyze them using the command line
In this book, we will learn security concepts through the security profiles. Each
security profile can be enabled on your policy according to your network needs
Flow-Based Inspection
Your Fortigate Firewall operates in 2 main inspection modes
● Flow-based
● Proxy-based
You can change the inspection mode on the policy page for each policy
let's assume that we have our host our fortigate. And there's the internet.
Whenever a host connects to a website or to any resource on the web fortigate
doesn't interfere with the three-way handshake. The TCP SYN, the TCP ACK,
and the TCP SYN-ACK go through our fortigate. And gets back to our host.
Fortigate only looks at the flow of packets, Packet after Packet. The same way
as we see packets on Wireshark or other tools.
Fortigate actually caches the packets, but it lets them move to the other side. It
doesn't buffer them and keeps them for internal scanning. It caches them and
when the last packet of a file is received, then your fortigate will buffer it. It will
not send it towards the destination until it finishes the scan.
Again, you can change the inspection mode on the policy page
Proxy-based inspection works by buffering the whole file before it is sent to the
host. Our host will have to wait for the inspection to end
When you use a proxy-based inspection, you will want to send packets to your
host, to make sure that the connection doesn’t time out
To do that, navigate to policy and objects---protocol options
There you will find different protocol options to play around with, one of them is
the comfort clients options
Enable it
Once done, your fortigate will send packets in an interval and amount, that you
will configure, so the other side host will not time out
A proxy-based mode is much more resource-intensive, But it gives you
better results in finding out viruses. So if you prefer performance versus security
then choose a flow-based mode that is suitable for most scenarios.
If you're not willing to sacrifice your security for anything, even performance, then
use the proxy-based mode.
Anti Virus
Anti-virus is a database of virus signatures that are used to identify virus
infections
during the scan, a virus must match a defined pattern called a signature
Signatures can be made of hashes, CRC, file attributes, binary values in different
areas of the file, encryption keys, parts of code, and more
You can use your AntiVirus Profile, in either Proxy or Flow-based mode. As
said Proxy is the most secure method but will consume more resources
Now the first thing that needs to be done is to choose your virus database, there
are actually several of them
If you write “set default-db” and press the TAB button, you will see, that you
can change between different databases
The Extreme database has ( as its name suggests ) the largest set of
signatures, new and legacy, the Extended includes more legacy signatures than
the Normal
Another option that you will want to make sure that it is enabled, is the Grayware
scan
One of the nicest features of your fortigateAntivirus profile is the content disarm.
It only works on a proxy-based mode. And what it does is actually stripping
content from office files and PDF files.
We have dozens or hundreds of files that are sent every day over the email,
which is the number one virus and malware attack surface.
Sometimes you want to block that content up until it is being scanned by a
FortiSandbox.
When setting up CDR, we can choose either to discard the embedded content or
to send it to a FortiSandbox if you have one or your license includes this
feature.
You can also choose which content to disarm and which not.
Let’s create a new profile, name it “disarm”
Save it
When you configure your IPS sensor, you configure it towards a specific target
either clients or servers, towards a specific operating system, either Mac Linux
windows
IPS Signatures
Signatures can be filtered based on
● Target type
● Operating system
● Protocol
● Applications
The best practice approach is to specify signatures based on your topology
Use signatures based on your operating system ( Mac, Linux, Windows ), your
targeted applications, or even for a specific set of protocols
Remember, your IPS is the most demanding resource of
your fortigate
The attack surface itself can come from botnets. It can come from IoT devices, it
can come from the cloud. Your IPS engine uses protocol decoders to look for
different patterns to look for mismatch in the protocols themselves.
Configuring A Sensor
let's create a new one. As said, we can choose between signatures and filter
which are actually adding up signatures that have common behavior. So we can
add signatures by their severity level, by the target they're after, by the protocol,
or maybe the applications that you're running on your servers.
We will create a profile that is targeting servers, the severity level is high.
The protocols that they're running are HTTP, HTTPS, and FTP, and the
operating system is Windows.
Those are the servers that we have in our organization, each signature has a
default action, but let's set them all to block.
So anyone would build any intrusion that is aiming servers, running FTP, HTTP
and HTTPS and Windows operating system, which have a severity level of high
and more will be blocked.
Now, we can also add up another criterion, which is applications, your
organization may run different applications by IBM, HP, Cisco, and more.
We will choose HP. So any application by HP that runs on your web server, will
be also included in that IPS sensor.
Now, we can set it up and apply our new sensor to our policy
Fine Tune Your IPS Settings
Whenever there is an issue with the IPS such as CPU spikes, or maybe your
fortigate gets into a conserve mode, you will need to analyze the issue
You can adjust your IPS settings by using the command line.
Let's open the CLI and write down
Using the “show full config” you will see all the different settings.
The settings that are the most relevant are:
set fail-open
By default, it is disabled, which actually means that if your IPS engine for any
reason, collapses due to resources, or buffer size, and so on, the traffic will be
dropped. If it is enabled, the traffic will still flow without inspection
“set database”
You actually have two databases the first one is Regular which includes all the
well-known and the latest anomalies and intrusions
The extended database includes all of that and the legacy ones, it is a bigger
database so performance can drop a bit.
Another setting that is important is the socket size. This socket size is actually
the buffer size. The default size differs between models. And you can set up an
integer between one mega and 64 mega.
There are several fortigate models. Most of them are from the high-end models
that actually support several IPS engines. So if your fortigate supports several
engines, you can set the count to more than one
Another setting is the “set-skype-client-public-IP-addr” is the place where you
set up your public IP addresses in your network that will receive Skype session
that will help you fortigate to identify Skype properly
But if you're disabling bypass,( your IPS still works and inspects traffic ) and
you're still having issues with the CPU. That means that you probably have an
issue with your IPS engine.
Option number 99 - turn on or turn off your IPS, you can do it using option 99
“Diag test application ipsmonitor 99”
And if you want to start your IPS engine, again, you can use option 99 that will
actually restart all your IPS engine operations.
Other commands to optimize your IPS operations are done in the global
configuration of your IPS
“config IPS global”
“set intelligent-mode”
One of the most important options that you can play around with is the intelligent
mode. Currently, it is by default enabled. The intelligent mode actually means
that your fortigate IPS engine will look at the session itself. It will not scan by
default every byte in this session, it will look and it will use heuristics and other
techniques to choose if to scan the whole session or to stop scanning the
session traffic upon recognizing that it is secure enough.
So be sure that you're using the intelligent mode that will actually
offload CPU resources memory resources from your fortigate
Web Filter
Probably one of the most used and popular security profiles, in
any scenario.
When you use a web filter, it actually comes to life after the following
steps:
Depending on your firmware, your fortigate will come with several pre-configured
profiles.
Web filter profile will work under both the proxy and the flow-based inspection
modes.
When you create a new profile, we will see that we have proxy only features.
Once you finished configuring your profile, you will use it and apply it to your
policy.
So let's move over to our profile. And let's create a new profile. And name it “test
profile”.
The first thing that you will see is the FortiGuard category based filter.
Each category can be enabled, and used with different actions - just right click on
the action and you will see a prompt of different Actions, that you can use
The Actions
Besides the allowed action, you will find the following actions:
Blocked - Traffic will be blocked
Monitored - allowing the users to go to the tree source, but your fortigate will log
any event
Warning - you can also use a warning page in specific intervals
Authenticate - allow different groups to use their credentials to get into that
resource.
Override a category
You can create different actions for different categories on your web filter.
But you can also override them for specific users.
So let's create a new security profile “block news”
And let's set up the action for new sites to block and then override it using our
web ratings override
We can override with specific groups, but this time we will do it generally
The idea is to choose a news web site such as cnn.com and to change its
category, instead of general interest --- news that is blocked now, to another
category that is allowed
Move to web rating overrides
Create a new override
And there just enter the URL that you want to exclude from the blocked category
and change its category and subcategory to an allowed one
Web Filter optimization
web filter seems to be the most used security profile on a fortigate firewall.
There are dozens of categories. each time your fortigate asks for different
categories rating, it saves the results in a cache.
This cache has a session Time To Live. If you want to make your fortigate
performance better, you will need to make that cache stay for a longer time. How
you do so using the command line.
So let's use the “config system fortiGuard”
And now let's set the web filter cache. First, we will make it enabled if it is for any
reason not enabled,
and then we will set the Cache Time To Live. to 4800 seconds. default is 3600.
So we are actually setting the cache for much longer.
Blocking Files
Another great feature of a web filter is its ability to block the download of files in
different file formats. This feature was once part of the DLP security profile, but
now it actually landed in the web filter part
Under scan archived contents, you will find the option to block files, just click on
the Create New
Name your filter
We will name it Block_pdf
Set your protocol options, either HTTP or FTP
And choose the file type, that you wish to block
Other Options
When you scroll to the bottom of the web filter security profile, you will see that
you have other very interesting options, some of them will require that you will
use the deep SSL inspection as in “Log al search keywords” where you can
actually see search phrases that are used by your employees on search engines
such as google
Another very important option that is used heavily is the URL filter, here you can
block, allow and monitor specific URLs. just enable it and you will have the option
to create a URL Filter
Create New
You can enter the URL as is, using the simple method, which is
quite simple, but you can also use regular expression and
wildcards for greater control
Wildcard
The wildcard is used to represent one or more characters. The most used
character is the asterisk (*), which actually means “everything “
The best way to explain wildcard is the following
We are asked to block the following sites :
www.example.com
www.photos.example.com
www.example.org
If we would do it using the simple method, we would need to create 3 URL filters
Another way which more practical is to use a wildcard in the following manner
By using an asterisk before example and after it, Everything will be
matched
Regular Expression
We need to match three domains and two top-level domains (TLD) in one regular
expression.
Let's open parentheses, and write down CNN and the or (|) sign.
Now let's write down Forbes and another or (|) sign, and Fox. Now let's close the
parentheses.
And now we only have the TLD. So we'll open new parentheses.
and We will write inside com or org and close the parentheses
There are 2 main places that you will want to make changes
● The categories - application categories
● The application and filter override
The order of the operation is quite significant !!!
The first thing that your fortigate scans are the application override where you
add up your own predefined signatures or filter signatures based on behavior,
protocol, popularity, application type, and more
Specific signatures
Common behavior signatures
Fortigate will start by scanning application override, it will see that the
Teamviewer is allowed, and then it will move to categories where remote apps
are blocked.
Doing so, Teamviewer will still work, while any other remote app will be
blocked
When the IPS engine finds a match to an application, it tells your fortigate that it
found an application ID number. Fortinet has a huge database of applications.
Each one has its own ID.
If you wish to see the different IDs for the different application, you use the CLI:
When you enable it, your users will get a block page that will include the following
information:
● The signature that detected the application
● The signatures category( remote access, peer to peer )
● The URL that was specifically blocked
● The client source - the IP address of the client
● The server's destination.
● Fortigate hostname and the UID of the policy that was governing the traffic.
Including Fortigate hostname is good in networks that have many fortigate
devices, you can look up at the hostname of the fortigate and tell which
fortigate actually blocked the traffic.
Application signatures
App signatures are organized by category, technology, and risk, they can be
viewed using the view signatures that is to the right of your app control page
Deep SSL Inspection
All cloud applications require you to enable deep SSL inspection on your policy in
order to recognize them. These apps can be recognized using the padlock icon
beside them, which means that their traffic is encrypted
Denial of Service
IPV4 policies are not the only policies that can be configured on Your Fortigate
firewall. One type of policy that you can configure is the DoS policy, where you
protect your network from anomalies
DoS
One of the key principles of the CIA triad model ( a theoretical model that
describes, 3 key components that must be kept to keep your system secure ) is
Availability, which is keeping your systems up.
There are dozens of Dos attacks, that are happening all the time
Protecting your network from denial of service is probably one of the major tasks
of your IPS engine.
let's create a Denial of Service policy.
Navigate to Policy & objects---IPV4 Dos policy
Create New
We will configure the incoming interface which is usually the WAN interface,
Source address can be All
The destination address can also be All unless you want to protect a specific
subnet.
Service is ALL
You can see that you have different anomalies that you can protect from, either
layer 3 anomalies and layer 4 anomalies
Each anomaly can be logged and in the middle of the table, you have different
actions to choose from, either to block the traffic or to monitor
On the right side, you will find the recommended threshold for each anomaly,
but you will need to configure the threshold based on your network topology, so
get familiar with your network baseline.
Anomalies
TCP Port Scan - done by tools such as Nmap to scan the network for open and
closed ports. if you have more than 1000 packets that are sent to one destination
address, then it triggers the action.
Once you configure your sensor, just apply it to the policy itself
and be aware of false-positive events since those anomalies can
happen from time to time and not only due to denial of service
attack.
Let's create another denial of service policy and this time we will protect our
gateway interface from another anomaly which is the ICMP Flood attack
If we will try to ping our gateway, Everything goes well, the rate is very
slow, usually, 1 packet per second, the size of the packet is 56 bytes
But then again, we can many tools available free on the internet, to conduct a
denial of service attack against our server, you can even use the hping tool
available in Linux or the regular terminal on the Mac, with the following command
Sudo Ping -f 192.168.1.1
-f stands for flood, your Mac will send hundreds and thousands of ICMP
packets towards the destination
As you can see, almost 20000 packets were sent in about 5 seconds
What Do We Do?
In our Policy, Move over to layer 4 anomalies. ICMP flood.
enable it and set the action to block
So let's configure the anomaly. Let's set the anomaly to ICMP sweep
Now once you do so, you can actually set the different parameters such as the
status, Log, and Do you want to quarantine
The answer is yes, we want to quarantine the attacker
“set quarantine attacker”
“set quarantine-expiry” <>
Here it is and we can set it to different time intervals. The default is five minutes,
but we can set it to one day, one week, three hours, and so on. So let's set it to
one day.
Whenever your IPS sees such an event, it will act upon but it will also ban
or quarantine the IP address.
Web Application Firewall
Your Fortigate firewall can also protect your network servers, not only your
clients.
This means that another approach is needed, as attacks against servers
utilize a different kind of vulnerabilities
In the case that you need to protect your servers, you can enable the WAF ( Web
application firewall ) on your fortigate.
The WAF security Profile uses the IPS engine, to inspect and recognize
malicious attempts
The following scenario is quite typical.
You have a DMZ interface. And behind that, you have your web servers.
Now let's create the address itself. Let's make it at the 10.0.6.1/24 we will not
enable anything on the administrative access. And that's it.
The next thing to do is to create a VIP that will allow outside users to get into our
web server.
VIP - virtual IP is used to map one IP address to another IP address, also known
as destination NAT. very similar to port forwarding on our home router
To create our VIP, navigate to Policy and object---- virtual IP
Create a new virtual IP and let's name our VIP “webserver”
Let's move to our ipv4 policy menu and create a new policy.
We don't really need to use NAT since we already have our VIP object which
maps the external IP to the inside private IP
Explicit Proxy
You can configure your fortigate to become a secure web gateway using a proxy.
You can use either Explicit Proxy or Transparent Proxy.
A web proxy intercepts requests from clients to servers, there are actually 2 TCP
connections, that are done
● From the client to the proxy
● From the proxy to the server
When using an Explicit Proxy, you will need to add up the IP address of the proxy
itself, either manually in the browser or using a PAC ( Proxy Auto-Config ) file.
Configuring explicit proxy involves some steps.
The very first thing to enable explicit proxy is navigating to system --- feature
visibility and make sure that the explicit proxy is enabled.
Now move to the interface that you wish to apply the proxy
Move to the bottom of the page and enable Explicit Proxy
We can also enable the proxy auto-configuration, which is a text file that contains
proxy settings
The PAC file has its own URL, you can use your command line
“get web-proxy explicit”
here you will find the syntax which is:
http:// followed by the address of that interface, the port / proxy.pac
Create New
we can see that we have an Explicit web proxy policy enabled on port two
The outgoing Interface is our WAN interface
Next, you can apply security profiles the same as you would do on any other
policy.
And that’s the basic configuration of an Explicit proxy. You can set many more
advanced settings related to authentication and network
Block IP Domains
There are times when you are asked to block a list of domains, that are related to
applications, that may cause harm to your network
As long as you control the connection which users connect to those apps, you
can try to block access to the app at the DNS level, using a block list of IP’s and
domains that are related to that app
In our example, we will try to block the TikTok app, but this could be any app.
The concept is the same
The first thing you will need to do is to get hold of TikTok domains and IP’s
TikTok uses different domains where it connects to when users log in, upload, or
view videos. to cut that, you will need to google “block TikTok domains“
Now copy all the domains and paste them into a text file and save it
The file should be plain text with one IP address on each line
On our FortiGate firewall, we will use an External IP block list, in many other
devices, you could probably enter the list manually, but here we will actually load
our text file to a web server so that we could manage the list more easily as we
may need to add more domains
Enable it
Press the + sign and choose the entries, your threat feed ( the one you created
before in the fabric connectors)
On your DNS filter page, you will see your new filter
Let’s move to the final part, apply your DNS filter to your Policy
Now Move to policy and objects — -IPV4 policy
And click on the policy, you want to add the DNS filter, in my case it is the full
access policy
Enable the DNS filter and choose our Block TikTok Filter
Save your Policy, and you’re Done
Final Words
You have just Finished “Fortigate Security Pocket Guide “ Part 2
I hope that you enjoyed the journey. My aim was to give you a head start on
security profiles, and how to protect your network, on one of the best
next-generation firewalls in the market.
Sincerely yours
Ofer Shmueli